hmp.calibrate()#

calibrate(
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,
)[source]#

Run the calibration a configuration declares, or say what it would run.

A path with no base goes to calibrate_a_file and builds no project. A document in memory, or a path read against base, opens a Project and runs Project.calibrate. A configuration that declares [[calibration.phases]] runs each phase in turn. A script that calibrates with parallel above 1 needs the if __name__ == "__main__": guard, because the workers start in spawn.

dry_run=True runs nothing and writes nothing: it returns the CalibrationPlan of calibration_plan(source, *, workspace=None, check=False) -> CalibrationPlan, whose phases, calibration, protocol and plan say 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, whose set, phase, name, resume, force and dry_run steer 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. None builds the default of the machine.

Returns:

CalibrationReport or CalibrationPlan – What the calibration found, or with dry_run what 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:

CalibrationReport | CalibrationPlan

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.

KeywordDefaultCommand-line flagAccepted by
baseNoneno flagevery form
phaseNone--phaseevery form
dry_runFalse--dry-runevery form
preflightTrueno flagevery form
caseNone--caseevery form
methodNoneno flagevery form
max_trialsNoneno flagevery form
seedNoneno flagevery form
save_runsNoneno flagevery form
objectiveNoneno flagevery form
projectNoneno flagevery form
workspaceNone-w --workspaceevery form
resumeFalse--resumeevery form
forceFalseno flagevery form
reportTrue--no-report (the flag turns it off)every form
headlessTrueno flagevery form
environmentNoneno flagevery 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.