[Thread Prev][Thread Next][Index]
Re: GRADS binary -> Ferret
On Feb 12, 7:37pm, Ilana Wainer wrote:
> Subject: GRADS binary -> Ferret
>
>
> Question: how to use a GRADS binary file with Ferret. In other words
> what would the " FILE/FORMAT " comand look like ?
>
> thanks
>
> -Ilana
===================================================
Hi Illana,
The GrADS binary files are typically (always?) grids of single precision
floating point values. Ferret can read 'em.
It is generally best to use Ferret to read the data and then SAVE the results
into a NetCDF file (with titles and units etc.). The reason for this is that
Ferret reads NetCDF much faster than unformatted binary and it cannot do direct
access or memory management on the binary data file. In Ferret we opted for
flexibility in ASCII and binary files at some cost of performance. Anyway, the
NetCDF files are standardized, machine independent, and self-describing ... all
that good stuff.
To read a variable from the binary file follow these steps:
1) Use DEFINE AXIS and DEFINE GRID to describe the coordinate system of the
variable
2) Use the FILE command with
/GRID=grid_from_step_1
/FORMAT=stream
/SKIP=#_of_words_to_skip_at_file_start
/VAR=varname
3) (optional) Use
SET VARIABLE/TITLE="My variable"/UNITS="those units" varname
to describe the variable
4) Use
SAVE/FILE=myfile.nc/TITLE="data set title" varname
5) for multiple variables repeat 2-4 and add "/APPEND" to the SAVE command in 4
Note: it is actually possible to read multiple variables simultaneously in step
2 by specifying /VAR="var1,var2,..." and
/COLUMNS=#_of_words_between_variables_in_file ... for simplicity we'll stick
with one variable at a time in this message)
Below is a more concrete example.
Cheers - steve
=================================================================
Suppose your file, GrADS.dat, was organized on a 2x2 degree global grid like
this:
Time 1, Level ?, Variable slp (sea level pressure)
Time 1, Level 1000, Variable td
Time 1, Level 850, Variable td
Time 1, Level 700, Variable td
Time 1, Level 500, Variable td
Time 1, Level 400, Variable td
Time 1, Level 300, Variable td
Time 1, Level 1000, Variable u
Time 1, Level 850, Variable u
then levels 700, 500, 400, 300, 250, 200, then
Time 1, Level 150, Variable u
Time 1, Level 100, Variable u
Time 1, Level 1000, Variable v
Time 1, Level 850, Variable v
then levels 700, 500, 400, 300, 250, 200, then
Time 1, Level 150, Variable v
Time 1, Level 100, Variable v
ditto all that for Time 2, ...
For this example we will read the 2D field of U at the first level at Time 1.
Step 1: define the grid for U
DEFINE AXIS/X=21E:19E:2/units=degrees xax ! 180 points
DEFINE AXIS/Y=89S:89N:2/unit=degrees yax ! 90 points
DEFINE AXIS/Z=1000:1000:1/units=mbars zax
DEFINE AXIS/t=1-JAN-1986:1-JAN-1986:1/unit=days tax ! or whatever ...
DEFINE GRID/X=xax/Y=yax/Z=zax/T=tax ugrid2d
Step 2: describe the variable in the file
FILE/VAR=u/SKIP=`180*90*7`/GRID=ugrid2d/FORMAT=stream GrADS.dat
Step 3: more information about variable "u"
SET VARIABLE/TITLE="Zonal Velocity"/UNITS="cm/sec" u
Step 4: Save the data to a NetCDF file
SAVE/FILE=GrADS.cdf/TITLE="My NetCDF data set" u
To keep this simple I've avoided the steps to handle the decreasing coordinates
on the Z axis of U. Write me if you want that.
--
| NOAA/PMEL | ph. (206) 526-6080
Steve Hankin | 7600 Sand Point Way NE | FAX (206) 526-6744
| Seattle, WA 98115-0070 | hankin@pmel.noaa.gov
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
ERL /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement