<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)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 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";
        color:black;
        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;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Consolas","serif";
        color:black;
        mso-fareast-language:EN-US;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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 bgcolor=white lang=EN-GB link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Jim, I&#8217;ve just tried this and it worked. You&#8217;ve made a grown man cry! Thank you. Huw<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-GB'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-GB'> gradsusr-bounces@gradsusr.org [mailto:gradsusr-bounces@gradsusr.org] <b>On Behalf Of </b>James T. Potemra<br><b>Sent:</b> 26 July 2013 14:04<br><b>To:</b> GrADS Users Forum<br><b>Subject:</b> Re: [gradsusr] GRADS USER FORUM QUESTION<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Huw:<br><br>The lines in your descriptor file for XDEF and YDEF should reflect the dimensions<br>in your netcdf file.&nbsp; A sample output from ncdump might help, but I presume you<br>don't have dimensions &quot;dimension1&quot; and &quot;dimension2&quot;, but rather &quot;rows&quot; and &quot;length&quot;<br>so these two lines:<br><br>XDEF dimension1 180 LINEAR -104.0 2.0<br>YDEF dimension2 80 LINEAR -80.0 2.0<br><br>need to be changed to reflect what your two dimensions are, e.g., <br><br>XDEF length 180 LINEAR -104.0 2.0<br>YDEF rows 80 LINEAR -80.0 2.0<br><br><br>Jim<br><br><o:p></o:p></p><div><p class=MsoNormal>On 7/26/13 1:08 PM, Huw Davies wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><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>&nbsp;<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>&nbsp;<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>&nbsp;<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>&nbsp;<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=&gt;swh 1 99 swh<o:p></o:p></p><p class=MsoNormal>ENDVARS<o:p></o:p></p><p class=MsoNormal>&nbsp;<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>---&gt; The invalid description file record is:<o:p></o:p></p><p class=MsoNormal>---&gt; xdef 180 linear -104.0 2.0<o:p></o:p></p><p class=MsoNormal>-----------------------------------------------------<o:p></o:p></p><p class=MsoNormal>&nbsp;<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?&nbsp; <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>&nbsp;<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>&nbsp;<o:p></o:p></p><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'><br><br><br><o:p></o:p></span></p><pre>_______________________________________________<o:p></o:p></pre><pre>gradsusr mailing list<o:p></o:p></pre><pre><a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><o:p></o:p></pre><pre><a href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a><o:p></o:p></pre></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'><o:p>&nbsp;</o:p></span></p><div class=MsoNormal align=center style='text-align:center'><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'><hr size=1 width="100%" noshade style='color:#A0A0A0' align=center></span></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:EN-GB'>No virus found in this message.<br>Checked by AVG - <a href="http://www.avg.com">www.avg.com</a><br>Version: 2013.0.3349 / Virus Database: 3209/6521 - Release Date: 07/25/13<o:p></o:p></span></p></div></body></html>