Skip to content

continuous_process_alignment

continuous_process_alignment ¤

Continuous-process alignment: transport-lag compensation for multi-station lines.

ContinuousProcessAlignmentEvents ¤

ContinuousProcessAlignmentEvents(
    dataframe: DataFrame,
    speed_uuid: str,
    line_config: list[dict],
    *,
    ref_uuid: str | None = None,
    cut_uuid: str | None = None,
    time_column: str = "systime",
    uuid_column: str = "uuid",
    value_column: str = "value_double",
    speed_unit: str = "m/min",
    min_speed: float = 0.01
)

Bases: Base

Align multi-station readings on a continuous production line to a common material reference time via speed-based transport lag compensation.

Parameters¤

dataframe: Long-format DataFrame with time_column, uuid_column, and signal value columns. All UUIDs (speed, stations, cut signals) share the same DataFrame. speed_uuid: UUID of the line-speed signal. line_config: Physical layout description — list of dicts with keys: name (str), offset (float, metres from reference), uuids (list[str]). ref_uuid: Optional UUID of a signal located at the reference point (offset = 0). cut_uuid: Optional UUID whose values carry the cut piece length in metres. time_column: Name of the timestamp column (default "systime"). uuid_column: Name of the UUID/identifier column (default "uuid"). value_column: Default value column used when no override is supplied to a method (default "value_double"). speed_unit: Unit of the speed signal. One of "m/min", "m/s", "mm/s". min_speed: Minimum speed in m/s used to clamp the speed before computing lag, preventing infinite lag at standstill (default 0.01).

align_to_reference ¤

align_to_reference(
    station_uuids: list[str] | None = None,
    *,
    value_column: str | None = None
) -> pd.DataFrame

Shift each station reading backward by its transport lag to produce a common material_ref_time.

Parameters¤

station_uuids: Subset of UUIDs to process. Defaults to all UUIDs in line_config. value_column: Value column to carry through. Defaults to the constructor value_column.

Returns¤

DataFrame with columns: material_ref_time, systime, uuid, component, position_offset_m, lag_seconds, <value_column>.

segment_by_cut ¤

segment_by_cut(
    aligned_df: DataFrame,
    *,
    cut_length_uuid: str | None = None,
    part_counter_uuid: str | None = None,
    cut_value_column: str = "value_double"
) -> pd.DataFrame

Add piece_id, piece_length_m, and piece_cut_ref_time to aligned_df (output of :meth:align_to_reference).

Cut-event detection strategies (in priority order):

  1. part_counter_uuid (boolean): each True row = 1 cut.
  2. part_counter_uuid (integer/float): each step where the counter increases by delta counts as delta cuts, all attributed to the same timestamp when the signal resolution is coarser than the cut rate.
  3. cut_length_uuid only: each row of the length signal = 1 cut.
Parameters¤

aligned_df: Output of :meth:align_to_reference. cut_length_uuid: UUID carrying the cut piece length value. part_counter_uuid: UUID of a part-counter signal (boolean or monotonically increasing integer). cut_value_column: Column holding the length value in cut_length_uuid rows.

Returns¤

aligned_df augmented with piece_id (int, 1-based), piece_length_m (float or NaN), piece_cut_ref_time (Timestamp).

lag_profile ¤

lag_profile(
    station_uuids: list[str] | None = None,
    *,
    window: str = "1min"
) -> pd.DataFrame

Compute per-window mean lag for each station.

Returns¤

DataFrame with columns: start, uuid, component, position_offset_m, mean_speed_m_s, lag_seconds.

alignment_quality ¤

alignment_quality(
    station_uuids: list[str] | None = None,
    *,
    window: str = "1h"
) -> pd.DataFrame

Coverage check: sample counts per window for speed and each station.

Returns¤

DataFrame with columns: start, speed_sample_count, has_speed_data, has_full_coverage, per_uuid_counts.