EBFM 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ebfm-0.1.0/AUTHORS.txt +6 -0
- ebfm-0.1.0/PKG-INFO +311 -0
- ebfm-0.1.0/README.md +289 -0
- ebfm-0.1.0/pyproject.toml +43 -0
- ebfm-0.1.0/setup.cfg +4 -0
- ebfm-0.1.0/src/EBFM.egg-info/PKG-INFO +311 -0
- ebfm-0.1.0/src/EBFM.egg-info/SOURCES.txt +34 -0
- ebfm-0.1.0/src/EBFM.egg-info/dependency_links.txt +1 -0
- ebfm-0.1.0/src/EBFM.egg-info/entry_points.txt +2 -0
- ebfm-0.1.0/src/EBFM.egg-info/requires.txt +15 -0
- ebfm-0.1.0/src/EBFM.egg-info/top_level.txt +7 -0
- ebfm-0.1.0/src/coupler.py +56 -0
- ebfm-0.1.0/src/coupling.py +418 -0
- ebfm-0.1.0/src/ebfm/FINAL_create_restart_file.py +79 -0
- ebfm-0.1.0/src/ebfm/INIT.py +504 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM.py +150 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_GHF.py +29 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_LHF.py +63 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_LWin.py +42 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_LWout.py +23 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_SHF.py +44 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_SWin.py +118 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_SWout.py +61 -0
- ebfm-0.1.0/src/ebfm/LOOP_EBM_insolation.py +152 -0
- ebfm-0.1.0/src/ebfm/LOOP_SNOW.py +704 -0
- ebfm-0.1.0/src/ebfm/LOOP_climate_forcing.py +150 -0
- ebfm-0.1.0/src/ebfm/LOOP_general_functions.py +35 -0
- ebfm-0.1.0/src/ebfm/LOOP_mass_balance.py +38 -0
- ebfm-0.1.0/src/ebfm/LOOP_write_to_file.py +236 -0
- ebfm-0.1.0/src/ebfm/__init__.py +21 -0
- ebfm-0.1.0/src/ebfm/grid.py +11 -0
- ebfm-0.1.0/src/elmer/mesh.py +64 -0
- ebfm-0.1.0/src/elmer/parser.py +116 -0
- ebfm-0.1.0/src/main.py +288 -0
- ebfm-0.1.0/src/reader.py +224 -0
- ebfm-0.1.0/src/utils.py +49 -0
ebfm-0.1.0/AUTHORS.txt
ADDED
ebfm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: EBFM
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Author: EBFM Authors
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: AUTHORS.txt
|
|
8
|
+
Requires-Dist: mpi4py>=4.1
|
|
9
|
+
Requires-Dist: mypy>=1.0
|
|
10
|
+
Requires-Dist: netCDF4>=1.7
|
|
11
|
+
Requires-Dist: numpy>=2.0
|
|
12
|
+
Requires-Dist: pandas>=2.0
|
|
13
|
+
Requires-Dist: pandas-stubs>=2.0
|
|
14
|
+
Requires-Dist: pathlib
|
|
15
|
+
Requires-Dist: pyproj
|
|
16
|
+
Requires-Dist: scipy
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pre-commit>=4.0; extra == "dev"
|
|
19
|
+
Provides-Extra: cpl
|
|
20
|
+
Requires-Dist: yac>=3.8; extra == "cpl"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
<!--
|
|
24
|
+
SPDX-FileCopyrightText: 2025 EBFM Authors
|
|
25
|
+
|
|
26
|
+
SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
+
-->
|
|
28
|
+
|
|
29
|
+
# Energy balance and firn model (EBFM)
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/p/ebfm/) 
|
|
32
|
+
|
|
33
|
+
This repository provides a Python implementation of an energy balance and firn model (EBFM).
|
|
34
|
+
|
|
35
|
+
Using YAC, this model can be coupled to other models.
|
|
36
|
+
|
|
37
|
+
## Basic installation
|
|
38
|
+
|
|
39
|
+
### Create virtual environment
|
|
40
|
+
|
|
41
|
+
You can use an arbitrary location to create your virtual environment.
|
|
42
|
+
A common choice is `.venv`. In the following, we will use `$VENV` as a placeholder and the path to the virtual environment `.venv` should be set as follows:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
export VENV=/path/to/your/environment/.venv
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If you do not already have a virtual environment, you can create one using the following commands, which will additionally install the necessary dependencies specified in `pyproject.toml`:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
python3 -m venv $VENV
|
|
52
|
+
source $VENV/bin/activate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Check if your virtual environment is activated. You should see the name within parentheses just before your command prompt, in this case it should say `(.venv)`.
|
|
56
|
+
|
|
57
|
+
If you want to know more about virtual environments, please refer to the [Python documentation](https://docs.python.org/3/library/venv.html). \
|
|
58
|
+
If you intend to develop EBFM, please take a look at the [developer notes](https://github.com/wardvp/EBFM/edit/matthias-ibach-patch-1/README.md?pr=%2Fwardvp%2FEBFM%2Fpull%2F23#developer-notes) further down in the `README`.
|
|
59
|
+
|
|
60
|
+
### Install EBFM
|
|
61
|
+
|
|
62
|
+
You can then install EBFM directly into you virtual environment by running the following command:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
pip3 install EBFM
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This will install the basic version of EBFM without coupling.
|
|
69
|
+
|
|
70
|
+
### Checking your installation
|
|
71
|
+
|
|
72
|
+
Please check your installation by running `ebfm --help` to print the help message and `ebfm --version` to print the installed version.
|
|
73
|
+
|
|
74
|
+
## Installation with coupling features
|
|
75
|
+
|
|
76
|
+
Before installing EBFM with coupling features, you must install YAC with the Python bindings. Similar to the instructions above, we will use a virtual environment to install all required dependencies.
|
|
77
|
+
During YAC’s configuration step, set the installation prefix to your virtual environment and enable Python bindings (`--prefix=$VENV` `--enable-python-bindings`).
|
|
78
|
+
Make sure to do this *after* creating your virtual environment.
|
|
79
|
+
|
|
80
|
+
The procedure should look similar to below:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
python3 -m venv $VENV
|
|
84
|
+
# configure and install YAC with --prefix=$VENV and --enable-python-bindings
|
|
85
|
+
source $VENV/bin/activate
|
|
86
|
+
pip3 install EBFM[cpl]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Adding `[cpl]` will make sure that additional dependencies needed for coupling, such as `yac`, are present in your virtual environment.
|
|
90
|
+
|
|
91
|
+
If you see any errors during the process, please make sure that your virtual environment is activated. If this is the case, you should see the name within parentheses just before your command prompt, in this case it should say `(.venv)`.
|
|
92
|
+
|
|
93
|
+
If during the installation of EBFM it appears that `yac` is missing, please double-check with `pip3 freeze` that the package has been installed properly. For detailed instructions on how to install YAC properly and guidance for troubleshooting, see the YAC documentation on [Python bindings](https://yac.gitlab-pages.dkrz.de/YAC-dev/d7/d9e/pythonbindings.html).
|
|
94
|
+
|
|
95
|
+
## Running EBFM
|
|
96
|
+
|
|
97
|
+
After installation, a basic, uncoupled simulation can be run with the following command, provided you cloned this repository:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
ebfm --matlab-mesh examples/dem_and_mask.mat
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Mesh data
|
|
104
|
+
|
|
105
|
+
The arguments `--matlab-mesh`, `--elmer-mesh`, and `--netcdf-mesh` allow to provide different kinds of mesh data.
|
|
106
|
+
EBFM supports the following formats:
|
|
107
|
+
|
|
108
|
+
* MATLAB Mesh: An example is given in `examples/dem_and_mask.mat`. This mesh
|
|
109
|
+
file provides x-y coordinates and elevation data. Please use the argument
|
|
110
|
+
`--matlab-mesh /path/to/your/mesh.mat`.
|
|
111
|
+
|
|
112
|
+
Usage example:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
ebfm --matlab-mesh examples/dem_and_mask.mat
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
* Elmer Mesh: An Elmer mesh file with x-y coordinates of mesh points and
|
|
119
|
+
elevation data stored in the z-component. Please use the argument
|
|
120
|
+
`--elmer-mesh /path/to/your/elmer/MESH`.
|
|
121
|
+
|
|
122
|
+
Usage example:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
ebfm --elmer-mesh examples/DEM
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
* Elmer Mesh with Elevation data from NetCDF: The Elmer mesh file provides x-y
|
|
129
|
+
coordinate. An additioal NetCDF file is given to provide elevation data for
|
|
130
|
+
these x-y coordinates. Please use the arguments `--elmer-mesh /path/to/your/elmer/MESH`
|
|
131
|
+
and `--netcdf-mesh /path/to/your/elevation.nc`
|
|
132
|
+
|
|
133
|
+
Usage example:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
ebfm --elmer-mesh examples/MESH --netcdf-mesh examples/BedMachineGreenland-v5.nc
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Note that an Elmer mesh must be provided in a directory following the structure:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
path/to/your/elmer/MESH/
|
|
143
|
+
├── mesh.boundary
|
|
144
|
+
├── mesh.elements
|
|
145
|
+
├── mesh.header
|
|
146
|
+
└── mesh.nodes
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The option `--is-partitioned-elmer-mesh` will tell EBFM that the provided Elmer
|
|
150
|
+
mesh is a partitioned mesh. A partitioned mesh file follows the structure:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
path/to/your/elmer/MESH
|
|
154
|
+
├── mesh.boundary
|
|
155
|
+
├── mesh.elements
|
|
156
|
+
├── mesh.header
|
|
157
|
+
├── mesh.nodes
|
|
158
|
+
└── partitioning.128
|
|
159
|
+
├── part.1.boundary
|
|
160
|
+
├── part.1.elements
|
|
161
|
+
├── part.1.header
|
|
162
|
+
├── part.1.nodes
|
|
163
|
+
...
|
|
164
|
+
├── part.128.boundary
|
|
165
|
+
├── part.128.elements
|
|
166
|
+
├── part.128.header
|
|
167
|
+
└── part.128.nodes
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Usage example for partitioned mesh:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
ebfm --elmer-mesh examples/MESH/partitioning.128/ --netcdf-mesh examples/BedMachineGreenland-v5.nc --is-partitioned-elmer-mesh --use-part 42
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Coupled simulation
|
|
177
|
+
|
|
178
|
+
The EBFM code allows coupling to other simulation codes. The following arguments
|
|
179
|
+
allow to configure the coupling:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
ebfm ...
|
|
183
|
+
--couple-to-elmer-ice
|
|
184
|
+
--couple-to-icon-atmo
|
|
185
|
+
--coupler-config /path/to/coupling/config.yaml
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Note that the coupling uses the Python bindings of YAC. Additionally, EBFM must
|
|
189
|
+
be run in a MPMD (multiple process multiple data) run.
|
|
190
|
+
Follow the install instructions from above and run the example command for a coupled simulation with Elmer/Ice and ICON:
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
mpirun -np 1 ebfm \
|
|
194
|
+
--elmer-mesh $MESHES/MESH/partitioning.128/ \
|
|
195
|
+
--netcdf-mesh $DATA/BedMachineGreenland-v5.nc \
|
|
196
|
+
--is-partitioned-elmer-mesh --use-part 1 \
|
|
197
|
+
--coupler-config $CPL_CONFIG --couple-to-elmer --couple-to-icon \
|
|
198
|
+
: \
|
|
199
|
+
-np 1 $ELMER_ROOT/src/elmer_dummy_f.x $MESHES/MESH/partitioning.128 1 $CPL_CONFIG \
|
|
200
|
+
: \
|
|
201
|
+
-np 1 $ICON_ROOT/src/icon_dummy.x $MESHES/icon_grid_0054_R02B08_G.nc $DATA/mbe3064_atm_elmer_monmean_1979.nc $DATA/varlist_elmerfile
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Be aware that the command above requires setting a few environment variables.
|
|
205
|
+
Assuming your project is structured following [this repository](https://gitlab.dkrz.de/k202215/ebfm_dummy),
|
|
206
|
+
the following settings should help getting started:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
export EBFM_DUMMY_REPO=/path/to/k202215/ebfm_dummy
|
|
210
|
+
export EBFM_REPO=/path/to/this/repo
|
|
211
|
+
|
|
212
|
+
export CPL_CONFIG=$EBFM_DUMMY_REPO/config/coupling.yaml
|
|
213
|
+
export MESHES=$EBFM_DUMMY_REPO/mesh
|
|
214
|
+
export DATA=$EBFM_DUMMY_REPO/data
|
|
215
|
+
|
|
216
|
+
export EBFM_ROOT=$EBFM_REPO
|
|
217
|
+
export ELMER_ROOT=$EBFM_DUMMY_REPO/dummies/ELMER
|
|
218
|
+
export ICON_ROOT=$EBFM_DUMMY_REPO/dummies/ICON
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Depending on the binaries that you want to use `$ELMER_ROOT` and/or `$ICON_ROOT`
|
|
222
|
+
may be set to point to the non-dummy versions of the codes.
|
|
223
|
+
|
|
224
|
+
## Troubleshooting
|
|
225
|
+
|
|
226
|
+
### `libnetcdf.so` not found at runtime
|
|
227
|
+
|
|
228
|
+
*Problem:* `./icon_dummy.x: error while loading shared libraries: libnetcdf.so.15: cannot open shared object file: No such file or directory`
|
|
229
|
+
*Solution:* Try rebuilding `icon_dummy.x`
|
|
230
|
+
`
|
|
231
|
+
### `libyaxt_c.so` not found at runtime
|
|
232
|
+
|
|
233
|
+
*Problem:* `./icon_dummy.x: error while loading shared libraries: libyaxt_c.so.1: cannot open shared object file: No such file or directory`
|
|
234
|
+
|
|
235
|
+
*Solution:* `export LD_LIBRARY_PATH='$YAXT_INSTALL_DIR/lib/'
|
|
236
|
+
|
|
237
|
+
### `#include <proj.h>` not found when building the Elmer dummy
|
|
238
|
+
|
|
239
|
+
*Problem:*
|
|
240
|
+
```sh
|
|
241
|
+
...
|
|
242
|
+
elmer_grid.c:11:10: fatal error: proj.h: No such file or directory
|
|
243
|
+
11 | #include <proj.h>
|
|
244
|
+
| ^~~~
|
|
245
|
+
compilation terminated.
|
|
246
|
+
make: *** [Makefile:48: elmer_grid.o] Error 1
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
*Solution:* `sudo apt-get install libproj-dev`
|
|
250
|
+
|
|
251
|
+
## Developer notes
|
|
252
|
+
|
|
253
|
+
### Optional dependencies `[dev]`
|
|
254
|
+
|
|
255
|
+
Please install the package with the optional dependencies `[dev]` if you are developing (this will automatically
|
|
256
|
+
install `pre-commit`).
|
|
257
|
+
|
|
258
|
+
To concatenate multiple optional dependencies, please run
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
pip3 install EBFM[dev,cpl]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### pre-commit
|
|
265
|
+
|
|
266
|
+
This project uses pre-commit hooks for some tasks described in detail below. To setup pre-commit please do the following:
|
|
267
|
+
|
|
268
|
+
```sh
|
|
269
|
+
pipx install pre-commit
|
|
270
|
+
pre-commit install
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Alternative:** If you are already working in an virtual environment, you can also use `pip3 install pre-commit` instead of `pipx`. Refer to the [documentation of `pipx`](https://pipx.pypa.io/stable/#overview-what-is-pipx) for further information.
|
|
274
|
+
|
|
275
|
+
As soon as pre-commit is set up, you will not be able to commit if any of the checks fails. With the help of the logging output it should usually be possible to fix the problem.
|
|
276
|
+
|
|
277
|
+
Note: You can bypass this check with `--no-verify`. Please note that the CI will also run pre-commit and fail if there are problems in any of the checks. Therefore, it is recommended to use the pre-commit hooks locally before pushing code to this repository and only bypass them if there is a good reason.
|
|
278
|
+
|
|
279
|
+
### Copyright and licensing
|
|
280
|
+
|
|
281
|
+
This project uses [REUSE](https://reuse.software/) to track information regarding copyright and licensing. Therefore, all files in this repository are required to provide the corresponding information. Please refer to the documentation of REUSE for details.
|
|
282
|
+
|
|
283
|
+
You can use pre-commit to automatically check if all files in the repository provide the necessary information:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
pre-commit run reuse --all-files
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Code formatting
|
|
290
|
+
|
|
291
|
+
Automated checks for PEP8 compiance are implemented following [^1] with some modifications. You can use pre-commit hooks to automatically format your code with black:
|
|
292
|
+
|
|
293
|
+
```sh
|
|
294
|
+
pre-commit run black --all-files
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
With flake8 you can check whether your code follows all relevant formatting rules:
|
|
298
|
+
|
|
299
|
+
```sh
|
|
300
|
+
pre-commit run flake8 --all-files
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Please note that black might not be able to automatically fix all problems and therefore flake8 might fail even if you have run black before. In this case, you will have to manually fix the remaining problems.
|
|
304
|
+
|
|
305
|
+
### Further hints
|
|
306
|
+
|
|
307
|
+
* Please consider installing EBFM via `pip3 --editable .` if you are developing the package.
|
|
308
|
+
|
|
309
|
+
----
|
|
310
|
+
|
|
311
|
+
[^1]: https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/
|
ebfm-0.1.0/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SPDX-FileCopyrightText: 2025 EBFM Authors
|
|
3
|
+
|
|
4
|
+
SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
# Energy balance and firn model (EBFM)
|
|
8
|
+
|
|
9
|
+
[](https://pypi.org/p/ebfm/) 
|
|
10
|
+
|
|
11
|
+
This repository provides a Python implementation of an energy balance and firn model (EBFM).
|
|
12
|
+
|
|
13
|
+
Using YAC, this model can be coupled to other models.
|
|
14
|
+
|
|
15
|
+
## Basic installation
|
|
16
|
+
|
|
17
|
+
### Create virtual environment
|
|
18
|
+
|
|
19
|
+
You can use an arbitrary location to create your virtual environment.
|
|
20
|
+
A common choice is `.venv`. In the following, we will use `$VENV` as a placeholder and the path to the virtual environment `.venv` should be set as follows:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
export VENV=/path/to/your/environment/.venv
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If you do not already have a virtual environment, you can create one using the following commands, which will additionally install the necessary dependencies specified in `pyproject.toml`:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
python3 -m venv $VENV
|
|
30
|
+
source $VENV/bin/activate
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Check if your virtual environment is activated. You should see the name within parentheses just before your command prompt, in this case it should say `(.venv)`.
|
|
34
|
+
|
|
35
|
+
If you want to know more about virtual environments, please refer to the [Python documentation](https://docs.python.org/3/library/venv.html). \
|
|
36
|
+
If you intend to develop EBFM, please take a look at the [developer notes](https://github.com/wardvp/EBFM/edit/matthias-ibach-patch-1/README.md?pr=%2Fwardvp%2FEBFM%2Fpull%2F23#developer-notes) further down in the `README`.
|
|
37
|
+
|
|
38
|
+
### Install EBFM
|
|
39
|
+
|
|
40
|
+
You can then install EBFM directly into you virtual environment by running the following command:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pip3 install EBFM
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This will install the basic version of EBFM without coupling.
|
|
47
|
+
|
|
48
|
+
### Checking your installation
|
|
49
|
+
|
|
50
|
+
Please check your installation by running `ebfm --help` to print the help message and `ebfm --version` to print the installed version.
|
|
51
|
+
|
|
52
|
+
## Installation with coupling features
|
|
53
|
+
|
|
54
|
+
Before installing EBFM with coupling features, you must install YAC with the Python bindings. Similar to the instructions above, we will use a virtual environment to install all required dependencies.
|
|
55
|
+
During YAC’s configuration step, set the installation prefix to your virtual environment and enable Python bindings (`--prefix=$VENV` `--enable-python-bindings`).
|
|
56
|
+
Make sure to do this *after* creating your virtual environment.
|
|
57
|
+
|
|
58
|
+
The procedure should look similar to below:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
python3 -m venv $VENV
|
|
62
|
+
# configure and install YAC with --prefix=$VENV and --enable-python-bindings
|
|
63
|
+
source $VENV/bin/activate
|
|
64
|
+
pip3 install EBFM[cpl]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Adding `[cpl]` will make sure that additional dependencies needed for coupling, such as `yac`, are present in your virtual environment.
|
|
68
|
+
|
|
69
|
+
If you see any errors during the process, please make sure that your virtual environment is activated. If this is the case, you should see the name within parentheses just before your command prompt, in this case it should say `(.venv)`.
|
|
70
|
+
|
|
71
|
+
If during the installation of EBFM it appears that `yac` is missing, please double-check with `pip3 freeze` that the package has been installed properly. For detailed instructions on how to install YAC properly and guidance for troubleshooting, see the YAC documentation on [Python bindings](https://yac.gitlab-pages.dkrz.de/YAC-dev/d7/d9e/pythonbindings.html).
|
|
72
|
+
|
|
73
|
+
## Running EBFM
|
|
74
|
+
|
|
75
|
+
After installation, a basic, uncoupled simulation can be run with the following command, provided you cloned this repository:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
ebfm --matlab-mesh examples/dem_and_mask.mat
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Mesh data
|
|
82
|
+
|
|
83
|
+
The arguments `--matlab-mesh`, `--elmer-mesh`, and `--netcdf-mesh` allow to provide different kinds of mesh data.
|
|
84
|
+
EBFM supports the following formats:
|
|
85
|
+
|
|
86
|
+
* MATLAB Mesh: An example is given in `examples/dem_and_mask.mat`. This mesh
|
|
87
|
+
file provides x-y coordinates and elevation data. Please use the argument
|
|
88
|
+
`--matlab-mesh /path/to/your/mesh.mat`.
|
|
89
|
+
|
|
90
|
+
Usage example:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
ebfm --matlab-mesh examples/dem_and_mask.mat
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
* Elmer Mesh: An Elmer mesh file with x-y coordinates of mesh points and
|
|
97
|
+
elevation data stored in the z-component. Please use the argument
|
|
98
|
+
`--elmer-mesh /path/to/your/elmer/MESH`.
|
|
99
|
+
|
|
100
|
+
Usage example:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
ebfm --elmer-mesh examples/DEM
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
* Elmer Mesh with Elevation data from NetCDF: The Elmer mesh file provides x-y
|
|
107
|
+
coordinate. An additioal NetCDF file is given to provide elevation data for
|
|
108
|
+
these x-y coordinates. Please use the arguments `--elmer-mesh /path/to/your/elmer/MESH`
|
|
109
|
+
and `--netcdf-mesh /path/to/your/elevation.nc`
|
|
110
|
+
|
|
111
|
+
Usage example:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
ebfm --elmer-mesh examples/MESH --netcdf-mesh examples/BedMachineGreenland-v5.nc
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Note that an Elmer mesh must be provided in a directory following the structure:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
path/to/your/elmer/MESH/
|
|
121
|
+
├── mesh.boundary
|
|
122
|
+
├── mesh.elements
|
|
123
|
+
├── mesh.header
|
|
124
|
+
└── mesh.nodes
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The option `--is-partitioned-elmer-mesh` will tell EBFM that the provided Elmer
|
|
128
|
+
mesh is a partitioned mesh. A partitioned mesh file follows the structure:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
path/to/your/elmer/MESH
|
|
132
|
+
├── mesh.boundary
|
|
133
|
+
├── mesh.elements
|
|
134
|
+
├── mesh.header
|
|
135
|
+
├── mesh.nodes
|
|
136
|
+
└── partitioning.128
|
|
137
|
+
├── part.1.boundary
|
|
138
|
+
├── part.1.elements
|
|
139
|
+
├── part.1.header
|
|
140
|
+
├── part.1.nodes
|
|
141
|
+
...
|
|
142
|
+
├── part.128.boundary
|
|
143
|
+
├── part.128.elements
|
|
144
|
+
├── part.128.header
|
|
145
|
+
└── part.128.nodes
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Usage example for partitioned mesh:
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
ebfm --elmer-mesh examples/MESH/partitioning.128/ --netcdf-mesh examples/BedMachineGreenland-v5.nc --is-partitioned-elmer-mesh --use-part 42
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Coupled simulation
|
|
155
|
+
|
|
156
|
+
The EBFM code allows coupling to other simulation codes. The following arguments
|
|
157
|
+
allow to configure the coupling:
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
ebfm ...
|
|
161
|
+
--couple-to-elmer-ice
|
|
162
|
+
--couple-to-icon-atmo
|
|
163
|
+
--coupler-config /path/to/coupling/config.yaml
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Note that the coupling uses the Python bindings of YAC. Additionally, EBFM must
|
|
167
|
+
be run in a MPMD (multiple process multiple data) run.
|
|
168
|
+
Follow the install instructions from above and run the example command for a coupled simulation with Elmer/Ice and ICON:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
mpirun -np 1 ebfm \
|
|
172
|
+
--elmer-mesh $MESHES/MESH/partitioning.128/ \
|
|
173
|
+
--netcdf-mesh $DATA/BedMachineGreenland-v5.nc \
|
|
174
|
+
--is-partitioned-elmer-mesh --use-part 1 \
|
|
175
|
+
--coupler-config $CPL_CONFIG --couple-to-elmer --couple-to-icon \
|
|
176
|
+
: \
|
|
177
|
+
-np 1 $ELMER_ROOT/src/elmer_dummy_f.x $MESHES/MESH/partitioning.128 1 $CPL_CONFIG \
|
|
178
|
+
: \
|
|
179
|
+
-np 1 $ICON_ROOT/src/icon_dummy.x $MESHES/icon_grid_0054_R02B08_G.nc $DATA/mbe3064_atm_elmer_monmean_1979.nc $DATA/varlist_elmerfile
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Be aware that the command above requires setting a few environment variables.
|
|
183
|
+
Assuming your project is structured following [this repository](https://gitlab.dkrz.de/k202215/ebfm_dummy),
|
|
184
|
+
the following settings should help getting started:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
export EBFM_DUMMY_REPO=/path/to/k202215/ebfm_dummy
|
|
188
|
+
export EBFM_REPO=/path/to/this/repo
|
|
189
|
+
|
|
190
|
+
export CPL_CONFIG=$EBFM_DUMMY_REPO/config/coupling.yaml
|
|
191
|
+
export MESHES=$EBFM_DUMMY_REPO/mesh
|
|
192
|
+
export DATA=$EBFM_DUMMY_REPO/data
|
|
193
|
+
|
|
194
|
+
export EBFM_ROOT=$EBFM_REPO
|
|
195
|
+
export ELMER_ROOT=$EBFM_DUMMY_REPO/dummies/ELMER
|
|
196
|
+
export ICON_ROOT=$EBFM_DUMMY_REPO/dummies/ICON
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Depending on the binaries that you want to use `$ELMER_ROOT` and/or `$ICON_ROOT`
|
|
200
|
+
may be set to point to the non-dummy versions of the codes.
|
|
201
|
+
|
|
202
|
+
## Troubleshooting
|
|
203
|
+
|
|
204
|
+
### `libnetcdf.so` not found at runtime
|
|
205
|
+
|
|
206
|
+
*Problem:* `./icon_dummy.x: error while loading shared libraries: libnetcdf.so.15: cannot open shared object file: No such file or directory`
|
|
207
|
+
*Solution:* Try rebuilding `icon_dummy.x`
|
|
208
|
+
`
|
|
209
|
+
### `libyaxt_c.so` not found at runtime
|
|
210
|
+
|
|
211
|
+
*Problem:* `./icon_dummy.x: error while loading shared libraries: libyaxt_c.so.1: cannot open shared object file: No such file or directory`
|
|
212
|
+
|
|
213
|
+
*Solution:* `export LD_LIBRARY_PATH='$YAXT_INSTALL_DIR/lib/'
|
|
214
|
+
|
|
215
|
+
### `#include <proj.h>` not found when building the Elmer dummy
|
|
216
|
+
|
|
217
|
+
*Problem:*
|
|
218
|
+
```sh
|
|
219
|
+
...
|
|
220
|
+
elmer_grid.c:11:10: fatal error: proj.h: No such file or directory
|
|
221
|
+
11 | #include <proj.h>
|
|
222
|
+
| ^~~~
|
|
223
|
+
compilation terminated.
|
|
224
|
+
make: *** [Makefile:48: elmer_grid.o] Error 1
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
*Solution:* `sudo apt-get install libproj-dev`
|
|
228
|
+
|
|
229
|
+
## Developer notes
|
|
230
|
+
|
|
231
|
+
### Optional dependencies `[dev]`
|
|
232
|
+
|
|
233
|
+
Please install the package with the optional dependencies `[dev]` if you are developing (this will automatically
|
|
234
|
+
install `pre-commit`).
|
|
235
|
+
|
|
236
|
+
To concatenate multiple optional dependencies, please run
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
pip3 install EBFM[dev,cpl]
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### pre-commit
|
|
243
|
+
|
|
244
|
+
This project uses pre-commit hooks for some tasks described in detail below. To setup pre-commit please do the following:
|
|
245
|
+
|
|
246
|
+
```sh
|
|
247
|
+
pipx install pre-commit
|
|
248
|
+
pre-commit install
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Alternative:** If you are already working in an virtual environment, you can also use `pip3 install pre-commit` instead of `pipx`. Refer to the [documentation of `pipx`](https://pipx.pypa.io/stable/#overview-what-is-pipx) for further information.
|
|
252
|
+
|
|
253
|
+
As soon as pre-commit is set up, you will not be able to commit if any of the checks fails. With the help of the logging output it should usually be possible to fix the problem.
|
|
254
|
+
|
|
255
|
+
Note: You can bypass this check with `--no-verify`. Please note that the CI will also run pre-commit and fail if there are problems in any of the checks. Therefore, it is recommended to use the pre-commit hooks locally before pushing code to this repository and only bypass them if there is a good reason.
|
|
256
|
+
|
|
257
|
+
### Copyright and licensing
|
|
258
|
+
|
|
259
|
+
This project uses [REUSE](https://reuse.software/) to track information regarding copyright and licensing. Therefore, all files in this repository are required to provide the corresponding information. Please refer to the documentation of REUSE for details.
|
|
260
|
+
|
|
261
|
+
You can use pre-commit to automatically check if all files in the repository provide the necessary information:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
pre-commit run reuse --all-files
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Code formatting
|
|
268
|
+
|
|
269
|
+
Automated checks for PEP8 compiance are implemented following [^1] with some modifications. You can use pre-commit hooks to automatically format your code with black:
|
|
270
|
+
|
|
271
|
+
```sh
|
|
272
|
+
pre-commit run black --all-files
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
With flake8 you can check whether your code follows all relevant formatting rules:
|
|
276
|
+
|
|
277
|
+
```sh
|
|
278
|
+
pre-commit run flake8 --all-files
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Please note that black might not be able to automatically fix all problems and therefore flake8 might fail even if you have run black before. In this case, you will have to manually fix the remaining problems.
|
|
282
|
+
|
|
283
|
+
### Further hints
|
|
284
|
+
|
|
285
|
+
* Please consider installing EBFM via `pip3 --editable .` if you are developing the package.
|
|
286
|
+
|
|
287
|
+
----
|
|
288
|
+
|
|
289
|
+
[^1]: https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025 EBFM Authors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "EBFM"
|
|
7
|
+
dynamic = [ "version" ]
|
|
8
|
+
authors = [ {name="EBFM Authors"} ]
|
|
9
|
+
license = "BSD-3-Clause"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"mpi4py >= 4.1",
|
|
13
|
+
"mypy >= 1.0",
|
|
14
|
+
"netCDF4 >= 1.7",
|
|
15
|
+
"numpy >= 2.0",
|
|
16
|
+
"pandas >= 2.0",
|
|
17
|
+
"pandas-stubs >= 2.0",
|
|
18
|
+
"pathlib",
|
|
19
|
+
"pyproj",
|
|
20
|
+
"scipy",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = [
|
|
25
|
+
"pre-commit >= 4.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
cpl = [
|
|
29
|
+
"yac >= 3.8",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
ebfm = "main:main"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["setuptools", "setuptools-git-versioning"]
|
|
37
|
+
build-backend = "setuptools.build_meta"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools-git-versioning]
|
|
40
|
+
enabled = true
|
|
41
|
+
|
|
42
|
+
[tool.black]
|
|
43
|
+
line-length = 120
|
ebfm-0.1.0/setup.cfg
ADDED