1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
|
<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
<html>
<head>
<title>GrADS Gridded Data</title>
</head>
<body bgcolor="e0f0ff" text="#000000">
<h1>About GrADS Gridded Data Sets</h1>
<p>
This section describes GrADS gridded data sets -- their structure and
format, how to create them, and how to instruct GrADS to interpret
them properly. Here are some quick links for skipping through this
section:
<ul>
<li><a href="aboutgriddeddata.html#introduction">Introduction</a>
<li><a href="aboutgriddeddata.html#descriptor">The Data Descriptor File</a>
<li><a href="aboutgriddeddata.html#structure">Structure of a Gridded Binary Data File</a>
<li><a href="aboutgriddeddata.html#formats">Binary Formats</a>
<li><a href="aboutgriddeddata.html#create">Creating Data Files</a>
</ul>
<hr>
<p>
<h2><a name="introduction">Introduction</a></h2>
<p>
In GrADS, the raw binary data and the meta data (information about the
binary data) are stored in separate files. The meta data file contains
a complete description of the binary data as well as instructions for
GrADS on where to find the data and how to read it. The binary data
file is purely data with no space or time identifiers. The meta data
file is the one you open in GrADS -- it is called the <b>data
descriptor file</b>. The data descriptor file has a default file extension of <code>.ctl</code>
and is therefore also referred to as a <b>control file</b>.
<p>
<code>ga-> <a href="gradcomdopen.html">open</a> <i>filename</i>.ctl</code>
<h2><a name="descriptor">The Data Descriptor File</a></h2>
<p>
The data descriptor file contains a complete description of the binary
data as well as instructions for GrADS on where to find the data and
how to read it. The descriptor file is an ascii file that can be
created easily with a text editor. The general contents of a gridded
data descriptor file are as follows:
<ul>
<li>Filename for the binary data
<li>Missing or undefined data value
<li>Mapping between grid coordinates and world coordinates
<li>Description of variables in the binary data set
</ul>
<p>
The individual components of data descriptor files are discussed in
detail in the section <a href="descriptorfile.html">Elements of a Data
Descriptor File</a>.
<p> The data descriptor file is free format, which means the components of each
record (line of text) are blank delimited. Leading blanks at the beginning of
each record are removed before parsing. Comment records must start with an asterisk
(*). Individual records may not be more than 255 characters long. Here is an
example of a basic data descriptor file:
<p>
<ul>
<pre>
<a href="descriptorfile.html#DSET">DSET</a> ^gridded_data_sample.dat
<a href="descriptorfile.html#TITLE">TITLE</a> Gridded Data Sample
<a href="descriptorfile.html#UNDEF">UNDEF</a> -9.99E33
<a href="descriptorfile.html#XDEF">XDEF</a> 180 LINEAR 0.0 2.0
<a href="descriptorfile.html#YDEF">YDEF</a> 90 LINEAR -90 2.0
<a href="descriptorfile.html#ZDEF">ZDEF</a> 10 LEVELS 1000 850 700 500 400 300 250 200 150 100
<a href="descriptorfile.html#TDEF">TDEF</a> 4 LINEAR 0Z10apr1991 12hr
<a href="descriptorfile.html#VARS">VARS</a> 4
slp 0 99 sea level pressure
hgt 10 99 heights
temp 10 99 temperature
shum 6 99 specific humidity
<a href="descriptorfile.html#ENDVARS">ENDVARS</a>
</pre>
</ul>
<p>
In this example, the binary data set is named
<code>gridded_data_sample.dat</code> and is located in the same
directory as the descriptor file. This is specified by the caret (^) in
front of the data filename. The undefined or missing data value is
-9.99e33, there are 180 grid points in the X direction, 90 grid points
in the Y direction, 10 vertical levels, 4 time steps, and 4
variables. The variable "slp" is a surface variable -- it has no
vertical levels, but is assigned a default vertical coordinate of
Z=1. The variables "hgt" and "temp" have 10 vertical levels, and the
variable "shum" has 6 vertical levels (the first six listed, 1000 to
300).
<p>
<h2><a name="structure">Structure of a Gridded Binary Data File</a></h2>
<p>
The binary data file is purely data with no space or time
identifiers. The data descriptor specifies the data's grid dimensions,
but it is up to the user to make sure that the binary data have been
written to file in the proper order so GrADS will interpret them
correctly.
<p>
GrADS views gridded data sets as multi-dimensional arrays varying in
longitude, latitude, vertical level, variable, and time. In version 2.0, a <a href="ensembles.html">fifth grid dimension</a> was added. The fifth grid dimension is assumed to be used for ensembles, and so it is given the name E (or ens), but because it is generally implemented, it may be used for other grid dimensions such as EOFs. The default size of the E dimension is 1 -- if no E dimension exists, it is not necessary to explicity declare it the descriptor file.
<p>It is helpful
to think of a gridded binary data file as a sequence of "building
blocks", where each building block is a horizonal grid of data varying
in the X and Y dimensions. The first dimension (X) always varies from
west to east; the second dimension (Y) varies from south to north (by
default). One horizontal grid represents a particular variable at a
particular height and time. Each horizontal grid in a GrADS binary data file must be the same
size. If you have two variables with different horizontal grids,
you must create two separate data sets.
<p>
The structure of a 3-D, 4-D, or 5-D data set is determined by the
order in which the horizonal grids are written to file. The building
blocks are stacked in a sequence according to dimension. The sequence
goes in the following order starting from the fastest varying
dimension to the slowest varying dimension: longitude (X), latitude
(Y), vertical level (Z), variable (VAR), time (T), and ensemble (E).
<p>
For example, suppose you want to create a 4-D binary data set
containing four variables. The horizonal grids would be written to the
data set in the following order:
<ul>
<pre>
Time 1, Variable 1, Each vertical level from bottom to top
Time 1, Variable 2, Each vertical level from bottom to top
Time 1, Variable 3, Each vertical level from bottom to top
Time 1, Variable 4, Each vertical level from bottom to top
Time 2, Variable 1, Each vertical level from bottom to top
Time 2, Variable 2, Each vertical level from bottom to top
Time 2, Variable 3, Each vertical level from bottom to top
Time 2, Variable 4, Each vertical level from bottom to top
etc.
</pre>
</ul>
<p>5-D ensemble data sets are created by concatenating 4-D data sets together -- the ensemble dimension varies outside of all the others. To extend the previous example, suppose you are creating a data set that has 3 ensembles (but only 2 variables) :
<ul>
<pre>
Ensemble 1, Time 1, Variable 1, Each vertical level from bottom to top
Ensemble 1, Time 1, Variable 2, Each vertical level from bottom to top
Ensemble 1, Time 2, Variable 1, Each vertical level from bottom to top
Ensemble 1, Time 2, Variable 2, Each vertical level from bottom to top
<...>
Ensemble 1, Time N, Variable 1, Each vertical level from bottom to top
Ensemble 1, Time N, Variable 2, Each vertical level from bottom to top
Ensemble 2, Time 1, Variable 1, Each vertical level from bottom to top
Ensemble 2, Time 1, Variable 2, Each vertical level from bottom to top
Ensemble 2, Time 2, Variable 1, Each vertical level from bottom to top
Ensemble 2, Time 2, Variable 2, Each vertical level from bottom to top
<...>
Ensemble 2, Time N, Variable 1, Each vertical level from bottom to top
Ensemble 2, Time N, Variable 2, Each vertical level from bottom to top
Ensemble 3, Time 1, Variable 1, Each vertical level from bottom to top
Ensemble 3, Time 1, Variable 2, Each vertical level from bottom to top
Ensemble 3, Time 2, Variable 1, Each vertical level from bottom to top
Ensemble 3, Time 2, Variable 2, Each vertical level from bottom to top
<...>
Ensemble 3, Time N, Variable 1, Each vertical level from bottom to top
Ensemble 3, Time N, Variable 2, Each vertical level from bottom to top
</pre>
</ul>
<h2><a name="formats">Binary Formats</a></h2>
<p>
GrADS can read binary data that are formatted with or without
FORTRAN record length headers. Files containing record length headers
are called "sequential" and those without embedded record length
information are called "direct access" or "stream" files. Unless
otherwise specified, GrADS will assume the data file does not contain
the record length headers.
<p>
GrADS can also directly read GRIB formatted data -- one of GrADS
most powerful and unique features! See the section on
<a href="grib2ctl.html">Creating Data Descriptor Files for GRIB
Data</a> for more information.
<p>
A third category of data formats that GrADS can read are
"self-describing files" such as NetCDF or HDF-SDS. For more
information, see the references pages for <a
href="sdfdescriptorfile.html">reading NetCDF or HDF-SDS files</a>.
<p>
<h2><a name="create">Creating Data Files</a></h2>
<p>
The default format for GrADS gridded binary data files is "stream" or
"direct access". If you want to read FORTRAN "sequential" unformatted
binary data files, you must include the following additional record in
the data descriptor file:
<ul><code><a href="descriptorfile.html#OPTIONS">OPTIONS</a> sequential</code></ul>
<p>
Following are three examples of how to create gridded binary data
files with simple FORTRAN programs.
<p>
<ol>
<li>Suppose you have U and V wind components in 4-dimensions (X, Y, Z, and T)
and you want to write them out in so they can be viewed in GrADS. The
FORTRAN code might look something like this:
<p>
<pre>
parameter (ni=144,nj=91,nk=8,nt=4)
dimension u(ni,nj,nk),v(ni,nj,nk),dum(ni,nj)
do n=1,nk
call load(u,ni,nj,nk,n,dum)
write(10) dum
end do
do n=1,nk
call load(v,ni,nj,nk,n,dum)
write(10) dum
end do
subroutine load(a,ni,nj,nk,n,dum)
dimension a(ni,nj,nk),dum(ni,nj)
do i=1,ni
do j=1,nj
dum(i,j)=a(i,j,n)
end do
end do
return
</pre>
<p>
The data descriptor file would look something like:
<p>
<pre>
<a href="descriptorfile.html#DSET">DSET</a> ^model.dat
<a href="descriptorfile.html#TITLE">TITLE</a> Sample Model Data
<a href="descriptorfile.html#UNDEF">UNDEF</a> 0.10000E+16
<a href="descriptorfile.html#XDEF">XDEF</a> 144 linear 0 2.5
<a href="descriptorfile.html#YDEF">YDEF</a> 91 linear -90 2.0
<a href="descriptorfile.html#ZDEF">ZDEF</a> 8 levels 1000 900 800 700 500 300 100 50
<a href="descriptorfile.html#TDEF">TDEF</a> 4 linear 00z01apr85 6hr
<a href="descriptorfile.html#VARS">VARS</a> 2
u 8 99 U component
v 8 99 V component
<a href="descriptorfile.html#ENDVARS">ENDVARS</a>
</pre>
<p>
<li>This simple example write out one variable:
<p>
<pre>
REAL Z(72,46,16)
....
OPEN(8,FILE='grads.dat',FORM='UNFORMATTED',
& ACCESS='DIRECT',RECL=72*46)
....
IREC=1
DO 10 I=1,16
WRITE (8,REC=IREC) ((Z(J,K,I),J=1,72),K=1,46)
IREC=IREC+1
10 CONTINUE
</pre>
<p>
<li>Another simple sample might be:
<p>
<pre>
REAL X(100)
DO 10 I=1,100
X(I)=I
10 CONTINUE
OPEN (8,FILE='samp.dat',FORM='UNFORMATTED',ACCESS='DIRECT',
&RECL=100)
WRITE (8,REC=1) X
STOP
END
</pre>
<p>
The associated descriptor file:
<p>
<pre>
<a href="descriptorfile.html#DSET">DSET</a> samp.dat
<a href="descriptorfile.html#TITLE">TITLE</a> Sample Data Set
<a href="descriptorfile.html#UNDEF">UNDEF</a> -9.99E33
<a href="descriptorfile.html#XDEF">XDEF</a> 100 LINEAR 1 1
<a href="descriptorfile.html#YDEF">YDEF</a> 1 LINEAR 1 1
<a href="descriptorfile.html#ZDEF">ZDEF</a> 1 LINEAR 1 1
<a href="descriptorfile.html#TDEF">TDEF</a> 1 LINEAR 1JAN2000 1DY
<a href="descriptorfile.html#VARS">VARS</a> 1
x 0 99 100 Data Points
<a href="descriptorfile.html#ENDVARS">ENDVARS</a>
</pre>
<p>
Once created, you can use this data set to experiment with GrADS
data functions, such as:
<p>
<ul>
<code>
<a href="gradcomddisplay.html">display</a>
<a href="gradfuncsin.html"> sin</a>(x/50)
</code>
</ul>
</ol>
</body>
</html>
|