| 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) Although coordinate names such as "lat", "lon", "latitude", |
| 29 |
etc. will work without any problems for plotting data, it seems |
| 30 |
that the names "X" and "Y" sould be preferred for the coordinate |
| 31 |
names so that calculations (eg. curl) can be applied to those |
| 32 |
data sets. For an example see: |
| 33 |
|
| 34 |
TRENBERTH_tau_mask/EH3_notes_mask.txt |
| 35 |
|
| 36 |
where both naming styles are used but the latter "X", "Y" naming |
| 37 |
scheme should be preferred. |
| 38 |
|
| 39 |
2) In order to work with the Ingrid "plot land" option, dimensions |
| 40 |
should have units of "degree_east" and "degree_north" as, for |
| 41 |
example, specified by: |
| 42 |
|
| 43 |
nc{'X'}.units = 'degree_east'; |
| 44 |
nc{'Y'}.units = 'degree_north'; |
| 45 |
|
| 46 |
The actual dimension names (eg. "lat" or "Y") are unimportant. |
| 47 |
|
| 48 |
3) It is generally a good idea to set the "gridtype" to 1 or 0 to |
| 49 |
indicate that the coordinate "wraps" or not. The gridtype |
| 50 |
attribute allows Ingrid to, for instance, plot longitudinal data |
| 51 |
over "wrapped" ranges such as -100 to 500deg. The attribute can |
| 52 |
be set using commands such as: |
| 53 |
|
| 54 |
nc{'X'}.gridtype = ncint(1); |
| 55 |
nc{'Y'}.gridtype = ncint(0); |
| 56 |
|
| 57 |
4) Ingrid does seem to correctly handle the "_FillValue" attribute |
| 58 |
and it can be set using a MatLAB command such as: |
| 59 |
|
| 60 |
nc{ idu }.FillValue_ = ncdouble(-9999.0); |
| 61 |
|
| 62 |
[ Note how the "_" character is moved to the end of the attribute |
| 63 |
name since MatLAB cannot correctly handle variable names with a |
| 64 |
leading underscore. ] |