RunSet#
| Member | Kind | What it is |
|---|---|---|
count | property | Number of simulations in the group. |
metrics | property | One row per run: its metrics at the gauge, in the window of its rule. |
parameters | property | Wide parameter table with one row per simulation. |
sim_ids | property | Simulation ids in group order. |
best | method | Return the run with the best value for metric. |
compare | method | Compare one metric across the runs of the group, best first. |
figure | method | Draw the registered runset figure *name* of this set, ensemble_band for one. |
filter | method | Intersect with another catalog.find(**criteria) call. |
score | method | Score the stored series of every run again, on any window, after the fact. |
score_network | method | Score the stream-network criterion of every run again, as their trials scored it. |
show | method | Read one thing of this set: table or figure. |
sort_by | method | Return a new group ordered by the raw value of one metric. |
table | method | Return the table *name* of the set: parameters, metrics or runs. |
timeseries | method | Return the stored series of every run, stacked, with sim_id and run. |
to_csv | method | Write to_dataframe() to a CSV file. |
to_dataframe | method | Return a wide table joining metadata, parameters, and metrics. |
to_xarray | method | Return a lazy stacked xarray.DataArray of variable across sims. |
worst | method | Return the run with the worst value for metric. |
- class RunSet(sim_ids, catalog, *, render=None)[source]#
Collection view over several simulations from one catalog.
RunSetis returned by catalog queries that match more than one run. It behaves like a lightweight list ofRunobjects 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:
catalog (Catalog) – Catalog used to resolve ids into
Runobjects 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
figureis refused when there is none.
Examples
>>> group = catalog.find(project="my_project") >>> group.count >>> group.best("nse").summary()
See also
hydromodpy.results.run.view.RunPer-simulation view yielded during iteration.
hydromodpy.results.catalog.facade.CatalogCatalog 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 lowestrmse, thepbiasclosest 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_windowsis 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:
- Returns:
pandas.DataFrame –
sim_id,name,project,solver,station,variable, the window columns andvalue, best first. Runs without the metric are left out.- Return type:
DataFrame
-
figure(
)[source]#name=None,*,request=None,draw=None,save=None,dpi=None,theme=None,engine=None,time=None,data=False,**options,
Draw the registered
runsetfigure name of this set,ensemble_bandfor 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.openor 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 prefixparam_. A run that has no series atstationor 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.
- sort_by(metric, *, ascending=True, mixed_windows=False)[source]#
Return a new group ordered by the raw value of one metric.
- Parameters:
- Returns:
RunSet – New group containing the sorted subset that has the metric.
- Return type:
- table(name)[source]#
Return the table name of the set:
parameters,metricsorruns.parametersisparameters,metricsismetricsandrunsisto_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_idandrun.The columns are
sim_id,run(the directory name),station_id,variable,source(simulated or observed),timeandvalue. Onlytimeseries.parquetof each run is read, never a field.station,variableandsourcekeep only the matching rows.
- to_dataframe(*, params=None, metrics=None)[source]#
Return a wide table joining metadata, parameters, and metrics.
One row per run, keyed by
sim_idand named byname, the case of a[sites]project.
- to_xarray(variable, *, dim='run')[source]#
Return a lazy stacked
xarray.DataArrayofvariableacross sims.Each per-simulation Zarr store is opened via
Catalog.open_zarr()and assembled into anxarray.DatasetbySimulationZarr.to_xarray()(dask-backed). Arrays are concatenated alongdimwhose 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 emptyxarray.DataArrayis returned.
- 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 metrics: DataFrame[source]#
its metrics at the gauge, in the window of its rule.
Columns:
sim_id,stationandvariableof 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’smanifest.json. A run without a seal, without a window or without a station has empty cells.- Type:
One row per run