[Thread Prev][Thread Next][Index]

Re: [ferret_users] CRU ascii file to netcdf



Hi Peter,

(Disclaimer -- this response is hurried -- based just on a quick scan of your problem ... just an idea in case it is useful.)

The /FORMAT= qualifier on the FILE command supports the full syntax of FORTRAN formats.  With that you can describe multiple lines of input as a single "record".  It looks to me at a glance like a format statement that uses the "/" (slash) multi-line syntax might do the trick.  You should be able to read the entire input into a single variable with something like

    /FORMAT=(11(12F5.0/))

Read this into a variable that is defined on a grid (/GRID=) that is 12x11 in size.  The indices j=2:11 on the axis that is of length 11 will be your years.  The i=1:12 on the other axis will be your months.  Use the LET command and the RESHAPE function.  Then you may want to tell Ferret to SAVE the data to a netCDF file so it is nicer to work with thereafter.

    2 cents - Steve

-------------------

Peter Szabo wrote:
Dear Ferret Users,

Its me, again...
I have data set of CRU 10" in ASCII format like this:
   4   1
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
   4   2
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
The 1st, 12th, 23th... lines are the coordinate numbers of the data (the longitude goes from 4:258, the latitude goes from 1:228)
The "real" first row means a year 1961... The last one 1970. The columns mean months of the year. So 10*12 matrix i have after the grid defining numbers.
I would like to make a netcdf of it. Here is how i was trying to solve this problem.

--------------------------
define axis/t=1:120:1/np=120 time
define grid/t=time grid
repeat/range=1:58140:1/name=m (file/ez/var="lon,lat"/skip=`2+11*(m-1)`:`11+11*(m-1)` "myfile" ;\
file/var=pre/skip=`1+11*(m-1)`/columns=12/grid=grid "myfile" ;\
save/file="output.nc"/append/clobber/ilimits=1:258/jlimits=1:228/i=`lon`/j=`lat` pre)
----------------------------

Has anyone faced this problem?
Thank You,
Peter Szabo, HMS

-- 
Steve Hankin, NOAA/PMEL -- Steven.C.Hankin@xxxxxxxx
7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080, FAX (206) 526-6744

"The only thing necessary for the triumph of evil is for good men
to do nothing." -- Edmund Burke

[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement