This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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