<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Dennis,
<div class=""><br class="">
</div>
<div class="">Thanks so much for your replies. I’ve read through these scripts and some docs, here’s what I’ve tried:</div>
<div class=""><br class="">
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">
<div class="">
<div class="">;=============================================================</div>
</div>
<div class="">
<div class="">; <a href="https://www.ncl.ucar.edu/Applications/method_1.shtml" class="">
https://www.ncl.ucar.edu/Applications/method_1.shtml</a></div>
</div>
<div class="">
<div class="">;=============================================================</div>
</div>
<div class="">
<div class=""> typeof(plev) => double</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class=""> plev_bnds = (/ (/ 100000, 98750/) \</div>
</div>
<div class="">
<div class=""> , (/ 98750, 96250/) \</div>
</div>
<div class="">
<div class=""> , (/ 91250, 88750/) \</div>
</div>
<div class="">
<div class=""> , (/ 1000, 500/) /) *1d0 ; last line</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class=""> ; name dimensions using NCL syntax</div>
</div>
<div class="">
<div class=""> plev_bnds!0 = "bnds0" ; ... whatever is appropriate</div>
</div>
<div class="">
<div class=""> plev_bnds!1 = "bnds1"</div>
</div>
<div class="">
<div class=""> if (isatt(plev_bnds,"units")) then</div>
</div>
<div class="">
<div class=""> plev_bnds@units = plev@units </div>
</div>
<div class="">
<div class=""> end if</div>
</div>
<div class="">
<div class=""> printVarSummary(plev_bnds) </div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class=""> dirNc = "./"</div>
</div>
<div class="">
<div class=""> filNc = "plev_bnds.nc"</div>
</div>
<div class="">
<div class=""> pthNc = dirNc+filNc</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class=""> system("/bin/rm -f "+pthNc) ; remove any pre-existing file</div>
</div>
<div class="">
<div class=""> ncdf = addfile(pthNc ,"c") ; open output netCDF file</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class="">;===================================================================</div>
</div>
<div class="">
<div class="">; create global attributes of the file (optional)</div>
</div>
<div class="">
<div class="">;===================================================================</div>
</div>
<div class="">
<div class=""> fAtt = True ; assign file attributes</div>
</div>
<div class="">
<div class=""> fAtt@title = "plev bound file"</div>
</div>
<div class="">
<div class=""> fAtt@Conventions = "None"</div>
</div>
<div class="">
<div class=""> fAtt@creation_date = systemfunc ("date")</div>
</div>
<div class="">
<div class=""> fileattdef( ncdf, fAtt ) ; copy file attributes</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class="">;===================================================================</div>
</div>
<div class="">
<div class="">; Write to file</div>
</div>
<div class="">
<div class="">;===================================================================</div>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">
<div class=""> ncdf->plev_bnds = plev_bnds</div>
</div>
</blockquote>
<div class="">
<div class=""><br class="">
</div>
<div class="">But I’m getting an error on the size of the right hand dimension I can’t fix. Thanks in advance if you can help:</div>
<div class=""><font face="Georgia" size="2" class=""><br class="">
</font></div>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> Copyright (C) 1995-2015 - All Rights Reserved</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> University Corporation for Atmospheric Research</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> NCAR Command Language Version 6.3.0</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> The use of this software is governed by a License Agreement.</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> See
<a href="http://www.ncl.ucar.edu/" class="">http://www.ncl.ucar.edu/</a> for more details.</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:syntax error: typeof is a function not a procedure; return value must be referenced</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:error at line 4 in file mk_plev_bnd.ncl</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251); min-height: 21px;" class="">
<font face="Georgia" size="2" class=""><br class="">
</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:syntax error: line 4 in file mk_plev_bnd.ncl before or near = </font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> typeof(plev) =</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">----------------^</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251); min-height: 21px;" class="">
<font face="Georgia" size="2" class=""><br class="">
</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:error in statement</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251); min-height: 21px;" class="">
<font face="Georgia" size="2" class=""><br class="">
</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Variable: plev_bnds</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Type: double</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Total Size: 64 bytes</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class=""> 8 values</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Number of Dimensions: 2</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space:pre">
</span>[bnds0 | 4] x [bnds1 | 2]</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">Coordinates: </font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:Variable (bnds1) is undefined</font></div>
</div>
</div>
<div class="">
<div class="">
<div style="margin: 0px; background-color: rgb(250, 255, 251);" class=""><font face="Georgia" size="2" class="">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 39 in file mk_plev_bnd.ncl</font></div>
</div>
</div>
</blockquote>
<div class="">
<div class=""><br class="">
</div>
<div class="">judy</div>
<div class=""><br class="">
</div>
<div>
<blockquote type="cite" class="">
<div class="">On Oct 21, 2015, at 3:55 PM, Dennis Shea <<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">Also .... another recommendation ...<br class="">
<br class="">
It is not required but I recommend the type of the 'plev_bnds' should<br class="">
be the same type as 'plev'<br class="">
<br class="">
=====================<br class="">
typeof(plev) => Integer<br class="">
<br class="">
plev_bnds = (/ (/ 100000, 98750/) \<br class="">
, (/ 98750, 96250/) \<br class="">
, (/ 91250, 88750/) \<br class="">
, (/ 1000, 500/) /) ; last line<br class="">
=================<br class="">
typeof(plev) => float<br class="">
<br class="">
plev_bnds = (/ (/ 100000.0, 98750.0/) \<br class="">
, (/ 98750.0, 96250.0/) \<br class="">
, (/ 91250.0, 88750.0/) \<br class="">
, (/ 1000.0, 500.0/) /) ; last line<br class="">
<br class="">
or, easier<br class="">
<br class="">
typeof(plev) => float<br class="">
<br class="">
plev_bnds = (/ (/ 100000, 98750/) \<br class="">
, (/ 98750, 96250/) \<br class="">
, (/ 91250, 88750/) \<br class="">
, (/ 1000, 500/) /) *1.0 ; last line<br class="">
<br class="">
=================<br class="">
<br class="">
typeof(plev) => double<br class="">
<br class="">
plev_bnds = (/ (/ 100000d0, 98750d0/) \<br class="">
, (/ 98750d0, 96250d0/) \<br class="">
, (/ 91250d0, 88750d0/) \<br class="">
, (/ 1000d0, 500d0/) /) ; last line<br class="">
<br class="">
or, easier<br class="">
<br class="">
typeof(plev) => double<br class="">
<br class="">
plev_bnds = (/ (/ 100000, 98750/) \<br class="">
, (/ 98750, 96250/) \<br class="">
, (/ 91250, 88750/) \<br class="">
, (/ 1000, 500/) /) *1d0 ; last line<br class="">
<br class="">
<br class="">
On Tue, Oct 20, 2015 at 4:30 PM, Dennis Shea <<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>> wrote:<br class="">
<blockquote type="cite" class="">NCL .... A general place to go to get file IO information.<br class="">
<br class="">
Click 'Examples' .... then 'File I/O' .... Click 'Change netCDF file'<br class="">
<br class="">
For 'fun' look at other examples also.<br class="">
<br class="">
===<br class="">
<br class="">
<br class="">
===<br class="">
<br class="">
Two approaches:<br class="">
<br class="">
[1]<br class="">
If you are familiar withe the netCDF Operators (not associated with<br class="">
NCL). Use netCDF Operator: ncks [Use WWW to search for<br class="">
documentation]<br class="">
<br class="">
(a) Create a netCDF with the plev_bnds variable: plev_bnd.nc<br class="">
See attached script. Of, course the 'plev' should be changed<br class="">
to the appropriate variable name.<br class="">
<br class="">
(b) If 'foo.nc' is your base file:<br class="">
ncks -O plev.nc foo.nc<br class="">
will append the bounds variable to the file.<br class="">
<br class="">
<br class="">
[2] NCL direct<br class="">
<br class="">
plev_bnds = (/ (/100000, 98750/) \<br class="">
, (/ 98750, 96250/) \<br class="">
, (/ 91250, 88750/) \<br class="">
<br class="">
, (/ ... , ... /) /) ; last line<br class="">
<br class="">
; name dimensions using NCL syntax<br class="">
plev_bnds!0 = "plev" ; ... whatever is appropriate<br class="">
plev_bnds!1 = "pbnd"<br class="">
plev_bnds@units = plev@units<br class="">
printVarSummary(plev_bnds)<br class="">
<br class="">
<br class="">
f = addfile("foo.nc", "w") ; NOTE the 'w'<br class="">
f->plev_bnds = plev_bnds<br class="">
<br class="">
===<br class="">
Either way, I would create test files in case there is a problem.<br class="">
<br class="">
On Tue, Oct 20, 2015 at 12:44 PM, Hertz, Judith A.<br class="">
(GSFC-606.0)[INTERNATIONAL TECHNOLOGY COALITION, INC]<br class="">
<<a href="mailto:judith.a.hertz@nasa.gov" class="">judith.a.hertz@nasa.gov</a>> wrote:<br class="">
<blockquote type="cite" class="">Greetings, NCL’ers<br class="">
<br class="">
I’m new to NCL. I want to add a variable, plev_bnds, to NetCDF files so that:<br class="">
<br class="">
double plev_bnds(plev, bnds) ;<br class="">
<br class="">
data:<br class="">
<br class="">
plev_bnds =<br class="">
100000, 98750,<br class="">
98750, 96250,<br class="">
96250, 93750,<br class="">
93750, 91250,<br class="">
91250, 88750,…..<br class="">
<br class="">
I’ve found addfile, which looks to be a good way to populate the data but the docs say the variable must already exist. Do you know what is the NCL way to create/define a new variable?<br class="">
<br class="">
thanks,<br class="">
<br class="">
judy<br class="">
_______________________________________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class="">
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>