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#
| Function | What it does | Returns | Command line |
|---|---|---|---|
hmp.calibrate() | Run the calibration a configuration declares, or say what it would run. | CalibrationReport, CalibrationPlan | hmp calibrate |
hmp.check() | Check a configuration, a draft or a file, and return every diagnostic it holds. | Diagnostic | hmp check, hmp run |
hmp.compare() | Compare sealed runs, the first one as the reference. | Comparison | hmp diff |
hmp.doctor() | Say what this machine runs: Python, HydroModPy, the packages and the solvers. | DoctorReport | hmp doctor |
hmp.example() | List the examples this build ships, show some, or install one, several or all. | ExampleEntry, ExampleEntry, InstallReport, InstallReport | hmp example |
hmp.export() | Export data of a run to files, or deliver what its [[export]] blocks name. | PublishedLine | hmp export |
hmp.open() | Open what a path stands for: a project, a run, a session or a workspace. | Project, Run, Session, Workspace | hmp show, hmp export |
hmp.publish() | Copy a sealed run, the summary or every sealed run of a project out of the tree. | PublishedProject | hmp publish |
hmp.replay() | Play a sealed run, or a published copy, again, and class the values it computes. | RunOutcome | hmp replay |
hmp.run() | Run a simulation or an overview. | RunOutcome, PlanDraft, OverviewResult | hmp 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 Path | hmp show |
hmp.spinup() | Run a cyclic spin-up, and a production run from its state when asked. | SpinupResult | hmp spinup |
hmp.status() | Say where runs and sessions stand, read from the disk and never from the index. | RunOutcome, RunOutcome, StatusReport | hmp ls |
hmp.stop() | Ask a running run or calibration session to stop, and return its flag. | pathlib.Path | hmp stop |
hmp.trash() | Move a run or a session to trash/, or bring a trashed one back. | list of pathlib.Path | hmp catalog |
Objects you get back#
ProjectSetup-once, run-many interface for HydroModPy simulations.LabBuild, look at, change and solve a model in memory, one step at a time.RunRead one persisted simulation from a HydroModPy catalog.RunSetCollection view over several simulations from one catalog.SessionOne calibration session, read from its directory.CatalogRead-only view of a project index.WorkspaceRead-only view of a workspace: its projects and the sealed runs they hold.RunOutcomeWhat a finished run says, read from its directory.PlanDraftA plan before it is written: its cases, and what is wrong with them.OverviewResultWhat an overview drew, and where it sealed it.DiagnosticOne finding of a check, at one key of the document.CalibrationReportWhat one calibration found, with or without phases.CalibrationPlanWhat a calibration declares, with nothing run and nothing written.SpinupResultOutcome of a spin-up loop.StatusReportThe status of every case of the current plan.ComparisonThe tables of one comparison and the data of its figures.PublishedLineOne line of published.jsonl: where a copy went, or where a file goes.PublishedProjectWhat publish_project wrote, and the runs it left out with the reason.ExampleEntryOne cataloged example: what it is, and every file it needs.InstallReportWhat one hmp example add actually did.DoctorReportThe state of the machine: versions, packages and solver executables.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.
| Class | TOML section | Selected by | What it is |
|---|---|---|---|
HydroModPyConfig | the whole file | Top-level configuration for HydroModPy. |