<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>As a general rule, GrADS does not support a lot of features in the sdfwrite interface because there is no good reason to duplicate code that works very nicely in the NetCDF Operators. So, you can create some basic netcdf files with sdfwrite, and then you can tweak them further with NCO if necessary. </div><div><br></div>Please see additional comments inline...<br><div><br><div><div>On Mar 23, 2014, at 11:14 PM, pankaj kumar wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_2889">Dear Sir/Ma'am,</div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_13"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_18"></div><div style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;" id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_15">I want to write the header of a netcdf file generated using sdfwrite as follows:</div><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_2904" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_25"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_22" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_220" style="font-family:lucida console, sans-serif;"><span id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_219">netcdf monthly_SST {<br>dimensions:<br> time = 12 ;<br> z_t = 15 ;<br> nlon = 360 ;<br> nlat = 180 ;<br>variables:<br> double time(time) ;<br> time:long_name = "time" ;<br> time:units = "days since 0000-01-01 00:00:00" ;<br> time:bounds = "time_bound" ;<br> time:calendar = "noleap" ;<br> float z_t(z_t) ;<br>
z_t:long_name = "depth from surface to midpoint of layer" ;<br> z_t:units = "centimeters" ;<br> z_t:positive = "down" ;<br>
z_t:valid_min = 500.f ;<br> z_t:valid_max = 14500.f ;<br> float TEMP(time, z_t, nlat, nlon) ;<br> TEMP:_FillValue = 9.96921e+36f ;<br> TEMP:long_name = "Potential Temperature" ;<br> TEMP:units = "degC" ;<br> float TLAT(nlat) ;<br> TLAT:long_name = "array of t-grid latitudes" ;<br> TLAT:units = "degrees_north" ;<br> float TLONG(nlon) ;<br> TLONG:long_name = "array of t-grid longitudes" ;<br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_50"> TLONG:units = "degrees_east" </span></span></div><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_4415" style="color:rgb(0, 0,
0);font-size:18.6667px;
font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><br></div><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_4416" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">however, the auto-written header of the file generated by grads command is very different which has many missing information also. I tried to change the header using <br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_62"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_59" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><code id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_69">set sdfattr</code></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_63" style="color:rgb(0, 0,
0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">but I have not got any success in changing anything. My grads script is as given below:</div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_72" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_76"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_73" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"> <span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20392" style="font-family:lucida console, sans-serif;">'set yflip on'<br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_130"></span></div></div></div></div></div></div></blockquote><div>This command is for graphics, not for data output. It will not reverse the underlying order of the Y axis. You can try bringing your original data in upside down, but your success will depend a bit on the original format.</div><div><br></div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_73" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20392" style="font-family:lucida console, sans-serif;"> 'set sdfwrite -flt
montly_temp.nc'</span></div></div></div></div></div></div></blockquote>The -flt option affects data variables, but not coordinates, which are always written out as doubles. </div><div> <br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_127" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;
font-style:normal;"><span style="font-family:lucida console, sans-serif;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_141"></span></div><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_13794" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20389" style="font-family:lucida console, sans-serif;"> 'set sdfattr time String long_name time'</span></div></div></div></div></div></div></blockquote>This attribute is set by default.</div><div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_131" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20390" style="font-family:lucida console, sans-serif;"> 'set sdfattr time String units days since 0000-01-01 00:00:00'<br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_152"></span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_149" style="color:rgb(0, 0, 0);font-size:18.6667px;
background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20391" style="font-family:lucida console, sans-serif;"> 'set sdfattr time String bounds time_bound'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_154" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"> 'set sdfattr time String calendar noleap'<br></span></div></div></div></div></div></div></blockquote><div><br></div>You cannot override the units or the calendar attributes of the time axis. This guarantees that they will be correct. The 'bounds' attribute will be written out, but what does it mean? </div><div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_144" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_102"></span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_99" style="color:rgb(0, 0,
0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"> 'set sdfattr z_t String long_name depth from surface to midpoint of layer'<br> 'set sdfattr z_t String units centimeters'<br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_108"> 'set sdfattr z_t Sting positive down'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_105" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"> 'set sdfattr z_t float valid_min 500.f'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_124" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console,
sans-serif;"> 'set sdfattr z_t float valid_max 14500.f'</span></div></div></div></div></div></div></blockquote><div><br></div>The Z axis is not named z_t, it is 'lev'. Setting the attribute 'positive' to 'down' will not alter the order of the Z axis values. Andrew's comment shows you how to rename and flip the Z axis with NCO. </div><div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_109" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20387" style="font-family:lucida console, sans-serif;"> <br> 'set sdfattr TEMP String long_name Potential Temperature'<br> 'set sdfattr TEMP String units degC'<br></span></div></div></div></div></div></div></blockquote><div><br></div><div>Variables in GrADS are lower case. This won't get written because the varname won't match the defined variable. </div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_109" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20387" style="font-family:lucida console, sans-serif;"> 'set undef 'undef_value<br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_174"></span></div></div></div></div></div></div></blockquote><div><br></div>GrADS will automaticlly set the _FillValue attribute with the default undef value. Use 'set undef' if you want it to be something other than -9.99e8.</div><div><br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_109" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20387" style="font-family:lucida console, sans-serif;"> </span></div><div id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_15995" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20426" style="font-family:lucida console, sans-serif;">
'set sdfattr TLAT String long_name array of t-grid latitudes'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_182" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20427" style="font-family:lucida console, sans-serif;"> 'set sdfattr TLAT String units degrees_north'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_187" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_192"></span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_189" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"> 'set sdfattr TLONG
String long_name array of t-grid longitudes'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_182" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;
font-style:normal;"><span style="font-family:lucida console, sans-serif;"><span id="yiv3571762485yui_3_13_0_ym1_1_1395627025493_20358"> 'set sdfattr TLONG String units degrees_east'</span></span></div></div></div></div></div></div></blockquote><div><br></div>These will be ignored because they are upper case and also because the longitude and latitudes grids are named 'lon' and 'lat'. The default values for the units are 'degrees_east' and 'degrees_north' and for the long_name are "Longitdue" and "Latitude". <br><blockquote type="cite"><div><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div id="yiv3571762485"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_189" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span style="font-family:lucida console, sans-serif;"> </span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_167" style="color:rgb(0, 0, 0);font-size:18.6667px;background-color:transparent;font-style:normal;"><span id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_224" style="font-family:lucida console, sans-serif;"> 'q sdfwrite'<br> 'sdfwrite TEMP'<br> 'c sdfwrite'</span></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_89" style="color:rgb(0, 0, 0);
font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_93"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_90" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">Since I am writing ocean data, I want to set top layer (500 cm) as first level but the bottom layer (14500 cm) is by default set as first level. I tried to invert levels using 'set yflip on' before sdfwrite command but it is not working. Please see how this can be achieved.</div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_198" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;"><br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_203"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_200" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">Thank you.</div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_205" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">With Regards</div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_208" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">Pankaj Sinha <br id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_214"></div><div id="yiv3571762485yui_3_13_0_ym1_7_1395627025493_211" style="color:rgb(0, 0, 0);font-size:18.6667px;font-family:garamond, new york, times, serif;background-color:transparent;font-style:normal;">Hokkaido University</div></div></div></div></div></div>_______________________________________________<br>gradsusr mailing list<br><a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>http://gradsusr.org/mailman/listinfo/gradsusr<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Jennifer M. Adams<br>Center for Ocean-Land-Atmosphere Studies (COLA)<br>111 Research Hall, Mail Stop 2B3<br>George Mason University<br>4400 University Drive<br>Fairfax, VA 22030 <br><br></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>