SpringPulseOnset
- postprocessinglib.evaluation.metrics.SpringPulseOnset(df: DataFrame, stations: list[int] = [], use_jday: bool = False) int
Calculates the average day of year when the spring pulse (snowmelt) begins for each station.
- Parameters:
df (pd.DataFrame) – Observed or simulated streamflow data with a MultiIndex (YEAR, JDAY).
stations (list[int], optional) – List of 1-indexed station numbers to evaluate. If empty, all stations are used.
use_jday (bool, default False) – If True, treats data as JDAY-style (fixed 366-day years). If False, uses datetime index logic.
- Returns:
DataFrame with station indices and average spring pulse onset day.
- Return type:
pd.DataFrame
Example
Calculation of the SpringPulseOnset
>>> from postprocessinglib.evaluation import metrics, data >>> path = 'MESH_output_streamflow_1.csv' >>> DATAFRAMES = data.generate_dataframes(csv_fpath=path, warm_up=365) >>> observed = DATAFRAMES["DF_OBSERVED"] >>> simulated = DATAFRAMES["DF_SIMULATED"] >>> print(observed) QOMEAS_05BB001 QOMEAS_05BA001 YEAR JDAY 1980 366 10.20 NaN 1981 1 9.85 NaN 2 10.20 NaN 3 10.00 NaN 4 10.10 NaN ... ... ... 2017 361 NaN NaN 362 NaN NaN 363 NaN NaN 364 NaN NaN 365 NaN NaN >>> . >>> print(simulated) QOSIM_05BB001 QOSIM_05BA001 YEAR JDAY 1980 366 2.530770 1.006860 1981 1 2.518999 1.001954 2 2.507289 0.997078 3 2.495637 0.992233 4 2.484073 0.987417 ... ... ... 2017 361 4.418050 1.380227 362 4.393084 1.372171 363 4.368303 1.364174 364 4.343699 1.356237 365 4.319275 1.348359
>>> # Calculating the spring pulse onset day >>> spod = metrics.SpringPulseOnset(df=simulated) >>> print(spod) [136, 143]