perda.units#
- class perda.units.Timescale(*values)[source]#
Bases:
EnumSupported timestamp units for time-series data.
- MS = 'ms'#
- S = 's'#
- US = 'us'#
- perda.units.convert_time(timestamp, source_time_unit, target_time_unit)[source]#
Convert a timestamp between two timescale units.
- Parameters:
- Returns:
Timestamp(s) in the target unit.
- Return type:
float | NDArray[Float64]
Examples
>>> convert_time(5000.0, Timescale.MS, Timescale.S) 5.0
- perda.units.from_seconds(timestamp_s, target_time_unit)[source]#
Convert a timestamp from seconds to the given unit.
- Parameters:
timestamp_s (float | NDArray[Float64]) – Timestamp(s) in seconds.
target_time_unit (Timescale) – Desired output unit.
- Returns:
Timestamp(s) in the target unit.
- Return type:
float | NDArray[Float64]
- perda.units.in_to_m(value)[source]#
Convert a length value from inches to meters.
- Parameters:
value (float | NDArray[Float64]) – Length in inches.
- Returns:
Length in meters.
- Return type:
float | NDArray[Float64]
Examples
>>> in_to_m(1.0) 0.0254
- perda.units.mph_to_m_per_s(value)[source]#
Convert a speed value from miles per hour to meters per second.
- Parameters:
value (float | NDArray[Float64]) – Speed in mph.
- Returns:
Speed in m/s.
- Return type:
float | NDArray[Float64]
Examples
>>> mph_to_m_per_s(1.0) 0.44704
- perda.units.to_seconds(timestamp, source_time_unit)[source]#
Convert a timestamp from the given unit to seconds.
- Parameters:
timestamp (float | NDArray[Float64]) – Timestamp(s) to convert.
source_time_unit (Timescale) – Unit of the input timestamp.
- Returns:
Timestamp(s) in seconds.
- Return type:
float | NDArray[Float64]