teehr.TimeseriesAwareCalculatedFields#

class teehr.TimeseriesAwareCalculatedFields[source]#

Bases: object

Timeseries aware calculated fields.

Notes

Timeseries aware CFs are aware of ordered groups of data (e.g., a timeseries). This is useful for things such as event detection, base flow separation, and other fields that need to be calculated based on a entire timeseries. The definition of what creates a unique set of timeseries (i.e., a timeseries) can be specified.

Available Calculated Fields:

  • PercentileEventDetection

Methods

class PercentileEventDetection(*, quantile: float = 0.85, value_time_field_name: str = 'value_time', value_field_name: str = 'primary_value', output_event_field_name: str = 'event', output_event_id_field_name: str = 'event_id', uniqueness_fields: str | List[str] = ['reference_time', 'primary_location_id', 'configuration_name', 'variable_name', 'unit_name'])#

Bases: CalculatedFieldABC, CalculatedFieldBaseModel

Adds an “event” and “event_id” column to the DataFrame based on a percentile threshold.

The “event” column (bool) indicates whether the value is above the XXth percentile. The “event_id” column (string) groups continuous segments of events and assigns a unique ID to each segment in the format “startdate-enddate”.

Properties#

  • quantile:

    The percentile threshold to use for event detection. Default: 0.85

  • value_time_field_name:

    The name of the column containing the timestamp. Default: “value_time”

  • value_field_name:

    The name of the column containing the value to detect events on. Default: “primary_value”

  • output_event_field_name:

    The name of the column to store the event detection. Default: “event”

  • output_event_id_field_name:

    The name of the column to store the event ID. Default: “event_id”

  • uniqueness_fields:

    The columns to use to uniquely identify each timeseries.

    Default: [
        'reference_time',
        'primary_location_id',
        'configuration_name',
        'variable_name',
        'unit_name'
    ]
    
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].