Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/Edit variables to BMI #116

Merged
merged 21 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.1
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.2

LABEL maintainer="Bart Schilperoort <[email protected]>"
LABEL org.opencontainers.image.source = "https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing"
Expand Down
2 changes: 1 addition & 1 deletion PyStemmusScope/bmi/docker_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class StemmusScopeDocker:
"""Communicate with a STEMMUS_SCOPE Docker container."""

# Default image, can be overridden with config:
compatible_tags = ("1.6.1",)
compatible_tags = ("1.6.2",)

_process_ready_phrase = b"Select BMI mode:"
_process_finalized_phrase = b"Finished clean up."
Expand Down
3 changes: 2 additions & 1 deletion PyStemmusScope/bmi/local_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, cfg_file: str) -> None:
"""Initialize the process."""
self.cfg_file = cfg_file
config = read_config(cfg_file)
self.sleep_duration = int(config.get("SleepDuration", 10))

exe_file = find_exe(config)
args = [exe_file, cfg_file, "bmi"]
Expand Down Expand Up @@ -153,7 +154,7 @@ def finalize(self) -> None:
"""Finalize the model."""
self.process = alive_process(self.process)
self.process.stdin.write(b"finalize\n") # type: ignore
sleep(10)
sleep(self.sleep_duration)
if self.process.poll() != 0:
try:
self.process.terminate()
Expand Down
32 changes: 30 additions & 2 deletions PyStemmusScope/bmi/variable_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,43 @@ class BmiVariable:
keys=["fluxes", "Resp"],
),
BmiVariable(
name="evaporation_total",
name="precipitation",
dtype="float64",
input=True,
output=False,
units="cm s-1",
grid=0,
keys=["ForcingData", "Precip_msr"],
all_timesteps=True,
),
BmiVariable(
name="applied_infiltration",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["EVAP"],
keys=["ForcingData", "applied_inf"],
all_timesteps=True,
),
BmiVariable(
name="soil_evaporation",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["Evap"],
),
BmiVariable(
name="transpiration",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["Trap"],
),
# soil vars:
BmiVariable(
name="soil_temperature",
Expand Down
4 changes: 2 additions & 2 deletions docs/bmi.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ To use the Docker image, use the `DockerImage` setting in the configuration file
```sh
WorkDir=/home/username/tmp/stemmus_scope
...
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2
```

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.
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.

Note that the `docker` package for python is required here. Install this with `pip install PyStemmusScope[docker]`.
Additionally, [Docker](https://docs.docker.com/get-docker/) itself has to be installed.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/config_file_docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ StartTime=1996-01-01T00:00
EndTime=1996-01-01T02:00
InputPath=
OutputPath=
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2
Loading