perda.analyzer.analyzer#

class perda.analyzer.analyzer.Analyzer(filepath, ts_offset=0, parsing_errors_limit=100)[source]#

Bases: object

Primary class for loading and analyzing car log data.

Parameters:
  • filepath (str)

  • ts_offset (int)

  • parsing_errors_limit (int)

analyze_frequency(var, expected_frequency_hz=None, gap_threshold_multiplier=2.0, font_config=FontConfig(large=20, medium=14, small=10), layout_config=LayoutConfig(width=1200, height=700, margin={'l': 70, 'r': 50, 't': 90, 'b': 70}, plot_bgcolor='white', title_x=0.5, title_xanchor='center', title_yanchor='top'), plot_config=ScatterHistogramPlotConfig(color_scatter='blue', color_line='crimson', color_histogram='blue', histogram_bins=80))[source]#

Analyse the sampling frequency of a variable and return a diagnostic figure.

Prints a summary to stdout and returns a Plotly figure with two subplots: instantaneous frequency over time and an inter-sample interval histogram.

Parameters:
  • var (Union[str, int]) – Variable name or ID to look up in the parsed data.

  • expected_frequency_hz (float | None, optional) – Nominal expected sampling frequency in Hz for error and gap diagnostics. Default is None.

  • gap_threshold_multiplier (float, optional) – Intervals exceeding this multiple of the expected (or median) interval are flagged as gaps. Default is 2.0.

  • font_config (FontConfig, optional) – Font sizes for plot elements. Default is DEFAULT_FONT_CONFIG.

  • layout_config (LayoutConfig, optional) – Plot dimensions and margins. Default is DEFAULT_LAYOUT_CONFIG.

  • plot_config (ScatterHistogramPlotConfig)

Returns:

Plotly figure with frequency diagnostics.

Return type:

go.Figure

Examples

>>> fig = aly.analyze_frequency("ams.stack.thermistors.temperature[38]", expected_frequency_hz=100)
>>> fig.show()
diff(server_data, timestamp_tolerance_ms=2, diff_rtol=0.001, diff_atol=0.001)[source]#

Compute the differences between the current data (assumed to be from RPI) and server data.

Parameters:
  • server_data (SingleRunData) – The server data to compare against.

  • timestamp_tolerance_ms (int, optional) – Timestamp tolerance used to match points between streams.

  • diff_rtol (float, optional) – Relative tolerance for value comparison (numpy.isclose).

  • diff_atol (float, optional) – Absolute tolerance for value comparison (numpy.isclose).

Return type:

Figure

Examples

>>> fig = aly.diff(server_data)
>>> fig.show()
get_accel_times()[source]#

Get acceleration times from the analyzer.

Returns:

List of acceleration segment results.

Return type:

list[AccelSegmentResult]

Examples

>>> results = aly.get_accel_times()
>>> for r in results:
...     print(r)
plot(var_1, var_2=None, ts_start=None, ts_end=None, title=None, y_label_1=None, y_label_2=None, show_legend=True, font_config=FontConfig(large=20, medium=14, small=10), layout_config=LayoutConfig(width=1200, height=700, margin={'l': 70, 'r': 50, 't': 90, 'b': 70}, plot_bgcolor='white', title_x=0.5, title_xanchor='center', title_yanchor='top'), vline_config=VLineConfig(color='gray', width=2, dash='dash', opacity=0.7))[source]#

Display variables from the parsed data on an interactive Plotly plot.

Concat boundaries (if any) are automatically shown as vertical lines.

Parameters:
  • var_1 (Union[str, int, DataInstance, List[Union[str, int, DataInstance]]]) – Variable(s) to plot on the left y-axis. Can be variable name(s), variable ID(s), or DataInstance(s)

  • var_2 (Union[str, int, DataInstance, List[Union[str, int, DataInstance]]] | None, optional) – Optional variable(s) to plot on the right y-axis. Can be variable name(s), variable ID(s), or DataInstance(s).

  • ts_start (float | None, optional) – Start of the time window in seconds. Data points before this time are excluded. Default is None (no lower bound).

  • ts_end (float | None, optional) – End of the time window in seconds. Data points after this time are excluded. Default is None (no upper bound).

  • title (str | None, optional)

  • y_label_1 (str | None, optional) – Label for left y-axis (or only y-axis if no right input).

  • y_label_2 (str | None, optional) – Label for right y-axis.

  • show_legend (bool, optional) – Whether to show plot legends. Default is True

  • font_config (FontConfig, optional) – Font configuration for plot elements. Default is DEFAULT_FONT_CONFIG

  • layout_config (LayoutConfig, optional) – Layout configuration for plot dimensions. Default is DEFAULT_LAYOUT_CONFIG

  • vline_config (VLineConfig, optional) – Visual configuration for concat boundary lines. Default is DEFAULT_VLINE_CONFIG.

Return type:

Figure

Examples

>>> fig = aly.plot("pcm.wheelSpeeds.frontRight")
>>> fig = aly.plot(["pcm.wheelSpeeds.frontRight", "pcm.wheelSpeeds.frontLeft"], title="Front Wheel Speeds")
>>> fig = aly.plot("pcm.moc.motor.requestedTorque", "pcm.wheelSpeeds.frontRight", ts_start=10.0, ts_end=30.0)
>>> fig.show()
search(query)[source]#

Natural language search for available variables in the parsed data.

Parameters:

query (str) – Search query

Return type:

None

Examples

>>> aly.search("front wheel speed")