Skip to content

environmental_compensation

environmental_compensation ¤

EnvironmentalCompensationEvents ¤

EnvironmentalCompensationEvents(
    dataframe: DataFrame,
    signal_uuid: str,
    *,
    env_uuid: str | None = None,
    env_value: float | None = None,
    value_column: str = "value_double",
    event_uuid: str = "quality:env_compensation",
    time_column: str = "systime"
)

Bases: Base

Quality: Environmental Compensation for Inline Sensors

Detect and compensate for environmental effects (temperature, humidity, pressure) on inline measurement sensors. Tracks correlation, estimates sensitivity coefficients, applies compensation, and flags out-of-range conditions.

Methods: - detect_correlation: Pearson correlation per window. - sensitivity: Linear regression coefficient per window. - compensated_signal: Apply compensation model to signal. - detect_env_exceedance: Flag out-of-range environmental conditions.

env_uuid (the environment signal) is required; the constructor raises ValueError without it. env_value is optional and only sets the nominal environment value used by compensated_signal.

detect_correlation ¤

detect_correlation(window: str = '4h') -> pd.DataFrame

Pearson correlation between measurement and env signal per window.

Parameters:

Name Type Description Default
window str

Resample window size.

'4h'

Returns:

Type Description
DataFrame

Summary DataFrame with columns: start, end, duration_seconds

DataFrame

(the window bounds), window_start (the resample label; a

DataFrame

deprecated twin of start), correlation, p_value,

DataFrame

significant.

sensitivity ¤

sensitivity(window: str = '8h') -> pd.DataFrame

Estimate environmental sensitivity coefficient per window.

Fits measurement = a × env + b per window.

Parameters:

Name Type Description Default
window str

Resample window size.

'8h'

Returns:

Type Description
DataFrame

Summary DataFrame with columns: start, end, duration_seconds

DataFrame

(the window bounds), window_start (the resample label; a

DataFrame

deprecated twin of start), coefficient, intercept,

DataFrame

r_squared, unit_change_per_degree.

compensated_signal ¤

compensated_signal(
    coefficient: float | None = None,
) -> pd.DataFrame

Apply linear compensation to the measurement signal.

corrected = measured - coefficient × (env - env_nominal)

If coefficient is not provided, estimates from data using overall linear regression.

Parameters:

Name Type Description Default
coefficient float | None

Environmental sensitivity coefficient. If None, estimated from data.

None

Returns:

Type Description
DataFrame

DataFrame with columns: systime, uuid, value_double,

DataFrame

compensated_value, correction_applied, source_uuid. uuid

DataFrame

is the event uuid and source_uuid the measured signal's uuid.

detect_env_exceedance ¤

detect_env_exceedance(
    valid_range: tuple[float, float], window: str = "1h"
) -> pd.DataFrame

Flag windows where environmental conditions exceed valid range.

Parameters:

Name Type Description Default
valid_range tuple[float, float]

Tuple (min, max) of acceptable env values.

required
window str

Resample window size.

'1h'

Returns:

Type Description
DataFrame

Summary DataFrame with columns: start, end, duration_seconds

DataFrame

(the window bounds), window_start (the resample label; a

DataFrame

deprecated twin of start), window_end, env_mean,

DataFrame

env_min, env_max, exceedance_type, severity.