[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[UDUNITS #ZNC-874842]: Outputting UDUnits Slope and Intercept from the API
- Subject: [UDUNITS #ZNC-874842]: Outputting UDUnits Slope and Intercept from the API
- Date: Thu, 30 Jul 2009 11:05:31 -0600
Peter,
> Full Name: Peter Bosler
> Email Address: address@hidden
> Organization: NCAR-SIParCS
> Package Version: UDUnits-2.1.8
> Operating System: Various
> Hardware: Various
> Description of problem: Is there a function in UDUnits2 API similar to
> ut_get_converter that returns simply the appropriate numerical values for the
> Slope and Intercept (rather than the whole converter structure)?
>
> This would be very similar to the output from the UDUnit2 utility when the
> input is 1 source unit...
With the advent of logarithmic units in the UDUNITS-2 package, it is *very*
dangerous to assume a Gallilean (i.e., slope/intercept) transformation between
units, so no, there isn't a function to return such values.
If you know, a priori, that two units have a Gallilean transformation between
them, then you can use the returned converter to obtain slope and intercept
values by first converting the value zero (to obtain the intercept) and then
converting the value one (to obtain the sum of the slope plus the intercept).
Subtracting the intercept from this latter value will give you the slope.
I strongly advise you not to do this as it probably indicates you're making
unwarranted assumptions about the units in question, which can lead to brittle
code.
Regards,
Steve Emmerson
Ticket Details
===================
Ticket ID: ZNC-874842
Department: Support UDUNITS
Priority: Normal
Status: Closed