Skip to content

Commit

Permalink
restore py3 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkEilander committed Jun 15, 2020
1 parent 5c5087e commit ac596e1
Show file tree
Hide file tree
Showing 28 changed files with 4,444 additions and 4,235 deletions.
29 changes: 15 additions & 14 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import sys
import os

from mock import Mock as MagicMock


class Mock(MagicMock):
__all__ = []
__version__ = "1.6"

@classmethod
def __getattr__(cls, name):
return Mock()
return Mock()


# Mock modules so that we can build on readthedocs.org
MOCK_MODULES = ['pcraster']
Expand All @@ -47,20 +51,20 @@ def __getattr__(cls, name):
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.autosectionlabel',
]
'sphinx.ext.autosummary',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.autosectionlabel',
]

napoleon_google_docstring = False
napoleon_use_param = False
napoleon_use_ivar = True

todo_include_todos=True
todo_include_todos = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -211,7 +215,6 @@ def __getattr__(cls, name):
]



# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
Expand All @@ -231,5 +234,3 @@ def __getattr__(cls, name):

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


25 changes: 21 additions & 4 deletions doc/running_GLOFRIM.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,27 @@ communicate with that model via BMI. Add only models which are part of the (coup
.. note::
CMF only listens to the configuration file if it is called *input_flood.nam*, therefore the original configuration file should be called different, for instance input_flood.nam.org.

The **coupling** section contains general settings for the exchanges between models.::
The **coupling** section contains general settings for the exchanges between models.
**dt** indicates the time step at which information should be exchanged between models. This usually should be at least one full time step of the model that runs with the largest time step.
In the example we assume that a WFlow model dictates daily time steps, and that a coupled lisflood model
has smaller time steps. The section furthermore contains projections of the different model instances. These can be provided in EPSG code (e.g. "EPSG:4326" would indicate regular WGS84 lat lon projection) or as proj string, as shown in the example.::

[coupling]
# timestep for exchanges [sec]
dt=86400
WFL=+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
LFP=+proj=utm +zone=34 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs

The **exchanges** section contains the information about how the models communicate on run time. This part has a slightly complex syntax as it contains a lot of information.

The **exchanges** section contains the information about how the models communicate on run time. This part has a slightly complex syntax as it contains a lot of information.
Every line indicates one exchange from the left (upstream/get) model.variable to the right (downstream/set) model.variable. This can be further extended by multipliers which can be model variables
or scalar values in order to make sure the variable units match. Finally behind the @ the spatial location to get (upstream) and set (downstream) the model variables.
Current options are @1d, @1d_us (the most upstream 1d cells or nodes) and @grid_us (the upstream cell for each grid cell)::
or scalar values in order to make sure the variable units match. Behind the @ the spatial location to get (upstream) and set (downstream) the model variables.
Current options are @1d, @1d_us (the most upstream 1d cells or nodes) and @grid_us (the upstream cell for each grid cell). Finally, behind the location of the downstream/set model, a user may set a `|` sign and then specify the grid cell coordinates (in the projection of the model) in python list form, that should be coupled with the upstream grid cells of the upstream/get model. This should be done as follows::

[[x1, y1], [x2, y2], [x3, y3], ...., [xn, yn]]


GLOFRIM will then only couple these specific grid cells rather than automatically lookup which cells are coupled. This is an important feature when river networks of the upstream/get and downstream/set models are not entirely commensurate. Examples are provided below::

[exchanges]
# setup exchanges which are executed during the coupled update function.
Expand All @@ -129,6 +140,12 @@ Current options are @1d, @1d_us (the most upstream 1d cells or nodes) and @grid
PCR.runoff*cellArea=DFM.rain*ba*1000@1d
PCR.discharge*86400@grid_us=DFM.rain*ba*1000@1d_us

# Example 3: upstream WFL discharge (RiverRunoff) is fed into a limited set of user specified LFP grid cells at the upstream bounds of the model domain.
# The user must ensure that the selected grid cells are overlapping with the intended
# WFL major streams.
WFL.RiverRunoff*86400@grid_us=LFP.SGCQin*86400@1d_us|[[677250, 8346250], [733250, 8428750], [839750, 8398750], [688750, 8452250], [792750, 8295750]]


.. note::
Note that only fluxes were tested as receiving variables. While states can be used as well, their rather static nature (i.e. using m3 instead of m3/s)
can lead to numerical stabilities per time step. Careful testing of the established model coupling is thus necessary!
Expand Down
31 changes: 16 additions & 15 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: glofrim
name: glofrim3

channels:
- conda-forge
- defaults

dependencies:
- python=2.7
- numpy==1.14.5
- netcdf4>=1.3.1
- rasterio>=1.0
- rtree>=0.8.3
- click>=6.7
- configparser>=3.5.0
- python-dateutil>=2.2
- pytz>=2014.3
- faulthandler>=2.3
- six>=1.6.1
- pip>=9.0.3
- configparser
- click>=7.0
- netcdf4>=1.4.2
- numpy
- pcraster
- pip>=20.0
- python>=3.7
- python-dateutil>=2.8
- pytz>=2019.3
- rasterio>=1.1
- rtree>=0.9.3
- six>=1.14
- wflow
- pip:
- bmi-python
- git+https://github.com/openearth/glofrim.git
- bmi-python>=0.2.6
59 changes: 29 additions & 30 deletions glofrim.ini
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
[engines]
# path to model engines; only required for the non-python models used
# these settings can also be set in environment.env
CMF = /home/dirk/Models/cama-flood_bmi_v3.6.2/src/libcama.so
DFM = /home/dirk/Models/dflowfm-1.1.201/lib/libdflowfm.so
LFP = /home/dirk/repos/LISFLOOD-BMI/lisflood-bmi-v5.9/liblisflood.so

[models]
# alternative root dir for relative ini-file paths, by default the directory of this ini file is used;
# this setting can also be set in environment.env
root_dir = /home/dirk/repos/model_test_data/test_Elbe
# reference to inifiles
# all referenced inifiles are run during update
# format: model_short_name = path/to/configuratoin_file
PCR=PCR_Elbe/setup_PCR_30min_Elbe.ini
DFM=DFM_Elbe/Elbe_1way_1d2dFM_400m_3200m.mdu


[coupling]
# timestep for exchanges [sec]
dt=86400

[exchanges]
# setup exchanges which are executed during the coupled update function.
# Note that the user should make sure that both sides should represent a volume [m3]
# format: From_model.var1*var2*multiplier@index = To_model.var*multiplier@index
# the multiplier is optional
# if no index is set the whole 2D domain is coupled
PCR.runoff*cellArea=DFM.rain*ba*0.1@1d
PCR.discharge*86400@grid_us=DFM.rain*ba*0.1@1d_us
[engines]
# path to model engines; only required for the non-python models used
# these settings can also be set in environment.env
# CMF = /home/dirk/Models/cama-flood_bmi_v3.6.2/src/libcama.so
# DFM = /home/dirk/Models/dflowfm-1.1.201/lib/libdflowfm.so
LFP = /home/hcwinsemius/lisflood/liblisflood.so

[models]
# alternative root dir for relative ini-file paths, by default the directory of this ini file is used;
# this setting can also be set in environment.env
root_dir = /home/hcwinsemius/git/glofrim/tests/model_test_data
# reference to inifiles
# all referenced inifiles are run during update
# format: model_short_name = path/to/configuratoin_file
# PCR=PCR_Elbe/setup_PCR_30min_Elbe.ini
# DFM=DFM_Elbe/Elbe_1way_1d2dFM_400m_3200m.mdu
LFP=LFP_data/LFPmodel_Elbe.par

[coupling]
# timestep for exchanges [sec]
dt=86400

[exchanges]
# setup exchanges which are executed during the coupled update function.
# Note that the user should make sure that both sides should represent a volume [m3]
# format: From_model.var1*var2*multiplier@index = To_model.var*multiplier@index
# the multiplier is optional
# if no index is set the whole 2D domain is coupled
# PCR.discharge*86400@grid_us=DFM.rain*ba*0.1@1d_us
17 changes: 9 additions & 8 deletions glofrim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pcr_bmi import PCR
from cmf_bmi import CMF
from dfm_bmi import DFM
from wfl_bmi import WFL
from lfp_bmi import LFP
from glofrim_bmi import Glofrim
from spatial_coupling import SpatialCoupling
from grids import UCGrid, UGrid, RGrid, Network1D
from glofrim.pcr_bmi import PCR
from glofrim.cmf_bmi import CMF
from glofrim.dfm_bmi import DFM
from glofrim.wfl_bmi import WFL
from glofrim.lfp_bmi import LFP
from glofrim.glofrim_bmi import Glofrim
from glofrim.spatial_coupling import SpatialCoupling
from glofrim.grids import UCGrid, UGrid, RGrid, Network1D
from glofrim import nb

0 comments on commit ac596e1

Please sign in to comment.