Skip to content

Commit 43c5e60

Browse files
Merge pull request #116 from EcoExtreML/add_rainfall_to_bmi
Add/Edit variables to BMI
2 parents 45b1ae2 + 9f7db94 commit 43c5e60

6 files changed

Lines changed: 37 additions & 8 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.1
1+
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.2
22

33
LABEL maintainer="Bart Schilperoort <b.schilperoort@esciencecenter.nl>"
44
LABEL org.opencontainers.image.source="https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing"

PyStemmusScope/bmi/docker_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class StemmusScopeDocker:
8383
"""Communicate with a STEMMUS_SCOPE Docker container."""
8484

8585
# Default image, can be overridden with config:
86-
compatible_tags = ("1.6.1",)
86+
compatible_tags = ("1.6.2",)
8787

8888
_process_ready_phrase = b"Select BMI mode:"
8989
_process_finalized_phrase = b"Finished clean up."

PyStemmusScope/bmi/local_process.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self, cfg_file: str) -> None:
8686
"""Initialize the process."""
8787
self.cfg_file = cfg_file
8888
config = read_config(cfg_file)
89+
self.sleep_duration = int(config.get("SleepDuration", 10))
8990

9091
exe_file = find_exe(config)
9192
args = [exe_file, cfg_file, "bmi"]
@@ -153,7 +154,7 @@ def finalize(self) -> None:
153154
"""Finalize the model."""
154155
self.process = alive_process(self.process)
155156
self.process.stdin.write(b"finalize\n") # type: ignore
156-
sleep(10)
157+
sleep(self.sleep_duration)
157158
if self.process.poll() != 0:
158159
try:
159160
self.process.terminate()

PyStemmusScope/bmi/variable_reference.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,43 @@ class BmiVariable:
2828
keys=["fluxes", "Resp"],
2929
),
3030
BmiVariable(
31-
name="evaporation_total",
31+
name="precipitation",
32+
dtype="float64",
33+
input=True,
34+
output=False,
35+
units="cm s-1",
36+
grid=0,
37+
keys=["ForcingData", "Precip_msr"],
38+
all_timesteps=True,
39+
),
40+
BmiVariable(
41+
name="applied_infiltration",
3242
dtype="float64",
3343
input=False,
3444
output=True,
3545
units="cm s-1",
3646
grid=0,
37-
keys=["EVAP"],
47+
keys=["ForcingData", "applied_inf"],
3848
all_timesteps=True,
3949
),
50+
BmiVariable(
51+
name="soil_evaporation",
52+
dtype="float64",
53+
input=False,
54+
output=True,
55+
units="cm s-1",
56+
grid=0,
57+
keys=["Evap"],
58+
),
59+
BmiVariable(
60+
name="transpiration",
61+
dtype="float64",
62+
input=False,
63+
output=True,
64+
units="cm s-1",
65+
grid=0,
66+
keys=["Trap"],
67+
),
4068
# soil vars:
4169
BmiVariable(
4270
name="soil_temperature",

docs/bmi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ To use the Docker image, use the `DockerImage` setting in the configuration file
1919
```sh
2020
WorkDir=/home/username/tmp/stemmus_scope
2121
...
22-
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
22+
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2
2323
```
2424

25-
It is best to add the version tag here too (`:1.6.1`), this way the BMI will warn you if the version might be incompatible.
25+
It is best to add the version tag here too (`:1.6.2`), this way the BMI will warn you if the version might be incompatible.
2626

2727
Note that the `docker` package for python is required here. Install this with `pip install PyStemmusScope[docker]`.
2828
Additionally, [Docker](https://docs.docker.com/get-docker/) itself has to be installed.

tests/test_data/config_file_docker.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ StartTime=1996-01-01T00:00
1313
EndTime=1996-01-01T02:00
1414
InputPath=
1515
OutputPath=
16-
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
16+
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2

0 commit comments

Comments
 (0)