Skip to content

measurement_point

MeasurementPoint

Bases: BaseModel

Represents a single measurement point in the environment.

Attributes:

Name Type Description
x float

X-coordinate of the measurement point in meters.

y float

Y-coordinate of the measurement point in meters (must be below 0).

distances_to_cables dict[CableKey, float]

Mapping from cable keys to distances in meters.

distances_to_mirror_cables dict[CableKey, float]

Mapping from mirror cable keys to distances in meters.

ndigits int

Number of decimal places used when generating the key.

key MeasurementPointKey

Computed 3-level key used in result DataFrame columns.

key property

key: MeasurementPointKey

Create a stable output key for a measurement point.

Returns:

Type Description
MeasurementPointKey

A 3-level tuple key in the format

MeasurementPointKey

("measurement_point", "x=<value>m", "y=<value>m").

MeasurementPointRegistry

MeasurementPointRegistry()

Stores and deduplicates measurement points.

Attributes:

Name Type Description
points set[MeasurementPoint]

Set of unique measurement points.

Source code in cable_thermal_model/environment/measurement_point.py
81
82
83
84
85
def __init__(self) -> None:
    """Initialize an empty measurement-point registry."""
    self.points: set[MeasurementPoint] = set()

    return

measurement_point_keys property

measurement_point_keys: set[MeasurementPointKey]

Return all registered measurement-point keys.

Returns:

Type Description
set[MeasurementPointKey]

The set of measurement-point keys currently in the registry.

add_measurement_point

add_measurement_point(x: float, y: float, ndigits: int = 3) -> MeasurementPointKey

Add a measurement point to the registry.

Parameters:

Name Type Description Default
x float

x-coordinate of the measurement point.

required
y float

y-coordinate of the measurement point.

required
ndigits int

Number of decimal places to round the coordinates for key generation.

3

Returns:

Type Description
MeasurementPointKey

The key of the added or already-existing measurement point.

Source code in cable_thermal_model/environment/measurement_point.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def add_measurement_point(self, x: float, y: float, ndigits: int = 3) -> MeasurementPointKey:
    """Add a measurement point to the registry.

    Args:
        x: x-coordinate of the measurement point.
        y: y-coordinate of the measurement point.
        ndigits: Number of decimal places to round the coordinates for key generation.

    Returns:
        The key of the added or already-existing measurement point.
    """
    measurement_point = MeasurementPoint(x=x, y=y, ndigits=ndigits)
    if measurement_point.key in self.measurement_point_keys:
        _, x_str, y_str = measurement_point.key
        logger.warning(f"Measurement point at {x_str}, {y_str} already exists. Skipping addition.")
    else:
        self.points.add(measurement_point)

    return measurement_point.key