[gradsusr] GRADS USER FORUM QUESTION

Huw Davies john.huw.davies at gmail.com
Fri Jul 26 08:08:03 EDT 2013


Hello.

I am trying to open a NetCDF file in GRADS that I have generated in matlab
(filename swh.nc). 

 

The file is an 80x180 matrix of global wave height data on a regular 2 deg
grid with bottom right corner at -80 -104 (80S 140W). The file does not
contain any Latitude, Longitude, X or Y information. 

 

My matlab code is:

% Create a variable in the MATLAB workspace

swh_12 = flipud(swh_12(1:80, 1:180));

numrow = 80;

numcol = 180;

my_data=swh_12;

% Create a netCDF file

ncid = netcdf.create('swh.nc','NC_WRITE');

% Define a dimension in the file (must give it a name and length or use
NC_UNLIMITED)

dimidrow = netcdf.defDim(ncid,'rows',numrow);

dimidcol = netcdf.defDim(ncid,'length',numcol);

% Define a variable on the dimension (must give it a name,data type,and a
dimension ID).

varid = netcdf.defVar(ncid,'swh','NC_DOUBLE',[dimidrow dimidcol]);

% Take the netCDF file out of define mode. To write data to a file, you must
be in data mode.

netcdf.endDef(ncid);

netcdf.putVar(ncid,varid,my_data);

netcdf.close(ncid);

 

----------------------------------------------

To open this in GRADS I need to create a descriptor file as 'sdfopen' cannot
find the xdef and ydef (as they aren't in the NetCDF) 

 

My descriptor file is:

DSET ^swh.nc

TITLE Significant Wave Height

UNDEF -9.99

XDEF dimension1 180 LINEAR -104.0 2.0

YDEF dimension2 80 LINEAR -80.0 2.0

VARS 1

swh=>swh 1 99 swh

ENDVARS

 

When I execute 'xdfopen12_swh.dat' I receive the following error:

---> The invalid description file record is:

---> xdef 180 linear -104.0 2.0

-----------------------------------------------------

 

Do I need to include x and y vectors in the NetCDF - if so how do I add them
to the NetCDF in matlab?  

Is there something simple that I have missed in the GRADS descriptor file?

 

Out of ideas here and would greatly appreciate your help.

Huw

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130726/8be31eb7/attachment-0003.html 


More information about the gradsusr mailing list