hmp.calibrate()#
- Command line
hmp calibrate - Returns
CalibrationReport,CalibrationPlan - Defined in
hydromodpy/project/api.py
-
calibrate(
)[source]#source,*,base=None,phase=None,dry_run=False,preflight=True,case=None,method=None,max_trials=None,seed=None,save_runs=None,objective=None,project=None,workspace=None,resume=False,force=False,report=True,headless=True,environment=None,
Run the calibration a configuration declares, or say what it would run.
A path with no
basegoes tocalibrate_a_fileand builds no project. A document in memory, or a path read againstbase, opens aProjectand runsProject.calibrate. A configuration that declares[[calibration.phases]]runs each phase in turn. A script that calibrates withparallelabove 1 needs theif __name__ == "__main__":guard, because the workers start in spawn.dry_run=Trueruns nothing and writes nothing: it returns theCalibrationPlanofcalibration_plan(source, *, workspace=None, check=False) -> CalibrationPlan, whosephases,calibration,protocolandplansay what the configuration declares and what a launch would write.- Parameters:
source (Source) – A calibration TOML file, a document as a mapping or JSON text, a validated
HydroModPyConfig, or a run request, whoseset,phase,name,resume,forceanddry_runsteer the call as the keywords do.base (PathLike | None) – The folder the relative paths of the document are read from, and the project the sessions are written in.
phase (str | None) – Run only the named phase of a staged calibration.
dry_run (bool) – Say what would run, and run nothing.
preflight (bool) – With
dry_run, run first the checks a launch runs, so a file they refuse raises. False reads the declaration only.case (str | None) – Name of the session of a calibration held in memory. A file names its case with
[simulation] name.method (str | None) – The search of a calibration held in memory, over its
[calibration].max_trials (int | None) – The search of a calibration held in memory, over its
[calibration].seed (int | None) – The search of a calibration held in memory, over its
[calibration].save_runs (str | None) – The search of a calibration held in memory, over its
[calibration].objective (str | None) – Name of the objective block to optimize.
project (str | None) – Label of the project in the session record.
workspace (PathLike | None) – The project root a file calibration writes in, over the folder of the file.
resume (bool) – Continue an interrupted session.
force (bool) – Run again a session identical to a completed one.
report (bool) – Write the report of each session once the search is over.
headless (bool) – Draw no figure while the calibration runs.
environment (Environment | None) – The environment of the call.
Nonebuilds the default of the machine.
- Returns:
CalibrationReport or CalibrationPlan – What the calibration found, or with
dry_runwhat it would run.- Raises:
FileNotFoundError – If the calibration TOML path does not exist.
hydromodpy.core.exceptions.ConfigError – If the configuration cannot be read, the preflight refuses it, or an option of a calibration held in memory is given for a file.
hydromodpy.core.exceptions.CalibrationError – If a phase is unknown, or the search fails.
- Return type:
Examples
>>> import hydromodpy as hmp >>> report = hmp.calibrate("calibration.toml") >>> plan = hmp.calibrate("calibration.toml", dry_run=True)
Keyword arguments and command-line flags#
The twin command is hmp calibrate.
| Keyword | Default | Command-line flag | Accepted by |
|---|---|---|---|
base | None | no flag | every form |
phase | None | --phase | every form |
dry_run | False | --dry-run | every form |
preflight | True | no flag | every form |
case | None | --case | every form |
method | None | no flag | every form |
max_trials | None | no flag | every form |
seed | None | no flag | every form |
save_runs | None | no flag | every form |
objective | None | no flag | every form |
project | None | no flag | every form |
workspace | None | -w --workspace | every form |
resume | False | --resume | every form |
force | False | no flag | every form |
report | True | --no-report (the flag turns it off) | every form |
headless | True | no flag | every form |
environment | None | no flag | every form |
Flags of hmp calibrate with no keyword: --list-phases, --expand. To get their effect from Python, build the configuration object with the values you want, or write them in the TOML file.