wristpy.core.models¶
Internal data model.
Functions
|
!!! abstract "Usage Documentation" |
Classes
|
!!! abstract "Usage Documentation" |
|
A single measurement of a sensor and its corresponding time. |
|
Watch data that is read off the device. |
- class wristpy.core.models.Measurement(*, name: str | None = None, measurements: ndarray, time: Series)[source]¶
Bases:
BaseModel
A single measurement of a sensor and its corresponding time.
- class Config[source]¶
Bases:
object
Config to allow for ndarray as input.
- arbitrary_types_allowed = True¶
- classmethod from_data_frame(data_frame: DataFrame, name: str | None = None) Measurement [source]¶
Creates a measurement from a Polars DataFrame.
- Parameters:
data_frame – The Polars DataFrame, must have a time column. All non-time columns will be used as the ‘measurements’ input.
name – Optional name describing the type of measurement.
- lazy_frame() LazyFrame [source]¶
Converts the measurement to a LazyFrame.
- Returns:
- The Measurement as a LazyFrame. The time property will have column name
’time’. Other column names should not be relied upon.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- time: Series¶
- classmethod validate_measurements_not_empty(v: ndarray) ndarray [source]¶
Validate that the measurements array is not empty.
- Parameters:
cls – The class.
v – The measurements array to validate.
- Returns:
The measurements array if it is not empty.
- Return type:
v
- Raises:
ValueError – If the measurements array is empty.
- classmethod validate_time(v: Series) Series [source]¶
Validate the time series.
Check that the time series is a datetime series, contains only unique entries, and is sorted.
- Parameters:
cls – The class.
v – The time series to validate.
- Returns:
The time series if it is valid.
- Return type:
v
- Raises:
ValueError – If the time series is not a datetime series or is not sorted,
or is empty. –
- class wristpy.core.models.WatchData(*, acceleration: Measurement, lux: Measurement | None = None, battery: Measurement | None = None, capsense: Measurement | None = None, temperature: Measurement | None = None, idle_sleep_mode_flag: bool | None = None, dynamic_range: tuple[float, float] | None = None)[source]¶
Bases:
BaseModel
Watch data that is read off the device.
This class should provide access to all raw input data. It must not be mutated during processing.
- acceleration: Measurement¶
- battery: Measurement | None¶
- capsense: Measurement | None¶
- lux: Measurement | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- temperature: Measurement | None¶
- classmethod validate_acceleration(v: Measurement) Measurement [source]¶
Validate the acceleration data.
Ensure that the acceleration data is a 2D array with 3 columns.
- Parameters:
cls – The class.
v – The acceleration data to validate.
- Returns:
The acceleration data if it is valid.
- Return type:
v
- Raises:
ValueError – If the acceleration data is not a 2D array with 3 columns.