Hi Deniz,<div><br></div><div>ok. When you tried to open the file with sdfopen and it failed, this means that the file is not consistent with the coards-standard. So we need a ctl-file and xdfopen.</div><div><br></div><div>
You need the name of all coordinates of the file. ncdump -h would give that. When you wrote "dimension1", this is just an example for the first dimension. Probably, this should be the name of your longitude-variable in matlab, eg. "long" or "x" or so. </div>
<div><br></div><div>"fwrite" in matlab follows the logic of the programming language c. You have to open the file first with fopen. It is explained in the matlab-manual. Here is an example from me:</div><div>% open the file 'ures.bin' in binary write-mode. </div>
<div><div>fid=fopen('ures.bin','wb');</div><div>% write binary data from the field winds to file in real*4 %precision</div><div> fwrite(fid,winds,'real*4');</div></div><div><br></div><div>Regards,</div>
<div>Heiner</div><div><br><div class="gmail_quote">On Tue, Nov 9, 2010 at 1:37 PM, Deniz Demirhan Bari <span dir="ltr"><<a href="mailto:bari@iap-kborn.de">bari@iap-kborn.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div lang="DE" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">Dear Heiner, </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">Grads 2.0 in our server is now changed and it is compiled with
netCDF support.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">When I tried:</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">>sdfopen <a href="http://ures.nc" target="_blank">ures.nc</a> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">it says: </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> >Scanning self-describing file: <a href="http://ures.nc" target="_blank">ures.nc</a></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">gadsdf: SDF file has no discernable X coordinate.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">When I try: </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">>xdfopen ures.ctl</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">>Scanning Descriptor File: ures.ctl</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">gadsdf: Lon dimension dimension1 is not an SDF dimension.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">SDF Descriptor file ures.ctl was not successfully opened &
parsed. </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">---Matlab fwrite, I tried it but couldn’t manage. </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">Thank you</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">Deniz</span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt">Von:</span></b><span style="font-size:10.0pt">
<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a> [mailto:<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>] <b>Im
Auftrag von </b>Heiner Körnich<br>
<b>Gesendet:</b> Montag, 8. November 2010 17:07</span></p><div><div></div><div class="h5"><br>
<b>An:</b> GrADS Users Forum<br>
<b>Betreff:</b> Re: [gradsusr] netCDF control file</div></div><p></p>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Deniz,<br>
<br>
when you write recognized "sdfopen" or "xdfopen", do you
mean that grads does not know the command? Is your grads-version compiled with
netcdf-support?<br>
<br>
It is certainly a good thing to create netcdf-files, as they are
self-descriptive. But still you could write binary data from matlab with the
command fwrite:<br>
<a href="http://www.mathworks.com/help/techdoc/ref/fwrite.html" target="_blank">http://www.mathworks.com/help/techdoc/ref/fwrite.html</a><br>
<br>
Then you have to follow the logic of grads binary files, ie. first longitude,
then latitude, then height, then time, as described in the manual.<br>
<br>
So far,<br>
Heiner</p>
<div>
<p class="MsoNormal">On Mon, Nov 8, 2010 at 4:25 PM, Deniz Demirhan Bari <<a href="mailto:bari@iap-kborn.de" target="_blank">bari@iap-kborn.de</a>> wrote:</p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">Hello Heiner, </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">Thank you for your mail. </span><span lang="EN-US" style="font-size:10.0pt;color:black">I tried 'sdfopen </span><span style="font-size:10.0pt;color:black"><a href="http://ures.nc" target="_blank"><span lang="EN-US" style="color:black">ures.nc</span></a></span><span lang="EN-US" style="font-size:10.0pt;color:black">' but neither grads 2.0 nor grads
1.8 recognized sdfopen. Then I prepared a control file as below, by
looking at the “CDO sinfo <a href="http://ures.nc" target="_blank">ures.nc</a>”.
Then tried “xdfopen ures.ctl” but none of the grads
versions recognized xdfopen again. </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black">*</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black">DSET ^<a href="http://ures.nc" target="_blank">ures.nc</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">DTYPE netcdf</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">UNDEF -9e+33</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">XDEF dimension1 96 LINEAR 0.000000
3.750000</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">YDEF dimension2 48 LEVELS -87.159
-83.479 -79.777 -76.070 -72.362 -68.652 </span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
-64.942 -61.232 -57.521 -53.810 -50.099 -46.389 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
-42.678 -38.967 -35.256 -31.545 -27.833 -24.122 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
-20.411 -16.700 -12.989 -9.278 -5.567 -1.856 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
1.856 5.567 9.278 12.989 16.700
20.411 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
24.122 27.833 31.545 35.256 38.967 42.678 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
46.389 50.099 53.810 57.521 61.232 64.942 </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">
68.652 72.362 76.070 79.777 83.479 87.159 </span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">ZDEF dimension3 114 LINEAR 1 1</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">TDEF dimension4 1 LINEAR
00:00Z00jan0000 1mn</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">TITLE ures.grb T31 grid</span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:black">VARS 1</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black">ures
114 1,100 ures</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black">ENDVARS</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black">*</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;color:black"> </span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:black">My data is three dimensionaI
and if I try to save my data in an ASCII file in MATLAB it gives a two
dimensional output. I also couldn’t solve this problem</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:black">Thank you</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:black">Deniz </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>
<div style="border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;border-color:-moz-use-text-color -moz-use-text-color">
<p class="MsoNormal"><b><span style="font-size:10.0pt">Von:</span></b><span style="font-size:10.0pt"> <a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>
[mailto:<a href="mailto:gradsusr-bounces@gradsusr.org" target="_blank">gradsusr-bounces@gradsusr.org</a>]
<b>Im Auftrag von </b>Heiner Körnich<br>
<b>Gesendet:</b> Montag, 8. November 2010 14:06<br>
<b>An:</b> GrADS Users Forum<br>
<b>Betreff:</b> Re: [gradsusr] netCDF control file</span></p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi
Deniz,<br>
<br>
you don't nead a ctl-file to open a netcdf-file in grads. If your file follows
the COARDS-standard, then you can open it with 'sdfopen <a href="http://ures.nc" target="_blank">ures.nc</a>'. If grads won't recognise it, you might want to
try an older grads-version. We had some problems here with grads 2.0 and
netcdf.<br>
<br>
If grads still won't open your file, you can write a ctl-file and try to open
that with the command 'xdfopen'. The ctl-file looks a bit different from
standard ctl-files, look here:<br>
<a href="http://www.iges.org/grads/gadoc/gradcomdxdfopen.html" target="_blank">http://www.iges.org/grads/gadoc/gradcomdxdfopen.html</a><br>
<br>
Then, you would need the output from ncdump in order to know what is inside the
netcdf-file. Alternatively you can use the climate data operators (CDO) with
the command "cdo sinfo <a href="http://ures.nc" target="_blank">ures.nc</a>".<br>
Or in matlab, if you have the mexnc-package installed, you read the information
with <br>
info=nc_info('<a href="http://ures.nc" target="_blank">ures.nc</a>')<br>
Then you can access all details in info.<br>
<br>
Finally, if it is only you who will use the data, it might be simpler to write
binary output in matlab and use a standard ctl.<br>
<br>
Kind regards from Stockholm,<br>
Heiner</p>
<div>
<p class="MsoNormal">On
Mon, Nov 8, 2010 at 10:11 AM, Deniz Demirhan Bari <<a href="mailto:bari@iap-kborn.de" target="_blank">bari@iap-kborn.de</a>>
wrote:</p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt">Dear Grads users, </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt">I have calculated residual wind components
in MATLAB and saved them in netCDF file. Now I want to read them in grads but I
cannot create a netcdf control file.</span></p>
<pre><span lang="EN-US">I tried to get the output of ncdump but my computer doesn’t recognize ncdump although I installed it. </span></pre><pre><span lang="EN-US">I am using the latest version of Grads on a Suse Linux computer. </span></pre>
<pre><span lang="EN-US">My attempt to create a ctl file is below: </span></pre>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">*</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">DSET ^<a href="http://ures.nc" target="_blank">ures.nc</a></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">DTYPE netCDF</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">XDEF 96 LINEAR 0.000000 3.750000</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">YDEF 48 LEVELS -87.159 -83.479 -79.777
-76.070 -72.362 -68.652</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
-64.942 -61.232 -57.521 -53.810 -50.099 -46.389</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
-42.678 -38.967 -35.256 -31.545 -27.833 -24.122</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
-20.411 -16.700 -12.989 -9.278 -5.567 -1.856</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
1.856 5.567 9.278 12.989 16.700
20.411</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
24.122 27.833 31.545 35.256 38.967 42.678</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
46.389 50.099 53.810 57.521 61.232 64.942</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">
68.652 72.362 76.070 79.777 83.479 87.159</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">ZDEF 114 LINEAR 1 1</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">TDEF 1 LINEAR 00:00Z00jan0000 1mn</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">OPTIONS yrev</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">UNDEF -9e+33</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">VARS 1</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">ures
114 1,100 ures</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">ENDVARS</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">* </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Thanks in advance</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Deniz DEMIRHAN BARI</span></p>
<p><span style="font-size:10.0pt">Leibniz-Institut für Atmosphärenphysik e.V.<br>
an der Universität Rostock<br>
Schlossstraße 6<br>
18225 Kühlungsborn</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<br>
-- <br>
Heiner Körnich <br>
Dept. of Meteorology Tel: +46 8
164333<br>
Stockholms University, SE-106 91 Stockholm, Sweden<br>
Email: <a href="mailto:heiner@misu.su.se" target="_blank">heiner@misu.su.se</a>
<a href="http://www.misu.su.se/%7Eheiner/" target="_blank">www.misu.su.se/~heiner/</a></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<br>
-- <br>
Heiner Körnich <br>
Dept. of Meteorology Tel: +46 8
164333<br>
Stockholms University, SE-106 91 Stockholm, Sweden<br>
Email: <a href="mailto:heiner@misu.su.se" target="_blank">heiner@misu.su.se</a> <a href="http://www.misu.su.se/~heiner/" target="_blank">www.misu.su.se/~heiner/</a></p>
</div></div></div>
</div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Heiner Körnich <br>Dept. of Meteorology Tel: +46 8 164333<br>Stockholms University, SE-106 91 Stockholm, Sweden<br>Email: <a href="mailto:heiner@misu.su.se">heiner@misu.su.se</a> <a href="http://www.misu.su.se/~heiner/">www.misu.su.se/~heiner/</a><br>
</div>