You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is best to add the version tag here too (`:1.5.0`), this way the BMI will warn you if the version might be incompatible.
26
+
27
+
Note that the `docker` package for python is required here. Install this with `pip install PyStemmusScope[docker]`.
28
+
Additionally, [Docker](https://docs.docker.com/get-docker/) itself has to be installed.
29
+
30
+
### Local executable file
13
31
The executable file can be downloaded from the STEMMUS_SCOPE repository. More specifically [here](https://github.com/EcoExtreML/STEMMUS_SCOPE/tree/main/run_model_on_snellius/exe).
14
32
15
33
To be able to run this executable, you need a Linux x86 system, along with Matlab Compiler Runtime R2023a. MCR is available [here](https://nl.mathworks.com/products/compiler/matlab-runtime.html).
Alternatively, if the environmental variable `STEMMUS_SCOPE` is configured, the BMI will use this if the ExeFilePath or DockerImage are not set in the configuration file.
25
43
26
-
## Dockerized executable
27
-
STEMMUS_SCOPE also has a Docker image available. This allows you to run the executable file without having to install MCR.
28
-
The Docker image is available at https://ghcr.io/ecoextreml/stemmus_scope
44
+
## Using the BMI
29
45
30
-
To use the Docker image, use the `DockerImage` setting in the configuration file:
A [notebook demonstration the use of the Basic Model Interface](BMI_demo.ipynb) is available.
47
+
For more information on using BMI, see the [CSDMS website](https://csdms.colorado.edu/wiki/BMI).
36
48
37
-
It is best to add the version tag here too (`:1.5.0`), this way the BMI will warn you if the version might be incompatible.
49
+
If you need access to other model variables that are not yet available in the BMI, please raise an issue on the [STEMMUS_SCOPE repository](https://github.com/EcoExtreML/STEMMUS_SCOPE/issues), or leave a comment if an issue is open already.
38
50
39
-
Note that the `docker` package for python is required here. Install this with `pip install PyStemmusScope[docker]`.
40
-
Additionally, [Docker](https://docs.docker.com/get-docker/) itself has to be installed.
51
+
## Developer instructions
52
+
53
+
The Python BMI implemented in this package communicates with the Matlab code through STDIN/STDOUT, or via a socket to the Docker container.
54
+
Over this interface, three commands can be sent to Matlab:
55
+
56
+
1.`initialize "path_to_cfg_file.txt"`
57
+
2.`update`
58
+
3.`finalize`
59
+
60
+
After the initialize and update steps, the Matlab process writes the state of any BMI exposed variables to an hdf5-file in the directory of `OutputPath` as defined in the configuration file.
61
+
62
+
The Python BMI interfaces with this file to allow the variables to be read and set.
63
+
64
+
### Adding/changing exposed variables
65
+
66
+
Step one of changing the exposed variables is to change the Matlab code and generating a new MCR executable (and possibly Docker image).
67
+
The exposed variables are defined in [`STEMMUS_SCOPE/src/STEMMUS_SCOPE_exe.m`](https://github.com/EcoExtreML/STEMMUS_SCOPE/blob/main/src/STEMMUS_SCOPE_exe.m).
68
+
Under the `bmiVarNames` variable.
69
+
Make sure that you add the model variable here, as well as any info on the variable's grid.
70
+
71
+
The available variable names (`MODEL_INPUT_VARNAMES`, `MODEL_OUTPUT_VARNAMES`), their units (`VARNAME_UNITS`), datatypes (`VARNAME_DTYPE`) and grids (`VARNAME_GRID`) are defined in constants at the top of the file `PyStemmusScope/bmi/implementation.py`.
72
+
These have to be updated to reflect the changes in the state file.
73
+
74
+
Lastly you have to update the `get_variable` and `set_variable` functions in `PyStemmusScope/bmi/implementation.py`.
75
+
Here you define how the python code can access them.
76
+
While writing the code you can inspect the state using `model.state`, which allows you to view the full contents of the HDF5 file for easier debugging.
77
+
78
+
When you release a new Docker image that is compatible with the new BMI implementation, you need to update the `compatible_tags` variable of the class `StemmusScopeDocker` in `PyStemmusScope/bmi/docker_process.py`.
0 commit comments