Replies: 1 comment
-
|
This should be possible, since all conversion functions are stored in ...
<Rows>
<R Ident="eumUmeter" MzId="1000" Desc="meter" Abbr="m" Expr="Length"/>
<R Ident="eumUkilometer" MzId="1001" Desc="kilometer" Abbr="km" Expr="1000*eumUmeter"/>
<R Ident="eumUmillimeter" MzId="1002" Desc="millimeter" Abbr="mm" Expr="0.001*eumUmeter"/>
<R Ident="eumUinch" MzId="1004" Desc="inch" Abbr="in" Expr="0.0254*eumUmeter"/>
<R Ident="eumUfeet" MzId="1003" Desc="feet" Abbr="ft" Expr="12*eumUinch"/>
...Unit conversions are common in engineering, are you aware of the pint library? >>> from pint import UnitRegistry
>>> u = UnitRegistry()
>>> (12.0 * (u.millimeter/u.d)).to(u.millimeter/u.h)
<Quantity(0.5, 'millimeter / hour')>
>>> (1.0 * (u.millimeter/u.d)).to(u.millimeter/u.h).magnitude
0.041666666666666664And keep in mind that some unit conversion are not simple multiplication factors, e.g. Fahrenheit to Celsius. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
My suggestion is related to
EUMTypeandEUMUnit.Describe the solution you'd like
An example explanation: When a time series object (DataArray) has an EUMType "Precipitation" and related EUMUnit "mm_per_day" and I want my time series object to be in "mm_per_hour", how do I convert the values into that unit. For that reason, it could be nice if there were some kind of conversion tool between units. That would be a conversion factor that is multiplied to the values. Of course, there would be some restrictions, like if it is not possible for some reason, the function (or whatever is going to be made) should return None or throw an error. In my example, the function should return a multiplication value of 1/24.
Describe alternatives you've considered
Self-made function with input values being "from_unit" and "to_unit". The function should return a multiplication value (scale factor).
Beta Was this translation helpful? Give feedback.
All reactions