<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hello.<o:p></o:p></p><p class=MsoNormal>I am trying to open a NetCDF file in GRADS that I have generated in matlab (filename swh.nc). <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My matlab code is:<o:p></o:p></p><p class=MsoNormal>% Create a variable in the MATLAB workspace<o:p></o:p></p><p class=MsoNormal>swh_12 = flipud(swh_12(1:80, 1:180));<o:p></o:p></p><p class=MsoNormal>numrow = 80;<o:p></o:p></p><p class=MsoNormal>numcol = 180;<o:p></o:p></p><p class=MsoNormal>my_data=swh_12;<o:p></o:p></p><p class=MsoNormal>% Create a netCDF file<o:p></o:p></p><p class=MsoNormal>ncid = netcdf.create('swh.nc','NC_WRITE');<o:p></o:p></p><p class=MsoNormal>% Define a dimension in the file (must give it a name and length or use NC_UNLIMITED)<o:p></o:p></p><p class=MsoNormal>dimidrow = netcdf.defDim(ncid,'rows',numrow);<o:p></o:p></p><p class=MsoNormal>dimidcol = netcdf.defDim(ncid,'length',numcol);<o:p></o:p></p><p class=MsoNormal>% Define a variable on the dimension (must give it a name,data type,and a dimension ID).<o:p></o:p></p><p class=MsoNormal>varid = netcdf.defVar(ncid,'swh','NC_DOUBLE',[dimidrow dimidcol]);<o:p></o:p></p><p class=MsoNormal>% Take the netCDF file out of define mode. To write data to a file, you must be in data mode.<o:p></o:p></p><p class=MsoNormal>netcdf.endDef(ncid);<o:p></o:p></p><p class=MsoNormal>netcdf.putVar(ncid,varid,my_data);<o:p></o:p></p><p class=MsoNormal>netcdf.close(ncid);<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>----------------------------------------------<o:p></o:p></p><p class=MsoNormal>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) <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My descriptor file is:<o:p></o:p></p><p class=MsoNormal>DSET ^swh.nc<o:p></o:p></p><p class=MsoNormal>TITLE Significant Wave Height<o:p></o:p></p><p class=MsoNormal>UNDEF -9.99<o:p></o:p></p><p class=MsoNormal>XDEF dimension1 180 LINEAR -104.0 2.0<o:p></o:p></p><p class=MsoNormal>YDEF dimension2 80 LINEAR -80.0 2.0<o:p></o:p></p><p class=MsoNormal>VARS 1<o:p></o:p></p><p class=MsoNormal>swh=>swh 1 99 swh<o:p></o:p></p><p class=MsoNormal>ENDVARS<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When I execute 'xdfopen12_swh.dat' I receive the following error:<o:p></o:p></p><p class=MsoNormal>---> The invalid description file record is:<o:p></o:p></p><p class=MsoNormal>---> xdef 180 linear -104.0 2.0<o:p></o:p></p><p class=MsoNormal>-----------------------------------------------------<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Do I need to include x and y vectors in the NetCDF - if so how do I add them to the NetCDF in matlab? <o:p></o:p></p><p class=MsoNormal>Is there something simple that I have missed in the GRADS descriptor file?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Out of ideas here and would greatly appreciate your help.<o:p></o:p></p><p class=MsoNormal>Huw<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>