Error in creating netCDF for GrADS reading

Owen Doherty odoherty at IC.SUNYSB.EDU
Mon Jan 4 18:31:06 EST 2010


Dear Grads Users,

I am having difficulties creating and writing to a netcdf file that can 
be read by GrADS.  The data is loaded into GrADS successfully, but when 
displayed looks similar to improperly written binary data (e.g. all data 
is in the range of 0 to 9e+36 interval 1e+36).  Below are the steps I 
take to create a 4-D gridded netCDF, write to the netCDF and finally to 
read the file into GrADS.

First, I create an nc file using the ncgen utility.  I have tried 
creating netCDF files with the variable both as "float" and "double" 
neither of which is successful and the errors from which appear to be 
similar.  Below is my source code (.cdl file) for this step.

netcdf test_ncgen{
dimensions:
    longitude=144;
    latitude =73;
    t=31;
    z=9;

variables:
    double longitude(longitude);
           longitude:units = "degrees_east";

    double latitude(latitude);
           latitude:units = "degrees_north";
   
    double t(t);
        t:units = "seconds since 1970-1-1 00:00:00";
       
    double z(z);
        z:units = "lev";
        z:valid_range = 200.,1000.;

    float omejjam(longitude, latitude, t, z) ;
       

data:
omejjam = 0;

Secondly, I write to the netCDF file using MATLAB.  The write step is 
fairly simple and I suspect that I am missing something in here to have 
it write out as binary.  I have tried outputting single precision 
(float) and double precision data from MATLAB both of which result in 
the same error.  I am using MATLAB 2008b to do the writing.  The write 
command is as follows:

nc=netcdf.open('test_ncgen.nc','nc_write');
[varname, xtype, dimids, numatts] = netcdf.inqVar(nc,4)% 0 - omejjam
 netcdf.putVar(nc,4,omejjam);

Lastly, I read the data into GrADS.  I have tried using sdfopen, xdfopen 
and the regular open command.  Adding the OPTION little_endian to the 
control file does not solve the issue.  All of the data looks erroneous, 
but consistent in between each different open command.  If anyone has 
any advice as to how to solve this problem, I would be grateful for the 
insight.

Owen

-- 
Owen Doherty
School of Marine and Atmospheric Science
Institute for Terrestrial and Planetary Atmospheres
103 Discovery Hall
Stony Brook University
Stony Brook, NY 11794
(631)-632-8682 (office)



More information about the gradsusr mailing list