RunSet#

MemberKindWhat it is
countpropertyNumber of simulations in the group.
metricspropertyOne row per run: its metrics at the gauge, in the window of its rule.
parameterspropertyWide parameter table with one row per simulation.
sim_idspropertySimulation ids in group order.
bestmethodReturn the run with the best value for metric.
comparemethodCompare one metric across the runs of the group, best first.
figuremethodDraw the registered runset figure *name* of this set, ensemble_band for one.
filtermethodIntersect with another catalog.find(**criteria) call.
scoremethodScore the stored series of every run again, on any window, after the fact.
score_networkmethodScore the stream-network criterion of every run again, as their trials scored it.
showmethodRead one thing of this set: table or figure.
sort_bymethodReturn a new group ordered by the raw value of one metric.
tablemethodReturn the table *name* of the set: parameters, metrics or runs.
timeseriesmethodReturn the stored series of every run, stacked, with sim_id and run.
to_csvmethodWrite to_dataframe() to a CSV file.
to_dataframemethodReturn a wide table joining metadata, parameters, and metrics.
to_xarraymethodReturn a lazy stacked xarray.DataArray of variable across sims.
worstmethodReturn the run with the worst value for metric.
class RunSet(sim_ids, catalog, *, render=None)[source]#

Collection view over several simulations from one catalog.

RunSet is returned by catalog queries that match more than one run. It behaves like a lightweight list of Run objects and adds cohort utilities: pivot parameter tables, read the metrics of each run under its rule, rank runs, compare one metric, export a wide DataFrame, and stack fields lazily. Runs scored under different rules (station, variable, window, rule version) are not ranked together unless asked (mixed_windows=True).

Parameters:
  • sim_ids (list[str]) – Ordered simulation ids in the group.

  • catalog (Catalog) – Catalog used to resolve ids into Run objects and tabular data.

  • render (Renderer | None) – The function that draws a figure of the set. Without one the set takes the one of its catalog, and figure is refused when there is none.

Examples

>>> group = catalog.find(project="my_project")
>>> group.count
>>> group.best("nse").summary()

See also

hydromodpy.results.run.view.Run

Per-simulation view yielded during iteration.

hydromodpy.results.catalog.facade.Catalog

Catalog that creates simulation groups.

best(metric, *, mixed_windows=False)[source]#

Return the run with the best value for metric.

Best follows the direction of the metric: the highest nse, the lowest rmse, the pbias closest to zero. The metric is read at the gauge of each run, in the window of its rule.

Raises:
  • ValueError – Raised when the group is empty, or when the metric has no declared direction (UnrankedMetricError).

  • MixedWindowsError – Raised when the runs were scored under different rules (station, variable, window or rule version) and mixed_windows is false.

  • KeyError – Raised when no run of the group carries the metric, for instance when no run declares a [metrics] window.

compare(metric, *, mixed_windows=False)[source]#

Compare one metric across the runs of the group, best first.

The metric is read at the gauge of each run, in the window of its rule (metrics). Best follows the direction of the metric.

Parameters:
  • metric (str) – Metric name, as in the columns of metrics.

  • mixed_windows (bool) – Rank runs scored under different rules: another station, variable, window or rule version. Refused by default: such values are not comparable.

Returns:

pandas.DataFrame – sim_id, name, project, solver, station, variable, the window columns and value, best first. Runs without the metric are left out.

Return type:

DataFrame

figure(
name=None,
*,
request=None,
draw=None,
save=None,
dpi=None,
theme=None,
engine=None,
time=None,
data=False,
**options,
)[source]#

Draw the registered runset figure name of this set, ensemble_band for one.

The arguments are those of hydromodpy.results.run.view.Run.figure(). A figure of another subject refuses the set.

Raises:

hydromodpy.core.exceptions.CommandUsageError – If the set was not opened by hydromodpy.open or a project.

filter(**criteria)[source]#

Intersect with another catalog.find(**criteria) call.

Equivalent to catalog.find(...) but restricted to this group’s simulations. Useful for chainable exploration in notebooks.

score(windows=None, metrics=None, months=None, station=None)[source]#

Score the stored series of every run again, on any window, after the fact.

Each run follows score(), and the rows are stacked. The parameters of each run are added as columns, a name that clashes with a score column getting the prefix param_. A run that has no series at station or no seal gives no row, with a warning, and the call is refused when no run gives any.

score_network(output=None, window=None)[source]#

Score the stream-network criterion of every run again, as their trials scored it.

Each run follows score_network(), and the rows are stacked with the parameters of each run as columns. The maps of runs that share mesh, maps, recharge and settings are built once. A run that holds nothing to score gives no row, with a warning, and the call is refused when no run gives any.

show(what, **options)[source]#

Read one thing of this set: table or figure.

sort_by(metric, *, ascending=True, mixed_windows=False)[source]#

Return a new group ordered by the raw value of one metric.

Parameters:
  • metric (str) – Metric name, as in the columns of metrics.

  • ascending (bool) – Sort from low to high when true.

  • mixed_windows (bool) – Order runs scored under different rules. Refused by default.

Returns:

RunSet – New group containing the sorted subset that has the metric.

Return type:

RunSet

table(name)[source]#

Return the table name of the set: parameters, metrics or runs.

parameters is parameters, metrics is metrics and runs is to_dataframe() with every column. Any other name is refused with these three.

timeseries(station=None, variable=None, source=None)[source]#

Return the stored series of every run, stacked, with sim_id and run.

The columns are sim_id, run (the directory name), station_id, variable, source (simulated or observed), time and value. Only timeseries.parquet of each run is read, never a field. station, variable and source keep only the matching rows.

to_csv(path)[source]#

Write to_dataframe() to a CSV file.

to_dataframe(*, params=None, metrics=None)[source]#

Return a wide table joining metadata, parameters, and metrics.

One row per run, keyed by sim_id and named by name, the case of a [sites] project.

Parameters:
  • params (list[str] | None) – Optional whitelist of parameter column names to keep after the pivot.

  • metrics (list[str] | None) – Optional whitelist of metric column names to keep.

to_xarray(variable, *, dim='run')[source]#

Return a lazy stacked xarray.DataArray of variable across sims.

Each per-simulation Zarr store is opened via Catalog.open_zarr() and assembled into an xarray.Dataset by SimulationZarr.to_xarray() (dask-backed). Arrays are concatenated along dim whose coordinate values are the simulation ids. Nothing is read into memory until the caller materializes the array (.compute(), .values, slicing, etc.). Simulations that lack the variable are skipped, a store that cannot be opened with a warning; if none match, an empty xarray.DataArray is returned.

Parameters:
  • variable (str) – Public field name (as declared in the hydromodpy.results.field_registry).

  • dim (str) – Name of the new stacking dimension (default "sim").

worst(metric, *, mixed_windows=False)[source]#

Return the run with the worst value for metric.

The mirror of best(), with the same direction rule and errors.

property count: int[source]#

Number of simulations in the group.

property metrics: DataFrame[source]#

its metrics at the gauge, in the window of its rule.

Columns: sim_id, station and variable of the headline NSE, the window it was computed on (window_start, window_end, n_samples, metric_rule_version), then one column per metric, named by the metric alone (nse, kge, rmse …). The scores come from each run’s manifest.json. A run without a seal, without a window or without a station has empty cells.

Type:

One row per run

property parameters: DataFrame[source]#

Wide parameter table with one row per simulation.

property sim_ids: list[str][source]#

Simulation ids in group order.