Plotting

class hydrobricks.plotter.Plotter[source]

Bases: object

A utility class for creating visualizations of hydrological model results.

This class provides methods for plotting time series comparisons, spatial distributions of model components across hydro units, and animated maps showing temporal evolution.

static create_animated_map_hydro_unit_value(results: Results, unit_ids_raster_path: str | Path, component: str, start_date: str, end_date: str, save_path: str | Path, dem_path: str | Path | None = None, min_val: int = 0, max_val: int | None = None, fps: int = 5, figsize: tuple[int, int] = (6.4, 4.8)) None[source]

Create an animated map of the values of a component at the hydro units.

Generates a time-series animation showing spatial evolution of a model component across hydro units over a specified time period. Saves as GIF.

Parameters:
  • results – The results object from a model run.

  • unit_ids_raster_path – Path to the raster file containing hydro unit IDs.

  • component – Name of the component to visualize (e.g., ‘discharge’, ‘storage’).

  • start_date – Start date of animation period (format: ‘YYYY-MM-DD’).

  • end_date – End date of animation period (format: ‘YYYY-MM-DD’).

  • save_path – Directory path where the animation GIF will be saved.

  • dem_path – Path to digital elevation model (DEM) raster. If provided, DEM is shown as shaded relief background. Default: None

  • min_val – Minimum value for color scale. Default: 0

  • max_val – Maximum value for color scale. If None, auto-scaled. Default: None

  • fps – Frames per second for animation. Default: 5

  • figsize – Figure size in inches (width, height). Default: (6.4, 4.8)

static plot_hydrograph(obs: numpy.ndarray, sim: numpy.ndarray, time: numpy.ndarray, year: int | None = None) None[source]

Plot the hydrograph of observed and simulated data.

Creates a plot comparing observed discharge with simulated discharge over time. Optionally filters to a specific year.

Parameters:
  • obs – The observed discharge data (1D array).

  • sim – The simulated discharge data (1D array).

  • time – The time array with datetime values.

  • year – The year to plot. If None, plots the entire time series. Default: None

static plot_map_hydro_unit_value(results: Results, unit_ids_raster_path: str | Path, component: str, date: str, dem_path: str | Path | None = None, min_val: int = 0, max_val: int | None = None, figsize: tuple[int, int] = (6.4, 4.8), title: str | None = None) None[source]

Plot the values of a component at the hydro units on a map.

Displays spatial distribution of model component values across hydro units on a raster map. Optionally overlays a digital elevation model for context.

Parameters:
  • results – The results object from a model run.

  • unit_ids_raster_path – Path to the raster file containing hydro unit IDs.

  • component – Name of the component to visualize (e.g., ‘discharge’, ‘storage’).

  • date – Date to plot (format: ‘YYYY-MM-DD’).

  • dem_path – Path to digital elevation model (DEM) raster. If provided, DEM is shown as shaded relief background. Default: None

  • min_val – Minimum value for color scale. Default: 0

  • max_val – Maximum value for color scale. If None, auto-scaled. Default: None

  • figsize – Figure size in inches (width, height). Default: (6.4, 4.8)

  • title – Title for the plot. If None, uses the date. Default: None