[gradsusr] Writing GrADS netCDF files with IDL
Dave Allured
dave.allured at noaa.gov
Fri Sep 16 14:21:16 EDT 2011
Richard,
On 9/15/2011 11:07 AM, Bantges, Richard J wrote:
> Hi - thanks to everyone that took the time to reply to my query, apologies that I didn't respond to each of you individually.
>
> I've managed to write a GrADS compatible netCDF file (using IDL) that can be opened using sdfopen in GrADS.
>
> However, I'm now trying to figure out if it's possible to do the following with the realms of sdfopen (i.e. I don't want to write a control file if it can be avoided):
> 1. Define what the missing values in my data array are. I know how this could be done using a control file, but is it possible to include this within the netCDF?
Just add the correct missing value attributes to your data variable.
For maximum compatibility, add both of these:
(IDL CODE, untested:)
NCDF_ATTPUT, file_id, 'var_name', '_FillValue', vmissing
NCDF_ATTPUT, file_id, 'var_name', 'missing_value', vmissing
Where vmissing is a numeric scalar of the same data type as the data
variable.
> 2. I have a 2D data array, that ideally I'd like to make 3D (x,y,z) (where x longitude, y latitude, and z would be levels). Again I know how to do this using a control file, but would like to know if it's possible to do this within the netCDF file, such that sdfopen in GrADS will read it.
Certainly you can write a 3-D array from IDL. Ahem, you should have
taken a closer look at the IDL examples that were suggested by John
Huddleston! Here is a lovely 4-D example from that collection; I am
sure you can figure out how to cut it down to 3-D:
http://www.unidata.ucar.edu/software/netcdf/examples/programs/pres_temp_4D_wr.pro
Note that this example also shows how to make a proper coordinate
variable for the added level dimension, which you will need for
automatic sdfopen compatibility.
--Dave
More information about the gradsusr
mailing list