Hi Ag,
O yes, you're right. To tell it to read just the one value, we need to
tell it to do that. I'll show how to do that in a minute.
First, do you even need to read the number of points? Or when you go
to read the data are you just going to read the rest of the file? If
you're going to read the whole file, you can just start with the
command that has /skip=4, and Ferret will read the whole thing. If you
do need to know the number of points after reading, you can get that
with the @NGD transformation on one of the variables:
FILE/FORM=delim/SKIP=4/DELIM="\b"/TYPE="text,date,time,text,numeric"/VAR="fname,ddate,ttime,dlab,val"
mydat.dat
LET npts = `ddate[i=@ngd]`
If you want to read the npts from the file however, you would define a
1-point axis and read the data using that axis.
DEFINE AXIS/X=1:1 x1
DEFINE GRID/x=x1 xgrid
FILE/GRID=xgrid/SKIP=2/var=nn mydat.dat
Now, if you want to, you could do the same thing with the rest of the
data, defining an axis of length `nn` and read the data with a grid
defined with that x axis.
Ansley
ag wrote:
Dear Ferret Users:
I am still missing something here.
I did try your suggestion below but Ferret reads in everything after
the first two lines after the command
FILE/SKIP=2/VAR=nn mydat.dat
Let npts=`nn`
-------------------------------------------------------------------------
Ferret Session
yes? FILE/SKIP=2/VAR=nn
"/ftp/incoming/G3/DEV/ws/GiMini/Timeseries_MOD04_L2_Image_Optical_Depth_Land_And_Ocean_GISS_10974194953.csv"
yes? LET npts=`nn`
**TMAP ERR: Host is down
Last or next-to-last record read:
filename begindatetime location mean
Data set:
/ftp/incoming/G3/DEV/ws/GiMini/Timeseries_MOD04_L2_Image_Optical_Depth_Land_And_Ocean_GISS_10974194953.csv
Data file:
/ftp/incoming/G3/DEV/ws/GiMini/Timeseries_MOD04_L2_Image_Optical_Depth_Land_And_Ocean_GISS_10974194953.csv
yes?
Any ideas? Any help is most appreciated.
Thanks
Arun
PS" The ASCII file has identical blocks of data like the one block
below each actual data block being preceded by 4 lines of comment, the
second of which tells how data records are there.
Also I am unable to tell ferret to read exactly "nn" records.
On Wed, Aug 5, 2009 at 12:42 PM, Ansley
Manke <Ansley.B.Manke@xxxxxxxx>
wrote:
Hi Ag,
To just give a few more details to what Peter said -- you would do this
in two separate read statements. The first would give you the number
of records to be read and the second would read in the variables
(although if it's always just one batch of actual data, Ferret can just
read to the end of the file.)
FILE/SKIP=2/VAR=nn mydat.dat
! We will cancel the dataset to read the next block, so save the
value just read:
LET npts = `nn`
! Now read the variables
CANCEL DATA mydat.dat
FILE/FORM=delim/SKIP=4/DELIM="\b"/TYPE="text,date,time,text,numeric"/VAR="fname,ddate,ttime,dlab,val"
mydat.dat
Notice I didn't use npts. If there were several blocks of data you
would DEFINE AXIS and DEFINE GRID, and use FILE/GRID= to read a
specific number of points from each block.
If you need to create a time axis from the date and time variables,
there is a similar example in this FAQ - How
can I create a time axis from variables containing year, month, day,
etc?
http://ferret.pmel.noaa.gov/FERRET_17sep07/FAQ/axes_and_data/time_axis_from_variables.html
Although your case here is simpler than what's in the FAQ -- you
already have ddate which is in units days from 1-jan-1900, and ttime
which is in units of hours and fraction of hours.
Ansley
ag wrote:
Dear Ferret Users:
Am looking for some suggestions on how to read an ASCII file (example
below) using Ferret. I would like to be able to skip the first two
records and then read the third as an integer (69 in this case), skip
the fourth record and then read the "integer" number of records of
input with each record having 5 columns.
The reason I need to do this is sometimes, there are more a few files
of the format below concatenated and the number of records of each file
is specified always as below in separate blocks.
Thanks in Advance
agdc2005
--------------------File---------------
GISS
Image_Optical_Depth_Land_And_Ocean/MOD04_L2
69
filename begindatetime location mean
MOD04_L2.A2007001.1500.005.2007003093108.hdf 2007-01-01 15:00:00
GISS
MOD04_L2.A2007001.1635.005.2007003093604.hdf 2007-01-01 16:35:00
GISS
MOD04_L2.A2007002.1540.005.2007004182338.hdf 2007-01-02 15:40:00
GISS 0.081
MOD04_L2.A2007003.1625.005.2007005151340.hdf 2007-01-03 16:25:00
GISS 0.027
MOD04_L2.A2007004.1530.005.2007007055054.hdf 2007-01-04 15:30:00
GISS
MOD04_L2.A2007005.1615.005.2007008173325.hdf 2007-01-05 16:15:00
GISS
MOD04_L2.A2007006.1520.005.2007010020024.hdf 2007-01-06 15:20:00
GISS
MOD04_L2.A2007007.1600.005.2007012202039.hdf 2007-01-07 16:00:00
GISS 0.167
MOD04_L2.A2007008.1505.005.2007012223915.hdf 2007-01-08 15:05:00
GISS
MOD04_L2.A2007008.1645.005.2007012225717.hdf 2007-01-08 16:45:00
GISS
MOD04_L2.A2007009.1550.005.2007013005323.hdf 2007-01-09 15:50:00
GISS
MOD04_L2.A2007010.1630.005.2007013053221.hdf 2007-01-10 16:30:00
GISS 0.039
MOD04_L2.A2007011.1535.005.2007014063943.hdf 2007-01-11 15:35:00
GISS 0.113
MOD04_L2.A2007012.1620.005.2007014045513.hdf 2007-01-12 16:20:00
GISS
MOD04_L2.A2007013.1525.005.2007015044928.hdf 2007-01-13 15:25:00
GISS
MOD04_L2.A2007014.1605.005.2007017161152.hdf 2007-01-14 16:05:00
GISS
MOD04_L2.A2007015.1510.005.2007017183912.hdf 2007-01-15 15:10:00
GISS
MOD04_L2.A2007016.1555.005.2007018180305.hdf 2007-01-16 15:55:00
GISS
MOD04_L2.A2007017.1500.005.2007019123555.hdf 2007-01-17 15:00:00
GISS 0.000
MOD04_L2.A2007017.1635.005.2007019125327.hdf 2007-01-17 16:35:00
GISS 0.028
MOD04_L2.A2007018.1540.005.2007020111006.hdf 2007-01-18 15:40:00
GISS 0.126
MOD04_L2.A2007018.1545.005.2007020105940.hdf 2007-01-18 15:45:00
GISS
MOD04_L2.A2007019.1625.005.2007023060629.hdf 2007-01-19 16:25:00
GISS
MOD04_L2.A2007020.1530.005.2007023002013.hdf 2007-01-20 15:30:00
GISS
MOD04_L2.A2007021.1615.005.2007023181352.hdf 2007-01-21 16:15:00
GISS
MOD04_L2.A2007022.1520.005.2007024120208.hdf 2007-01-22 15:20:00
GISS
MOD04_L2.A2007023.1600.005.2007024194356.hdf 2007-01-23 16:00:00
GISS 0.136
MOD04_L2.A2007024.1505.005.2007027011552.hdf 2007-01-24 15:05:00
GISS 0.095
MOD04_L2.A2007024.1645.005.2007027010315.hdf 2007-01-24 16:45:00
GISS 0.086
|