[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading GrADS data file in IDL



In article <3A70F0A5.575F123@pacific.met.fsu.edu>,
  Kyong Hwan Seo <khseo@pacific.met.fsu.edu> wrote:
> msienkiewicz@my-deja.com wrote:
>
> >
> > The basic GrADS file format is very simple.  The data are stored as
> > a sequence of unformatted floating point arrays.  If your '.ctl'
file does
> > not have any special options specified (i.e. 'options sequential',
> > 'options byteswapped', 'options bigendian' or the like) and you are
> > planning to read it on a computer that has the same 'endianness'
> > as the computer that generated it - well you can just use the ASSOC
> > command and access those arrays directly from the disk.  To advise
> > further, we'd need to have a look at your .ctl file.
> >
>
> >
> > Meta
> >
>
> Thanks, Meta
>
> I believe the ctl file is pretty much usual one.
> Could you show me one example of using ASSOC command(function) for my
> case.
>
> Thanks again,
>
> Seo
>
> (Note that the z dimensions for variables are different (16 or 10).)
> Below is the ctl file:
>
> DSET csf_rNCEP_flux.data
> undef -9999.
> TITLE  CSEOFs of NCEP reanalysis
> * ------------------------------------------------------------------
> XDEF 47 LINEAR 45.0  5.0
> *
> YDEF 47 LINEAR -57.5 2.5
> *
> ZDEF 16 LEVELS 925 850 700 600 500 400 300 250 200 150 100 70 50 30 20
> 10
> *
> TDEF 96 LINEAR Jan1958 1mo
> *
> vars 33
> xubup  16  35,100,0 ** x1
> xupup  16  35,100,0 ** x2
> xvbup  16  35,100,0 ** x3
> xvpub  16  35,100,0 ** x4
> xvpup  16  35,100,0 ** x5
> xwbup  10  35,100,0 ** x6
> xwpub  10  35,100,0 ** x7
> xwpup  10  35,100,0 ** x8
> xtbup  16  35,100,0 ** x9
> xtpub  16  35,100,0 ** x10
> xtpup  16  35,100,0 ** x11
> yubvp  16  35,100,0 ** y1
> yupvb  16  35,100,0 ** y2
> yupvp  16  35,100,0 ** y3
> yvbvp  16  35,100,0 ** y4
> yvpvp  16  35,100,0 ** y5
> ywbvp  10  35,100,0 ** y6
> ywpvb  10  35,100,0 ** y7
> ywpvp  10  35,100,0 ** y8
> ytbvp  16  35,100,0 ** y9
> ytpvb  16  35,100,0 ** y10
> ytpvp  16  35,100,0 ** y11
> zubwp  10  35,100,0 ** z1
> zupwb  10  35,100,0 ** z2
> zupwp  10  35,100,0 ** z3
> zvbwp  10  35,100,0 ** z4
> zvpwb  10  35,100,0 ** z5
> zvpwp  10  35,100,0 ** z6
> zwbwp  10  35,100,0 ** z7
> zwpwp  10  35,100,0 ** z8
> ztbwp  10  35,100,0 ** z9
> ztpwb  10  35,100,0 ** z10
> ztpwp  10  35,100,0 ** z11
> ENDVARS
>
> --
> Kyong Hwan Seo
> Florida State University            Home  :(850) 216-1985
> Dept. of Meteorology                Office:(850) 644-2274
> Email: khseo@pacific.met.tamu.edu   Fax   :(850) 644-9642
>
I'm assuming still that this is a regular GrADS file with unformatted
binary arrays.  (I'm not familiar with the "35,100,0" notation in
the third column... so I could be missing something here.)

The control file says that you have a number of arrays
dimensioned 47 x 47 saved in the file.  In the GrADS format all
the vertical levels for a single variable at a given time are
stored consecutively.  The first sixteen arrays should be the 16
levels of your variable 'xubup', the next 16 are 'xupup', etc.

What I would try then is something like this:

; Open the file as unit 1
;
open,1,'csf_rNCEP_flux.data'
;
; Make an associated variable
;
arr = assoc(1,fltarr(47,47))
;
; Draw a contour plot of the first variable at the first level
;
contour, arr(0)
;
; Try reading in the 47x47x10 array 'xwpub'
;
skip = 5*16+10
xwpub = fltarr(47,47,10)
for j=0,9 do xwpub(*,*,j) = arr(skip+j)
;
; try reading the 47x47x10 array 'xwpub' at time 5
; "skipt" is the number of grids at a single time period to skip over
skipt = 16*16 + 17*10
for j = 0,9 do xwpub(*,*,j) = arr(5*skipt+skip+j)

... or something like that anyway.  It's what I would try first,
anyway.  Hope this helps.

Meta


Sent via Deja.com
http://www.deja.com/