perda.core_data_structures.single_run_data#

pydantic model perda.core_data_structures.single_run_data.SingleRunData[source]#

Bases: BaseModel

Pydantic model to store parsed CSV data with dictionary-like lookup.

Notes

All timestamps (data_start_time, data_end_time and every DataInstance’s timestamp_np) are raw integers in timestamp_unit, which is microseconds for current logs. Helpers that take a source_time_unit or timestamp_unit argument require it; pass data.timestamp_unit.

Examples

>>> from perda.units import to_seconds
>>> data = aly.data
>>> di = data["pcm.wheelSpeeds.frontRight"]
>>> "pcm.wheelSpeeds.frontRight" in data
>>> duration_s = to_seconds(data.data_end_time - data.data_start_time, data.timestamp_unit)
Config:
  • arbitrary_types_allowed: bool = True

Fields:
Validators:
  • _build_keyword_index » all fields

field id_to_instance: dict[int, DataInstance] [Required]#

Mapping from variable ID to DataInstance

Validated by:
  • _build_keyword_index

field cpp_name_to_id: dict[str, int] [Required]#

Mapping from variable name to variable ID

Validated by:
  • _build_keyword_index

field id_to_cpp_name: dict[int, str] [Required]#

Mapping from variable ID to variable name

Validated by:
  • _build_keyword_index

field id_to_descript: dict[int, str] [Required]#

Mapping from variable ID to variable description

Validated by:
  • _build_keyword_index

field creation_time: datetime | None = None#

Timestamp when this run log was recorded

Validated by:
  • _build_keyword_index

field total_data_points: int [Required]#

Total number of data points across all variables

Validated by:
  • _build_keyword_index

field data_start_time: int [Required]#

Start timestamp in log timestamp unit

Validated by:
  • _build_keyword_index

field data_end_time: int [Required]#

End timestamp in log timestamp unit

Validated by:
  • _build_keyword_index

field timestamp_unit: Timescale = Timescale.MS#

Timestamp logging unit for this run (ms/us)

Validated by:
  • _build_keyword_index

field concat_boundaries: list[int] [Optional]#

Timestamps where concatenated runs begin (post-shift)

Validated by:
  • _build_keyword_index

field semantic_index: VariableSemanticIndex | None = None#

Vector index over variable descriptions. None when semantic search is disabled or unavailable

Validated by:
  • _build_keyword_index

field keyword_index: VariableKeywordIndex [Optional]#

Normalized name and description text backing keyword search

Validated by:
  • _build_keyword_index

add(cpp_name, di)[source]#

Insert a new derived DataInstance using a synthetic negative ID.

Parameters:
  • cpp_name (str) – C++ variable name key for the new variable.

  • di (DataInstance) – DataInstance to insert.

Return type:

None

Examples

>>> power = aly.data["bms.pack.voltage"] * aly.data["bms.pack.current"]
>>> aly.data.add("derived.pack.power", power)
>>> fig = aly.plot("derived.pack.power")
replace(cpp_name, di)[source]#

Overwrite the values of an existing variable in-place.

Parameters:
  • cpp_name (str) – C++ variable name of the variable to replace.

  • di (DataInstance) – DataInstance whose value_np that replaces the stored one.

Return type:

None

Examples

>>> voltage = aly.data["bms.pack.voltage"]
>>> aly.data.replace("bms.pack.voltage", voltage / 1000.0)