<div dir="ltr">The best solution would be a direct port of the UDUNITS-2 units conversion library, via NCL built-in functions. UDUNITS-2 is efficient, well tested, documented, open source, and in current maintenance by UCAR. It is also the official reference for physical units in the CF Conventions. I requested this a long time ago, as you may recall. Please consider this possibility.<div><br></div><div> <a href="http://www.unidata.ucar.edu/software/udunits/" target="_blank">http://www.unidata.ucar.edu/<wbr>software/udunits/</a><br></div><div><br></div><div>I would like to have two different NCL access functions for UDUNITS, along these lines:</div><div><br></div><div>(1) result_array:snumeric = udunits_convert (input_array:snumeric, new_units[1]:string)</div><div><br></div><div>where input_array@units specifies the input units, and new_units specifies the output units;</div><div><br></div><div>(2) conversion_params = udunits_params (old_units[1]:string, new_<wbr>units[1]:string)</div><div><br></div><div>where the two conversion coefficients from UDUNITS are returned as conversion_params@multiplier and conversion_params@offset, and conversions_params is a scalar dummy variable, like a resource variable, to hold the two named parameters.</div><div><br></div><div>Such converters should be reserved for simple numeric conversions only. Please do not try to include special UDUNITS calendar functionality in any such basic converters. Calendar functionality is already handled reasonably in the cd_calendar and ut_calendar function families.</div><div><br></div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 28, 2016 at 8:28 AM, Dennis Shea <span dir="ltr"><<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>A supported unit conversion library? I am not aware of any NCL library. <br><br></div><div>Certainly, it would be useful ...<br><br></div><div>BUT ...<br></div><div><br></div>it can become a bit overwhelming. <br><br>Writing the functions or procedures is the easy part. However, to raise to the level of a supported library, functions must be tested and documentation must be created. These latter tasks are necessary but they can become rather tedious.<br><br>--<br></div>I am attaching the very nascent start of a library which I did *years* (?10+?) ago. Better naming would help but nothing has been added .. it has not been tested. <br><br></div>I'm also attaching a script of 'global' constants that may be useful if you want to develop your own library.<br><br></div>Cheers<br></div>D<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 28, 2016 at 12:31 AM, Heiko Klein <span dir="ltr"><<a href="mailto:Heiko.Klein@met.no" target="_blank">Heiko.Klein@met.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
I have a couple of CF-compliant netcdf files and will apply some<br>
ncl-functions on them. The variables come in all types of units, so I<br>
would like to automatically convert the unit to the ones I want to have,<br>
e.g. degC to Kelvin and hPa to Pa.<br>
<br>
This functionality is part of udunits and I see some time-related<br>
udunits functions in the documentation. Are there some functions to<br>
convert other units, too?<br>
<br>
Best regards,<br>
<br>
Heiko<span class="m_6404958237561563207gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote></div></div></blockquote></div></div></div></div>