plotting¶
Visualization functions for Great Lakes NBS forecast output.
Produces the figures used to inspect and communicate forecast results:
plot_cnbs_forecast()— static 4x4 grid (lake x component) of the precipitation, evaporation, runoff, and NBS forecasts with 95% rangesplot_cnbs_forecast_interactive()— the same grid as an interactive Plotly figure saved to HTMLplot_nbs_forecast()— per-lake NBS forecast with climatology overlayplot_cep_timeseries()— Climatology Exceedance Probability (CEP) timeseries per lakeplot_cep_spatial()— month-by-month spatial CEP maps over the basin
Each function optionally saves to filename and otherwise displays the
figure. The plotting backends (matplotlib, plotly, cartopy) are mocked when
building the documentation.
- src.plotting.plot_cnbs_forecast(df, filename=None)[source]¶
Static Matplotlib plot for Great Lakes CNBS forecasts.
- Parameters:
df (pd.DataFrame) – Pivoted dataframe with columns: [“cfs_run”, “forecast_month”, “model”, “lake”, “precipitation”, “evaporation”, “runoff”, “nbs”]
filename (str, optional) – Path to save the PNG. If None, the plot is displayed only and not saved.
- src.plotting.plot_cnbs_forecast_interactive(df, filename=None)[source]¶
Interactive Plotly plot for Great Lakes CNBS forecasts.
- Parameters:
df (pd.DataFrame) – Pivoted dataframe with columns: [“cfs_run”, “forecast_month”, “model”, “lake”, “precipitation”, “evaporation”, “runoff”, “nbs”]
filename (str, optional) – File path for saving the interactive HTML. Defaults to None.
- src.plotting.plot_nbs_forecast(df_filtered, prob, filename=None)[source]¶
Plot NBS forecasts for the Great Lakes with ensemble model lines, 95% range, and climatology.
- Parameters:
df_filtered (pd.DataFrame) – Forecast data containing ‘forecast_month’, ‘lake’, ‘model’, and ‘nbs’.
prob (pd.DataFrame) – Probability of exceedance data containing ‘month’, ‘lake’, ‘prob_exceedance’, and ‘value’.
- src.plotting.plot_cep_timeseries(df_cep, filename=None)[source]¶
Plot Great Lakes 12-Month mean CEP timeseries for multiple models.
- Parameters:
df_cep (pd.DataFrame) –
- CEP dataframe. Must contain:
date
lake
model
cep
filename (str, optional) – Path to save figure.
- src.plotting.plot_cep_spatial(df_cep, model=None, value_col='cep', filename=None, cmap='BrBG_r', title='Great Lakes 12-Month NBS Climatology Exceedance Outlook')[source]¶
Plot a 12-panel spatial map of Climatology Exceedance Probability (CEP).
Renders one map per forecast month (up to twelve) over the Great Lakes basin, shading each lake polygon by its CEP value on a diverging wetter-to-drier colour scale.
- Parameters:
df_cep (pd.DataFrame) – CEP data. Must contain ‘forecast_month’, ‘lake’, and the column named by
value_col(and a ‘cep’ column used for labels).model (str, optional) – If given, plot only this model. If None, the multi-model mean across models is plotted.
value_col (str, default "cep") – Column used to colour each lake polygon.
filename (str, optional) – Path to save the figure. If None, the figure is displayed only.
cmap (str, default "BrBG_r") – Matplotlib colormap name for the diverging wetter/drier scale.
title (str, optional) – Base figure title; the selected model (or “Multi-model Mean”) is appended.
- Returns:
The created figure.
- Return type:
matplotlib.figure.Figure