apply_unit_conversion
Stable function · Units
Tier: stable · Kind: function · Topic: Units
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
apply_unit_conversion, apply_unit_conversion! | not exported | apply_unit_conversion | not exported | not exported |
Note: multiple spellings exported by: julia
Julia
Exported as apply_unit_conversion and apply_unit_conversion!. Both names refer to the same operation.
apply_unit_conversion
apply_unit_conversion(values::AbstractArray, conversion; variable_name)
apply_unit_conversion(values, conversion; variable_name) -> Array
Non-mutating apply_unit_conversion!
: returns a converted copy, or
values itself when there is nothing to apply.
apply_unit_conversion!
apply_unit_conversion!(values::AbstractVector{Float64}, conversion; variable_name)
apply_unit_conversion!(values, conversion; variable_name) -> values
Apply conversion to values IN PLACE, producing the variable’s declared units
(esm-spec §8.5).
A factor (or a closed expression, which folds to one) multiplies; a factor of
exactly 1.0 leaves the values untouched rather than round-tripping them through
a multiply. An open expression is COMPILED ONCE and then evaluated per element
with the raw value bound to its single free variable; more than one free variable
is an error, since there is no second column to bind it to.
TypeScript
TypeScript does not export this function.
Python
apply_unit_conversion(values: Any, conversion: Any, *, variable_name: str) -> Any
Apply conversion to values.
Accepts Python scalars, numpy arrays, xarray DataArrays, or anything
supporting numeric multiplication. If conversion is a constant
(number or closed expression), multiplies values by that constant.
If it is an open expression, evaluates it once per element with the raw
value bound to the expression’s single free variable.
Rust
Rust does not export this function.
Go
Go does not export this function.