Time Series¶
- pydantic model infrasys.time_series_models.TimeSeriesData¶
Base class for all time series models
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "TimeSeriesData", "description": "Base class for all time series models", "type": "object", "properties": { "uuid": { "format": "uuid", "title": "Uuid", "type": "string" }, "variable_name": { "title": "Variable Name", "type": "string" }, "normalization": { "anyOf": [ { "discriminator": { "mapping": { "by_value": "#/$defs/NormalizationByValue", "max": "#/$defs/NormalizationMax" }, "propertyName": "normalization_type" }, "oneOf": [ { "$ref": "#/$defs/NormalizationMax" }, { "$ref": "#/$defs/NormalizationByValue" } ] }, { "type": "null" } ], "default": null, "description": "Defines the type of normalization performed on the data, if any.", "title": "Normalization" } }, "$defs": { "NormalizationByValue": { "additionalProperties": false, "description": "Perform normalization by a user-defined value.", "properties": { "value": { "title": "Value", "type": "number" }, "normalization_type": { "const": "by_value", "default": "by_value", "enum": [ "by_value" ], "title": "Normalization Type", "type": "string" } }, "required": [ "value" ], "title": "NormalizationByValue", "type": "object" }, "NormalizationMax": { "additionalProperties": false, "description": "Perform normalization by the max value in an array.", "properties": { "max_value": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Max Value" }, "normalization_type": { "const": "max", "default": "max", "enum": [ "max" ], "title": "Normalization Type", "type": "string" } }, "title": "NormalizationMax", "type": "object" } }, "additionalProperties": false, "required": [ "variable_name" ] }
- Config:
str_strip_whitespace: bool = True
validate_assignment: bool = True
validate_default: bool = True
extra: str = forbid
use_enum_values: bool = False
arbitrary_types_allowed: bool = True
populate_by_name: bool = True
- Fields:
- field normalization: Annotated[None | NormalizationMax | NormalizationByValue, FieldInfo(annotation=NoneType, required=True, description='Defines the type of normalization performed on the data, if any.', discriminator='normalization_type')] = None¶
Defines the type of normalization performed on the data, if any.
- field variable_name: str [Required]¶
- abstract static get_time_series_metadata_type() Type ¶
Return the metadata type associated with this time series type.
- property summary: str¶
Return the variable_name of the time series array with its type.
- pydantic model infrasys.time_series_models.SingleTimeSeries¶
Defines a time array with a single dimension of floats.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "SingleTimeSeries", "description": "Defines a time array with a single dimension of floats.", "type": "object", "properties": { "uuid": { "format": "uuid", "title": "Uuid", "type": "string" }, "variable_name": { "title": "Variable Name", "type": "string" }, "normalization": { "anyOf": [ { "discriminator": { "mapping": { "by_value": "#/$defs/NormalizationByValue", "max": "#/$defs/NormalizationMax" }, "propertyName": "normalization_type" }, "oneOf": [ { "$ref": "#/$defs/NormalizationMax" }, { "$ref": "#/$defs/NormalizationByValue" } ] }, { "type": "null" } ], "default": null, "description": "Defines the type of normalization performed on the data, if any.", "title": "Normalization" }, "data": { "anyOf": [], "title": "Data" }, "resolution": { "format": "duration", "title": "Resolution", "type": "string" }, "initial_time": { "format": "date-time", "title": "Initial Time", "type": "string" } }, "$defs": { "NormalizationByValue": { "additionalProperties": false, "description": "Perform normalization by a user-defined value.", "properties": { "value": { "title": "Value", "type": "number" }, "normalization_type": { "const": "by_value", "default": "by_value", "enum": [ "by_value" ], "title": "Normalization Type", "type": "string" } }, "required": [ "value" ], "title": "NormalizationByValue", "type": "object" }, "NormalizationMax": { "additionalProperties": false, "description": "Perform normalization by the max value in an array.", "properties": { "max_value": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Max Value" }, "normalization_type": { "const": "max", "default": "max", "enum": [ "max" ], "title": "Normalization Type", "type": "string" } }, "title": "NormalizationMax", "type": "object" } }, "additionalProperties": false, "required": [ "variable_name", "data", "resolution", "initial_time" ] }
- Config:
str_strip_whitespace: bool = True
validate_assignment: bool = True
validate_default: bool = True
extra: str = forbid
use_enum_values: bool = False
arbitrary_types_allowed: bool = True
populate_by_name: bool = True
- Fields:
- Validators:
- field data: Array | Quantity [Required]¶
- Validated by:
- field initial_time: datetime [Required]¶
- field resolution: timedelta [Required]¶
- classmethod aggregate(ts_data: list[Self]) Self ¶
Method to aggregate list of SingleTimeSeries data.
- Parameters:
ts_data – list of SingleTimeSeries data
- Return type:
- Raises:
InconsistentTimeseriesAggregation – Raised if incompatible timeseries data are passed.
- classmethod from_array(data: Sequence | Array | ndarray | Quantity, variable_name: str, initial_time: datetime, resolution: timedelta, normalization: Annotated[None | NormalizationMax | NormalizationByValue, FieldInfo(annotation=NoneType, required=True, description='Defines the type of normalization performed on the data, if any.', discriminator='normalization_type')] = None) SingleTimeSeries ¶
Method of SingleTimeSeries that creates an instance from a sequence.
- Parameters:
data – Sequence that contains the values of the time series
initial_time – Start time for the time series (e.g., datetime(2020,1,1))
resolution – Resolution of the time series (e.g., 30min, 1hr)
variable_name – Name assigned to the values of the time series (e.g., active_power)
- Return type:
See also
from_time_array
Time index implementation
Note
Length of the sequence is inferred from the data.
- classmethod from_time_array(data: Sequence | Array | ndarray | Quantity, variable_name: str, time_index: Sequence[datetime], normalization: Annotated[None | NormalizationMax | NormalizationByValue, FieldInfo(annotation=NoneType, required=True, description='Defines the type of normalization performed on the data, if any.', discriminator='normalization_type')] = None) SingleTimeSeries ¶
Create SingleTimeSeries using time_index provided.
- Parameters:
data – Sequence that contains the values of the time series
variable_name – Name assigned to the values of the time series (e.g., active_power)
time_index – Sequence that contains the index of the time series
- Return type:
See also
from_array
Base implementation
Note
The current implementation only uses the time_index to infer the initial time and resolution.
- static get_time_series_metadata_type() Type ¶
Return the metadata type associated with this time series type.
- property length: int¶
Return the length of the data.