[ncl-talk] How to convert udunits compliant units?

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Fri Oct 28 12:52:23 MDT 2016


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.

    http://www.unidata.ucar.edu/software/udunits/

I would like to have two different NCL access functions for UDUNITS, along
these lines:

(1)  result_array:snumeric = udunits_convert (input_array:snumeric,
new_units[1]:string)

where input_array at units specifies the input units, and new_units specifies
the output units;

(2) conversion_params = udunits_params (old_units[1]:string, new_
units[1]:string)

where the two conversion coefficients from UDUNITS are returned as
conversion_params at multiplier and conversion_params at offset, and
conversions_params is a scalar dummy variable, like a resource variable, to
hold the two named parameters.

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.

--Dave


On Fri, Oct 28, 2016 at 8:28 AM, Dennis Shea <shea at ucar.edu> wrote:

> A supported unit conversion library? I am not aware of any NCL library.
>
> Certainly, it would be useful ...
>
> BUT ...
>
> it can become a bit overwhelming.
>
> 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.
>
> --
> 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.
>
> I'm also attaching a script of 'global' constants that may be useful if
> you want to develop your own library.
>
> Cheers
> D
>
> On Fri, Oct 28, 2016 at 12:31 AM, Heiko Klein <Heiko.Klein at met.no> wrote:
>
>> Hi,
>>
>> I have a couple of CF-compliant netcdf files and will apply some
>> ncl-functions on them. The variables come in all types of units, so I
>> would like to automatically convert the unit to the ones I want to have,
>> e.g. degC to Kelvin and hPa to Pa.
>>
>> This functionality is part of udunits and I see some time-related
>> udunits functions in the documentation. Are there some functions to
>> convert other units, too?
>>
>> Best regards,
>>
>> Heiko
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161028/36c66017/attachment.html 


More information about the ncl-talk mailing list