Lab#
| Member | Kind | What it is |
|---|---|---|
config | property | A frozen copy of the configuration of the project with the changes of the lab. |
project | property | The project the lab works on. A calibration or a spin-up goes through it. |
state | property | The objects the engine holds now. Reading them computes nothing. |
steps | property | One row per step of a run: its status, its last duration in s, what it reads. |
advance | method | Play in memory the steps that are missing or stale, up to to included. |
capture | method | Record the local variables and the return value of each target as it returns. |
close | method | Close the project and remove the scratch folder of the lab. |
force | method | Replace the object name of the state by value until lab.release(name). |
read | method | Read name from the solve of the lab, solving first when the model is stale. |
release | method | Forget the forced value of name, so its step builds it again. |
run | method | Keep the model of the lab as a sealed run of the project, as simulate does. |
set | method | Change the configuration of the lab and return the built steps that became stale. |
solve | method | Solve the model and return one solved run per run of the plan. |
write_config | method | Write 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
toincluded.Without
tothe lab plays the next step. The steps afterrun_solverbelong to a run, solab.runplays them. A draft is refused while a step up totoreads 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": ...}.
- force(name, value)[source]#
Replace the object
nameof the state byvalueuntillab.release(name).The steps after the one that computes it become stale. A run is refused meanwhile.
- read(name, *, time='all')[source]#
Read
namefrom the solve of the lab, solving first when the model is stale.The solver answers from its own files, so nothing is written.
headis the water table of every cell,dischargethe flow that leaves the catchment, andsaturated_thicknessandrelease_fluxhold one value per cell.timeis"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.
- run(name=None, *, until_step=None)[source]#
Keep the model of the lab as a sealed run of the project, as
simulatedoes.The run is the run of the configuration of the lab, so it is refused while an object is forced. When
run_solveris built and the configuration does not keep solver files, the run takes the solve of the lab instead of solving again. It returns whatsimulatereturns.
- 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=Truebuilds 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 ofrun_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.