Lab#

MemberKindWhat it is
configpropertyA frozen copy of the configuration of the project with the changes of the lab.
projectpropertyThe project the lab works on. A calibration or a spin-up goes through it.
statepropertyThe objects the engine holds now. Reading them computes nothing.
stepspropertyOne row per step of a run: its status, its last duration in s, what it reads.
advancemethodPlay in memory the steps that are missing or stale, up to to included.
capturemethodRecord the local variables and the return value of each target as it returns.
closemethodClose the project and remove the scratch folder of the lab.
forcemethodReplace the object name of the state by value until lab.release(name).
readmethodRead name from the solve of the lab, solving first when the model is stale.
releasemethodForget the forced value of name, so its step builds it again.
runmethodKeep the model of the lab as a sealed run of the project, as simulate does.
setmethodChange the configuration of the lab and return the built steps that became stale.
solvemethodSolve the model and return one solved run per run of the plan.
write_configmethodWrite the configuration of the lab, its changes applied, as a TOML file.
class Lab(source, *, base=None, environment=None)[source]#

Build, look at, change and solve a model in memory, one step at a time.

advance(to=None)[source]#

Play in memory the steps that are missing or stale, up to to included.

Without to the lab plays the next step. The steps after run_solver belong to a run, so lab.run plays them. A draft is refused while a step up to to reads a section it lacks.

capture(*targets)[source]#

Record the local variables and the return value of each target as it returns.

A target is "path/file.py:function" or "path/file.py:Class.method", the file matched by the end of its path. The block gives a dict that maps each target to the list of its calls, each call {"locals": ..., "returned": ...}.

close()[source]#

Close the project and remove the scratch folder of the lab.

force(name, value)[source]#

Replace the object name of the state by value until lab.release(name).

The steps after the one that computes it become stale. A run is refused meanwhile.

read(name, *, time='all')[source]#

Read name from the solve of the lab, solving first when the model is stale.

The solver answers from its own files, so nothing is written. head is the water table of every cell, discharge the flow that leaves the catchment, and saturated_thickness and release_flux hold one value per cell. time is "all", "first", "last" or the index of a period. A name the backend cannot say is refused with its reason. A run reads every stored variable.

release(name)[source]#

Forget the forced value of name, so its step builds it again.

run(name=None, *, until_step=None)[source]#

Keep the model of the lab as a sealed run of the project, as simulate does.

The run is the run of the configuration of the lab, so it is refused while an object is forced. When run_solver is built and the configuration does not keep solver files, the run takes the solve of the lab instead of solving again. It returns what simulate returns.

set(changes=None, /, **named)[source]#

Change the configuration of the lab and return the built steps that became stale.

A key is a name of hmp config targets (K=5e-5), a dotted path of the TOML ({"flow.param.K.field.value": 5e-5}) or a whole section (data={...}). The new configuration is checked at once. Changes that bring the configuration back to the file are forgotten, so a run seals none.

solve(built=None, *, build_only=False)[source]#

Solve the model and return one solved run per run of the plan.

build_only=True builds each flow run of the plan without solving it, and keeps nothing in the state. lab.solve(built) then solves these runs and keeps them as the result of run_solver. That path plays no transport run.

write_config(path)[source]#

Write the configuration of the lab, its changes applied, as a TOML file.

property config: HydroModPyConfig[source]#

A frozen copy of the configuration of the project with the changes of the lab.

property project: Project[source]#

The project the lab works on. A calibration or a spin-up goes through it.

property state: LabState[source]#

The objects the engine holds now. Reading them computes nothing.

property steps: pd.DataFrame[source]#

its status, its last duration in s, what it reads.

Type:

One row per step of a run