reclaim.dynamic_features.utils package
reclaim.dynamic_features.utils.catchment_meteorology module
reclaim.dynamic_features.utils.inflow_outflow module
- reclaim.dynamic_features.utils.inflow_outflow.max_annual_flow_m3_per_s(ts: Series) float[source]
Computes the maximum annual flow in m³/s from daily flow series.
- Parameters:
ts (pd.Series) – Time series of daily flow values in m³/day, indexed by datetime.
- Returns:
Maximum annual flow in m³/s.
- Return type:
float
- reclaim.dynamic_features.utils.inflow_outflow.mean_annual_flow_m3_per_s(ts: Series) float[source]
Computes the mean annual flow in m³/s from a time series of daily flow in m³/day.
- Parameters:
ts (pd.Series) – Time series of daily flow values in m³/day, indexed by datetime.
- Returns:
Mean annual flow in m³/s.
- Return type:
float
- reclaim.dynamic_features.utils.inflow_outflow.mean_annual_flow_std_m3_per_s(ts: Series) float[source]
Computes the mean annual standard deviation of daily flow (in m³/s).
- Parameters:
ts (pd.Series) – Time series of daily flow values in m³/day, indexed by datetime.
- Returns:
Mean annual standard deviation of flow in m³/s.
- Return type:
float
- reclaim.dynamic_features.utils.inflow_outflow.mean_annual_flow_variability(ts: Series) float[source]
Computes the mean annual variability (coefficient of variation) of daily flow.
CV = std / mean within each year
- Parameters:
ts (pd.Series) – Time series of daily flow values in m³/day, indexed by datetime.
- Returns:
Mean coefficient of variation across all years (unitless).
- Return type:
float
reclaim.dynamic_features.utils.rainfall module
- reclaim.dynamic_features.utils.rainfall.mean_annual_rainfall_mm(ts: Series) float[source]
Calculates the mean annual rainfall in mm from a time series of daily rainfall in mm.
- Parameters:
ts (pd.Series) – Time series of daily rainfall values in mm, indexed by datetime.
- Returns:
Mean annual rainfall in mm.
- Return type:
float
- reclaim.dynamic_features.utils.rainfall.mean_annual_rainy_days(ts: Series, threshold: float = 100.0) float[source]
Calculates the mean annual number of days on which daily rainfall exceeds a threshold.
- Parameters:
ts (pd.Series) – Time series of daily rainfall values in mm, indexed by datetime.
threshold (float, optional) – Rainfall threshold in mm to define a “rainy day” (default is 10 mm).
- Returns:
Mean annual number of days exceeding the threshold.
- Return type:
float
reclaim.dynamic_features.utils.statistical_metrics module
- reclaim.dynamic_features.utils.statistical_metrics.annual_mean(ts: Series) float[source]
Calculates the mean of annual means from a time series. The annual mean is computed for each year using daily values.
- Parameters:
ts (pd.Series) – Time series of daily values, indexed by datetime.
- Returns:
Mean of the annual mean values across all years.
- Return type:
float
- reclaim.dynamic_features.utils.statistical_metrics.annual_std(ts: Series) float[source]
Calculates the mean annual standard deviation from a time series. Standard deviation is computed for each year using daily values.
- Parameters:
ts (pd.Series) – Time series of daily values, indexed by datetime.
- Returns:
Mean standard deviation across all years.
- Return type:
float
- reclaim.dynamic_features.utils.statistical_metrics.coefficient_of_variation(ts: Series) float[source]
Calculates coefficient of variation (CV) of the given time series.
- Parameters:
ts (pd.Series) – Time series, indexed by datetime.
- Returns:
Coefficient of variation (std/mean, unitless).
- Return type:
float
- reclaim.dynamic_features.utils.statistical_metrics.kurtosis_val(ts: Series) float[source]
Calculates kurtosis of the given time series.
- Parameters:
ts (pd.Series) – Time series, indexed by datetime.
- Returns:
Kurtosis of the time series (excess kurtosis, unitless).
- Return type:
float
- reclaim.dynamic_features.utils.statistical_metrics.max_annual_persistence(timeseries, threshold=0.36787944117144233, min_periods=30)[source]
Compute the persistence (decorrelation time) of high values in a time series annually.
- Parameters:
timeseries (pd.Series) – A datetime-indexed series of daily values.
threshold (float, optional) – Autocorrelation cutoff (default=1/e ~ 0.367).
min_periods (int, optional) – Minimum number of days required in a year to compute autocorrelation.
- Returns:
Maximum persistence (days) across all years.
- Return type:
int
- reclaim.dynamic_features.utils.statistical_metrics.max_days_above_90th(ts: Series) float[source]
Calculates the maximum number of days per year where the daily values exceed the 90th percentile threshold (computed over the entire time series).
- Parameters:
ts (pd.Series) – Time series of daily values, indexed by datetime.
- Returns:
Maximum count of days above the 90th percentile across years.
- Return type:
float
reclaim.dynamic_features.utils.ts_aggregate module
- reclaim.dynamic_features.utils.ts_aggregate.build_intervals(start_year, end_year, time_interval)[source]
- reclaim.dynamic_features.utils.ts_aggregate.compute_ts_aggregates(ts_csv_path: str, time_column: str, value_column: str, feature_functions: Dict[str, Callable], intervals: List[Sequence[int]]) DataFrame[source]
Compute an aggregate feature from a user-provided time series CSV for a single reservoir.
- Parameters:
ts_csv_path (str) – Path to the CSV file containing the time series.
time_column (str) – Name of the column representing dates/timestamps.
value_column (str) – Name of the column representing the variable values.
feature_functions (Dict[str, Callable]) – Dictionary where keys are feature names (column names for output DataFrame) and values are functions that take a pd.Series and return a single value.
intervals (list of list of int) – List of [start_year, end_year] intervals to compute features over.
- Returns:
A single-row DataFrame containing the computed feature with the specified column name.
- Return type:
pd.DataFrame