1 |
|
2 |
Examples: NetCDF & MatLAB |
3 |
========================== |
4 |
|
5 |
These directories contain examples of MatLAB commands for reading, |
6 |
creating, and modifying NetCDF files. All the scripts use Chuck |
7 |
Denham's MatLAB package which can be obtained at: |
8 |
|
9 |
"MexCDF and NetCDF Toolbox For Matlab-5&6" |
10 |
http://woodshole.er.usgs.gov/staffpages/cdenham/public_html/MexCDF/nc4ml5.html |
11 |
|
12 |
and must first be installed. |
13 |
|
14 |
|
15 |
The NetCDF files generated here are intended for use with Ingrid: |
16 |
|
17 |
http://ingrid.mit.edu/ |
18 |
|
19 |
As a result, they approximately follow the simple COARDS convention |
20 |
which is described at: |
21 |
|
22 |
http://www.unidata.ucar.edu/packages/netcdf/conventions.html |
23 |
http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html |
24 |
|
25 |
|
26 |
The key items for the use of NetCDF files within Ingrid are: |
27 |
|
28 |
1) In order to work with the Ingrid "plot land" option, dimensions |
29 |
should have units of "degree_east" and "degree_north" as, for |
30 |
example, specified by: |
31 |
|
32 |
nc{'lon'}.units = 'degree_east'; |
33 |
nc{'lat'}.units = 'degree_north'; |
34 |
|
35 |
The actual dimension names (eg. "lat" or "Y") are unimportant. |
36 |
|
37 |
2) It is generally a good idea to set the "gridtype" to 1 or 0 to |
38 |
indicate that the coordinate "wraps" or not. The gridtype |
39 |
attribute allows Ingrid to, for instance, plot longitudinal data |
40 |
over "wrapped" ranges such as -100 to 500deg. The attribute can |
41 |
be set using commands such as: |
42 |
|
43 |
nc{'X'}.gridtype = ncint(1); |
44 |
nc{'Y'}.gridtype = ncint(0); |
45 |
|
46 |
3) Ingrid does seem to correctly handle the "_FillValue" attribute |
47 |
and it can be set using a MatLAB command such as: |
48 |
|
49 |
nc{ idu }.FillValue_ = ncdouble(-9999.0); |
50 |
|
51 |
[ Note how the "_" character is moved to the end of the attribute |
52 |
name since MatLAB cannot correctly handle variable names with a |
53 |
leading underscore. ] |