[Thread Prev][Thread Next][Index]

Re: [ferret_users] Reading ascii data



Hi Jaison,

Thanks very much, this worked!

I was able to use this to read in the full data set (17,654 values) for my f
ull 48yr+ data, plot it, and write it out as a netcdf file.

Before sending my email I did study the documentation.  But I didn't make th
e connection between a continuous stream of data being equivalent to 1095 co
lumns of data, and that the 1095 columns would be recognized as a single var
iable (not intuitive, but clear now).  I'm glad I learned this factoid about
 Ferret.

Another small but interesting note.  I started with an excel file, copied it
 over to a word file and converted from a table to simple text, copied it to
 a Linux machine and used a shell script to convert the CRs to spaces, but F
erret wouldn't read the file.  After I simply copied (cp) the file (to anoth
er file/different name), then Ferret would read the new file.  Ferret didn't
 want to read the .txt file which originated from MsWord, but would read the
 file after simply being copied on a Linux machine.  Probably some control c
haracters in the word/txt file.

Thanks again,

Ben


At 15:23 2007/02/17 +0530, you wrote:
> Hi Ben,
>          By default, Ferret reads ascii files along columns rather than al
ong
> rows, irrespective of the "delimiter" used. Depending on the grid specified,
> entries in the first column will be assigned to first variable, entries in
 the
> second column will be assigned to second variable and so on. To force Ferret
> to read "along the row/line", you have to use /COLUMNS qualifier with proper
> value, to FILE command. A simple example is shown below. 
> 
>   Please note that Ferret Documentation covers almost all aspects of handl
ing
> ASCII data. For example, "Ch2 Sec5.  ASCII DATA" contains detailed explana
tions
> about different commands/qualifiers with very good examples. Also the very
 next
> section, Ch2 Sec6. TRICKS TO READING BINARY AND ASCII FILES, explains some
> trics to handle ASCII data sets with non-standardized formats.
> 
>   It is always a good habit to convert the ascii data to NetCDF format in
> Ferret, after assigning proper grid/title/units etc., for future use. 
> 
> Hope this helps....
> 
> Regards,
> 
> Jaison
> 
> 
> !------example for reading ASCII data along row------------------
> \cancel mode verify
> !
> ! suppose the txt file ascii_columns.dat contains just the following line
> !
> !     1 2 3 4 5 6 7 8 9 10
> !
> ! Then the following method will show up only one value
> 
>       define axis/t=1:10:1 tax
>       define grid/t=tax gfile
>       file/grid=gfile/var=p ascii_column.dat
>       list p
> !
> ! But the /COLUMNS=10 qualifier will make all values available
> !
>       file/grid=gfile/columns=10/var=p1 ascii_column.dat
>       list p1
> 
> !-----end of example---------------------------------------------------
> 
> 
> On Sat, 17 Feb 2007, Ben Burford wrote:
> 
> > Hello All,
> > 
> > I have a very simple problem, but alas. . . .
> > 
> > I have ascii integer data that is space separated.  I can also create a 
comm
> > a separated file but space separated is easier.  Its a continuous stream
 of 
> > values (1095 values, which is 3 years of daily precipitation data) with 
no c
> > arriage returns.  I haven't been successfull in reading either type (spa
ce s
> > eparated or comma separted).
> > 
> > I tried variations on:
> > define axis/t=1:1095:1/units=days  tax
> > define grid/t=tax aaa
> > file/grid=aaa/var=p file.dat
> > 
> > I also tried variations on stream (I think stream is for binary data, bu
t do
> > es type=text handle ascii data?):
> > define axis/t=1:1095:1/units=days  tax
> > define grid/t=tax aaa
> > set data/format=delimited/delimiters="\b"/type=text/grid=aaa/var=p  file
dat
> >   (note: in this line "\b" is backslash b for blank).
> > 
> > In both cases if I do a "list p" I only I find that I've read in only on
e da
> > ta value.
> > 
> > Surely this must be a simple thing - read in a string of ascii values, e
ithe
> > r space or comma delimited (I could also convert the commas to tabs as d
elim
> > iters).
> > 
> > Please show me how to do this.
> > 
> > Thank you,
> > 
> > Ben
> > 
> > 
> > 
>  




[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement