Skip to content

Commit 618d497

Browse files
authored
Merge pull request #232 from GEB-model/main
Update DYNAMO branch
2 parents 02a654b + 176467e commit 618d497

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+7189
-4271
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
## Overview
21
GEB (Geographical Environmental and Behavioural model) simulates the environment (e.g., hydrology, floods), the individual people, households and orginizations as well as their interactions at both small and large scale. The model does so through a "deep" coupling of an agent-based model a hydrological model, a vegetation model and a hydrodynamic model. You can find full documentation [here](https://geb-model.github.io/GEB/).
32

43
The figure below shows a schematic overview of the model agent-based and hydrological model.
@@ -20,11 +19,13 @@ or with [uv](https://docs.astral.sh/uv/):
2019
uv pip install geb --prerelease=allow
2120
```
2221

22+
To run SFINCS (the hydrodynamic model), you also need to install Docker (on Windows) or Singularity (on Linux and Mac OS X). To install Docker you need to obtain and install Docker from their website (https://www.docker.com/get-started) and make sure Docker or Singularity is running.
23+
2324
## Development installation and setup
2425

2526
To contribute to GEB, we recommend first cloning the repository from this repo using `git clone`, and then use uv to install the dependencies. Therefore, first install [uv](https://docs.astral.sh/uv/#installation) and [git](https://git-scm.com/).
2627

27-
Also create a folder where you would like to store the code and model, we call this the *working directory*. In this *working directory*, create a folder called *model*, and place the model input files in this folder. The directory structure should look like this:
28+
Also create a folder where you would like to store the code and model, we call this the *working directory*. Note that this folder should *NOT* be placed into a cloud synchonized folder (e.g., OneDrive). In this *working directory*, create a folder called *model*, and place the model input files in this folder. The directory structure should look like this:
2829

2930
```
3031
working directory

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@
5252
extensions = [
5353
"sphinx.ext.autodoc",
5454
"sphinx.ext.coverage",
55-
"sphinx.ext.napoleon",
55+
"sphinx.ext.napoleon", # Napoleon is a Sphinx extension that enables Sphinx to parse both NumPy and Google style docstrings
5656
"sphinx.ext.viewcode",
5757
"sphinx_rtd_theme",
5858
"sphinx_autodoc_typehints",
5959
"sphinxcontrib.autoprogram",
6060
"sphinxcontrib.autoyaml",
6161
"sphinxcontrib.bibtex",
62+
"myst_parser",
6263
]
6364

6465
# Add any paths that contain templates here, relative to this directory.

docs/contribution_guide.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Contribution Guide
2+
===================
3+
4+
General Recommendations
5+
----------------------------
6+
7+
- It is RECOMMENDED to turn on notifications of GitHub issues to remain aware of current issues and suggested solutions. You can do so using the "watch" feature on the GEB GitHub page.
8+
- You MUST use descriptive commit messages for every commit (e.g., no "some fixes", "progress", etc.).
9+
- It is RECOMMENDED to keep up-to-date with the main branch by frequently (at least once a week) pulling updates from the main. This will reduce the number of merge conflicts and avoid work duplication.
10+
- You MUST use descriptive branch names, and include your name or your sub-project if multiple people work on the same topic.
11+
12+
Feature Development
13+
----------------------------
14+
15+
The main version of GEB is always on the ``main`` branch. This branch SHOULD be stable, and we aim for it to be free of bugs
16+
(acknowledging that this is an almost impossible aim). New features are developed in other branches.
17+
18+
- It is RECOMMENDED to create a GitHub issue with the features that you are working on and to communicate this to other developers
19+
working on similar topics, so that everyone is aware of ongoing work.
20+
- It is RECOMMENDED to limit the number of features in a single branch. If possible, break your feature into several sub-features.
21+
- When the (sub-)features are complete, the branch MUST be merged into ``main`` using a pull request on GitHub.
22+
- It is RECOMMENDED to get feedback on the code from one of the main developers. You can use the reviewer mechanism on the pull request page.
23+
24+
Bugs
25+
----------------------------
26+
27+
We use GitHub issues for tracking bugs.
28+
29+
- When you find a bug that affects ``main``, you MUST create a new issue describing the bug.
30+
- When fixing the bug:
31+
- The fix MUST be reported on the issue.
32+
- The issue MUST link to the fix.
33+
- It is RECOMMENDED to create the fix in a dedicated bug-fix branch created from ``main`` (i.e., not from your working branch).
34+
- Merge the bug-fix branch into your own branch as needed, and separately request a merge of the bug-fix branch back into ``main``.
35+
- It is also RECOMMENDED to communicate the bug to developers who may be affected.
36+
37+
Testing
38+
----------------------------
39+
40+
We use ``pytest`` for automated testing of the GEB model.
41+
42+
- It is RECOMMENDED to write tests for your code.
43+
- Tests are automatically run on GitHub when any branch is pushed.
44+
45+
Coding Practices
46+
----------------------------
47+
48+
- All variable names MUST be clear. Prefer long and descriptive names over short, unclear ones.
49+
- Code comments are RECOMMENDED, focusing on *why* something is done, rather than *what* is done. The *what* should ideally be
50+
evident from the variable naming and structure.
51+
- Units MUST be in SI units, or have the unit appended to the variable name. If SI units cannot be used (e.g., when coupling
52+
with other models), units should be converted immediately on import or export.
53+
- Monetary units MUST be nominal USD (face value) for the respective years.
54+
- It is RECOMMENDED to use ``assert`` statements in the model to ensure correct behaviour.
55+
- When there is an error, the model SHOULD fail. Do not catch exceptions and replace with dummy data.
56+
- All code MUST be formatted using ``ruff format`` and ``ruff check``. Imports MUST be ordered using ``isort`` (included in ``ruff``).
57+
- It is RECOMMENDED to install the ruff plugin and set ruff as the default formatter in Visual Studio Code.
58+
Also turn on “format on paste” and “format on save”.
59+
- ``ruff format`` and ``ruff check`` are automatically executed when pushing to GitHub.

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The figure below shows a schematic overview of some parts of the model, showing
3131
:maxdepth: 1
3232
:caption: Getting Started
3333

34-
Installation <installation>
34+
Overview and installation <overview_and_installation>
3535
Configuration <configuration>
3636
Preprocessing <preprocessing>
3737
Running the model <running>
@@ -63,4 +63,5 @@ The figure below shows a schematic overview of some parts of the model, showing
6363
:caption: About
6464

6565
Authors <authors_page>
66+
Contribution guide <contribution_guide>
6667
Updates <updates>

docs/installation.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/overview_and_installation.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Overview and installation
2+
========================
3+
4+
.. include:: ../README.md
5+
:parser: myst_parser.sphinx_

docs/plantFATE.rst

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,31 @@
1-
1) DOWNLOAD PACKAGES
1+
Download Packages
2+
===============
23

3-
So PlantFATE runs with the use of 2 other packages and with the coupling package you need to checkout 4 different github repositories.
4+
```bash
45
5-
The packages are:
6+
git clone [email protected]:jaideep777/Plant-FATE.git
7+
git switch feature_python_pckg # switch to the feature branch
8+
cd Plant-FATE
69
7-
1) Coupling package: https://github.com/jensdebruijn/couple-plantFATE-CWatM (branch: develop)
8-
2) PlantFATE package: https://github.com/jaideep777/Plant-FATE (branch: feature_stepByStepSim)
9-
3) libpspm package: https://github.com/jaideep777/libpspm (branch: develop)
10-
4) Phydro package: https://github.com/jaideep777/phydro (branch: master)
10+
```
1111

12-
For ease of running and set up put these in one big project root folder (not necessary for the coupling package):
12+
Install optional packages from plantfate extras in GEB:
1313

14-
root
15-
|---- phydro
16-
| |--- inst/include
17-
|
18-
|---- libpspm
19-
| |--- include
20-
| |--- lib
21-
|
22-
|---- Plant-FATE
23-
| |--- inst/include
14+
```bash
2415
25-
2) INSTALL PLANTFATE and PYBIND
16+
uv sync --extra plantfate
2617
27-
- module load cm-eigen3/3.3.7
28-
- module load shared
29-
- module load 2022
30-
- module load GSL/2.7-GCC-11.3.0
18+
```
3119

32-
As per instructions in PlantFATE readme, install natively in C++.
3320

34-
You may need to install additional libraries, specifically pybind:
21+
Compiling PlantFATE
22+
=====================
3523

36-
* pip
24+
```bash
3725
38-
* pip install pybind11
26+
module load shared 2024 Eigen/3.4.0-GCCcore-12.3.0 GSL/2.7-GCC-12.3.0
27+
cd Plant-FATE
28+
make all
29+
uv pip install ../Plant-FATE/
3930
40-
* pip install cppimport
41-
* libpspm
42-
43-
* cd libpspm
44-
45-
* make clean testclean
46-
47-
* make
48-
49-
* make check
50-
51-
* Phydro
52-
53-
* cd phydro
54-
55-
* make clean testclean
56-
57-
* make check
58-
59-
* PlantFATE
60-
61-
* cd Plant-FATE
62-
63-
* make clean testclean
64-
65-
* make python
31+
```

docs/report.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ For example, to export the total bare soil evaporation, gridded daily discharge,
3838
function: weightednansum
3939
hydrology.routing:
4040
discharge_daily:
41-
varname: grid.var.discharge
41+
varname: grid.var.discharge_m3_s
4242
type: grid
4343
function: null
4444
agents.crop_farmers:
@@ -53,7 +53,7 @@ The following options are supported.
5353
* **filename**: The name of the file to be created. This can be a .csv or .zarr file. If the file already exists, it will be overwritten. The filename will be created in the output directory specified in the model configuration file, and placed inside the subdirectory with the name of the module.
5454
* **varname**: The name of the variable to be reported. NumPy-style fancy indexing is supported. For example `varname[:,0]` selects the first column of a 2D array. There are two options:
5555

56-
+ **module attribute**: The variable name in the module. Any variable that can be reached from "self" in the module can be used. For example, `[self.]varname` or `[self.]grid.var.discharge`. Note that `self.` is ommited.
56+
+ **module attribute**: The variable name in the module. Any variable that can be reached from "self" in the module can be used. For example, `[self.]varname` or `[self.]grid.var.discharge_m3_s`. Note that `self.` is ommited.
5757
+ **local variable**: Any variable that exists within the `step` function of the module. This is useful for reporting variables that are not stored between timesteps. Local variables are prefixed with ".", for exampe `.actual_bare_soil_evaporation` in the example above.
5858
* **type**: The type of the variable. This can be one of the following:
5959

examples/geul/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ setup_region:
22
subgrid_factor: 20
33

44
set_time_range:
5-
start_date: 1970-01-01
5+
start_date: 2000-01-01
66
end_date: 2024-12-31
77

88
setup_hydrography:
@@ -14,10 +14,10 @@ setup_regions_and_land_use:
1414
ISO3_column: GID_0
1515

1616
setup_cell_area:
17-
18-
setup_economic_data:
1917

2018
setup_mannings:
19+
20+
setup_economic_data:
2121

2222
setup_soil_parameters:
2323

@@ -340,5 +340,5 @@ setup_forcing_era5:
340340

341341
setup_SPEI:
342342
window: 12
343-
calibration_period_start: 2000-01-01
344-
calibration_period_end: 2020-12-31
343+
calibration_period_start: 2011-01-01
344+
calibration_period_end: 2021-12-31

examples/geul/model.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ general:
1414
# start of the spinup time (YYYY-MM-DD).
1515
# spinup_time: 1999-01-01
1616
# spinup_time: 1980-01-01
17-
spinup_time: 2001-01-01
17+
spinup_time: 2011-01-01
1818
# spinup_time: 2020-01-01
1919
###
2020
# base folder where to report output data to
@@ -24,7 +24,7 @@ hazards:
2424
floods:
2525
simulate: true
2626
resolution: 100
27-
nr_subgrid_pixels: 5
27+
nr_subgrid_pixels: 4
2828
flood_risk: false
2929
gpu: false
3030
force_overwrite: true
@@ -38,6 +38,6 @@ hazards:
3838
report:
3939
hydrology.routing:
4040
discharge_daily:
41-
varname: grid.var.discharge
41+
varname: grid.var.discharge_m3_s
4242
type: grid
4343
function: null

0 commit comments

Comments
 (0)