<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt">Hi,<br><br>Thanks!! NCO is of great help in re-writting header attributes and the commands are very easy to use. Let me mention some useful links below:<br>http://jisao.washington.edu/data/nco/<br>http://marine.rutgers.edu/~jevans/using_dods/nco/ncatted.html<br><br>Regards<br>Pankaj<br><div><span><br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: lucida console, sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Monday, March 24, 2014 4:36 PM, Andrew Friedman <andfried@berkeley.edu> wrote:<br> </font> </div> <div class="y_msg_container">Hi Pankaj,<br clear="none"><br clear="none">I’ve been using NCO to address similar issues as you are
having, after writing with sdfwrite.<br clear="none"><br clear="none">You can use NCO to rename your z-dimension and flip the vertical levels.<br clear="none"><br clear="none">ncrename -v lev,z_t -d lev,z_t outfile.nc<br clear="none">ncpdq -O --rdr=-z_t outfile.nc outfile.nc<br clear="none"><br clear="none">Also, I don’t know what errors you are getting, but you could have a problem with data type of your dimensions.<br clear="none">Though you are setting floating point output for the variables, it won’t output your dimensions as floating point. You can change the format of the output variables using <br clear="none"><br clear="none">ncap2 -O -s ''z_t = z_t.float()'' outfile.nc outfile.nc<br clear="none"><br clear="none">NCO can be found here: <a shape="rect" href="http://nco.sourceforge.net/" target="_blank">http://nco.sourceforge.net/</a><br clear="none"><br clear="none">Best,<br clear="none">Andrew<br clear="none"><div class="yqt4783941820"
id="yqtfd32375"><br clear="none">On Mar 24, 2014, at 11:14 AM, pankaj kumar <<a shape="rect" ymailto="mailto:pankajqumar@yahoo.com" href="mailto:pankajqumar@yahoo.com">pankajqumar@yahoo.com</a>> wrote:<br clear="none"><br clear="none">> Dear Sir/Ma'am,<br clear="none">> <br clear="none">> I want to write the header of a netcdf file generated using sdfwrite as follows:<br clear="none">> <br clear="none">> netcdf monthly_SST {<br clear="none">> dimensions:<br clear="none">> time = 12 ;<br clear="none">> z_t = 15 ;<br clear="none">> nlon = 360 ;<br clear="none">> nlat = 180 ;<br clear="none">> variables:<br clear="none">> double time(time) ;<br clear="none">> time:long_name = "time" ;<br clear="none">> time:units = "days since 0000-01-01 00:00:00" ;<br clear="none">>
time:bounds = "time_bound" ;<br clear="none">> time:calendar = "noleap" ;<br clear="none">> float z_t(z_t) ;<br clear="none">> z_t:long_name = "depth from surface to midpoint of layer" ;<br clear="none">> z_t:units = "centimeters" ;<br clear="none">> z_t:positive = "down" ;<br clear="none">> z_t:valid_min = 500.f ;<br clear="none">> z_t:valid_max = 14500.f ;<br clear="none">> float TEMP(time, z_t, nlat, nlon) ;<br clear="none">> TEMP:_FillValue = 9.96921e+36f ;<br clear="none">> TEMP:long_name = "Potential Temperature" ;<br clear="none">> TEMP:units = "degC" ;<br clear="none">> float TLAT(nlat) ;<br
clear="none">> TLAT:long_name = "array of t-grid latitudes" ;<br clear="none">> TLAT:units = "degrees_north" ;<br clear="none">> float TLONG(nlon) ;<br clear="none">> TLONG:long_name = "array of t-grid longitudes" ;<br clear="none">> TLONG:units = "degrees_east" <br clear="none">> <br clear="none">> 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 clear="none">> set sdfattr<br clear="none">> but I have not got any success in changing anything. My grads script is as given below:<br clear="none">> <br clear="none">> 'set yflip on'<br clear="none">> 'set sdfwrite -flt montly_temp.nc'<br clear="none">> <br
clear="none">> 'set sdfattr time String long_name time'<br clear="none">> 'set sdfattr time String units days since 0000-01-01 00:00:00'<br clear="none">> 'set sdfattr time String bounds time_bound'<br clear="none">> 'set sdfattr time String calendar noleap'<br clear="none">> <br clear="none">> 'set sdfattr z_t String long_name depth from surface to midpoint of layer'<br clear="none">> 'set sdfattr z_t String units centimeters'<br clear="none">> 'set sdfattr z_t Sting positive down'<br clear="none">> 'set sdfattr z_t float valid_min 500.f'<br clear="none">> 'set sdfattr z_t float valid_max 14500.f'<br clear="none">> <br clear="none">> 'set
sdfattr TEMP String long_name Potential Temperature'<br clear="none">> 'set sdfattr TEMP String units degC'<br clear="none">> 'set undef 'undef_value<br clear="none">> <br clear="none">> 'set sdfattr TLAT String long_name array of t-grid latitudes'<br clear="none">> 'set sdfattr TLAT String units degrees_north'<br clear="none">> <br clear="none">> 'set sdfattr TLONG String long_name array of t-grid longitudes'<br clear="none">> 'set sdfattr TLONG String units degrees_east'<br clear="none">> <br clear="none">> 'q sdfwrite'<br clear="none">> 'sdfwrite TEMP'<br clear="none">> 'c sdfwrite'<br clear="none">> <br clear="none">> 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.<br clear="none">> <br clear="none">> Thank you.<br clear="none">> With Regards<br clear="none">> Pankaj Sinha <br clear="none">> Hokkaido University</div><br clear="none">> _______________________________________________<br clear="none">> gradsusr mailing list<br clear="none">> <a shape="rect" ymailto="mailto:gradsusr@gradsusr.org" href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br clear="none">> <a shape="rect" href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><div class="yqt4783941820" id="yqtfd69765"><br clear="none"></div><br><br></div> </div> </div> </div> </div></body></html>