utils.units module¶
Functions to convert distances between different units
Function |
Description |
---|---|
Returns a list of units supported by pfdf |
|
Converts distances from one unit to another |
|
Returns the conversion factors from supported units to meters |
Functions¶
- pfdf.utils.units.supported()¶
Returns a list of unit options supported by pfdf
supported()
Returns a list of supported unit options.
- Outputs:
list – The unit options supported by pfdf
- pfdf.utils.units.convert(distance, from_units, to_units)¶
Converts distances from one unit to another
convert(distance, from_units, to_units)
Converts the input distances from one unit to another. Distances may be a scalar or array-like dataset. Always returns converted distances as a numpy array. Note that you cannot convert between “base” units, as these units are ambiguous and depend on the selection of CRS.
- Inputs:
distance (int | float | np.ndarray) – The distances that should be converted
from_units (str) – The current units of distances
to_units (str) – The units that the distances should be converted to
- Outputs:
np.ndarray – The converted distances
- pfdf.utils.units.units_per_meter()¶
Returns conversion factors between supported units and meters
units_per_meter()
Returns a dict whose keys are the (string) names of unit options supported by pfdf. Values are the multiplicative conversion factors used to convert from meters to the associated unit. Note that the “base” unit refers to the base units of a CRS. The base conversion factor is nan because these units are variable and depend on the selection of CRS.
- Outputs:
dict – Multiplicative conversion factors from meters to each unit