Python API#

import hydromodpy as hmp. The functions below are the entry points of the package; the objects they return hold the results. The Command line column names the hmp command that is the twin of each function.

A minimal session#

import hydromodpy as hmp

run = hmp.run("path/to/config.toml").open()   # simulate, then open the Run
head = run.read("head")           # an xarray.DataArray
run.figure("water_budget")   # draw a shipped preset

proj = hmp.open("path/to/project")     # reopen the project later, read only
run = proj["baseline"]                 # one of its runs, by name

How these objects relate, and what Run.read returns for each kind of variable, is on Objects and how they relate. What can be raised, with the HMPY.Exxx codes, is on Exceptions and error codes.

Stability#

This page documents hydromodpy 2.0.1. The public surface is the 52 names of hydromodpy.__all__ (17 functions, 7 classes, 27 exceptions and 1 other names), the classes they return, and the exceptions of this reference. A name outside this reference is internal, except the modules for extensions on the contracts page. So is the hydromodpy.project.api module.

This is a final release: a name listed here changes only under the rules of the versions page. Versions follow semantic versioning with PEP 440 pre-release tags. What each kind of version may change is on the versions page.

Functions#

FunctionWhat it doesReturnsCommand line
hmp.calibrate()Run the calibration a configuration declares, or say what it would run.CalibrationReport, CalibrationPlanhmp calibrate
hmp.check()Check a configuration, a draft or a file, and return every diagnostic it holds.Diagnostichmp check, hmp run
hmp.compare()Compare sealed runs, the first one as the reference.Comparisonhmp diff
hmp.doctor()Say what this machine runs: Python, HydroModPy, the packages and the solvers.DoctorReporthmp doctor
hmp.example()List the examples this build ships, show some, or install one, several or all.ExampleEntry, ExampleEntry, InstallReport, InstallReporthmp example
hmp.export()Export data of a run to files, or deliver what its [[export]] blocks name.PublishedLinehmp export
hmp.open()Open what a path stands for: a project, a run, a session or a workspace.Project, Run, Session, Workspacehmp show, hmp export
hmp.publish()Copy a sealed run, the summary or every sealed run of a project out of the tree.PublishedProjecthmp publish
hmp.replay()Play a sealed run, or a published copy, again, and class the values it computes.RunOutcomehmp replay
hmp.run()Run a simulation or an overview.RunOutcome, PlanDraft, OverviewResulthmp run
hmp.show()Read one thing of a run, a session, a set of runs or a project.dict or DataFrame or Series or DataArray or Figure or Pathhmp show
hmp.spinup()Run a cyclic spin-up, and a production run from its state when asked.SpinupResulthmp spinup
hmp.status()Say where runs and sessions stand, read from the disk and never from the index.RunOutcome, RunOutcome, StatusReporthmp ls
hmp.stop()Ask a running run or calibration session to stop, and return its flag.pathlib.Pathhmp stop
hmp.trash()Move a run or a session to trash/, or bring a trashed one back.list of pathlib.Pathhmp catalog

Objects you get back#

ProjectSetup-once, run-many interface for HydroModPy simulations.33 public members
LabBuild, look at, change and solve a model in memory, one step at a time.14 public members
RunRead one persisted simulation from a HydroModPy catalog.57 public members
RunSetCollection view over several simulations from one catalog.18 public members
SessionOne calibration session, read from its directory.19 public members
CatalogRead-only view of a project index.52 public members
WorkspaceRead-only view of a workspace: its projects and the sealed runs they hold.5 public members
RunOutcomeWhat a finished run says, read from its directory.13 public members
PlanDraftA plan before it is written: its cases, and what is wrong with them.14 public members
OverviewResultWhat an overview drew, and where it sealed it.6 public members
DiagnosticOne finding of a check, at one key of the document.13 public members
CalibrationReportWhat one calibration found, with or without phases.24 public members
CalibrationPlanWhat a calibration declares, with nothing run and nothing written.5 public members
SpinupResultOutcome of a spin-up loop.4 public members
StatusReportThe status of every case of the current plan.6 public members
ComparisonThe tables of one comparison and the data of its figures.3 public members
PublishedLineOne line of published.jsonl: where a copy went, or where a file goes.6 public members
PublishedProjectWhat publish_project wrote, and the runs it left out with the reason.1 public members
ExampleEntryOne cataloged example: what it is, and every file it needs.12 public members
InstallReportWhat one hmp example add actually did.13 public members
DoctorReportThe state of the machine: versions, packages and solver executables.5 public members

The configuration#

hmp.HydroModPyConfig is the whole document of a TOML file as a Pydantic model. In Python you build or change the same keys, so their reference is the TOML one.

ClassTOML sectionSelected byWhat it is
HydroModPyConfigthe whole fileTop-level configuration for HydroModPy.