Page tree
Skip to end of metadata
Go to start of metadata

iMOD Adapter

This page describes the iMOD module adapter, its functions, and provides an example for configuring an iMOD run in Delft-FEWS.

iMOD is an easy-to-use Graphical User Interface with Deltares' innovative version of MODFLOW (called iMODFLOW). Both iMOD and iMODFLOW are freely available here: https://oss.deltares.nl/web/imod

The iMOD Adapter is a Python script designed to make running iMODFLOW models from Delft-FEWS as easy as possible. This includes not only iMODFLOW, but also the coupled MetaSWAP and WOFOST models, as described below. It builds on the iMOD Python package found at https://gitlab.com/deltares/imod/imod-python and uses the iMOD RUNFILE batch function to create run files from project files.

iMODFLOW

MODFLOW is a popular open-source groundwater flow model distributed by the U.S. Geological Survey. iMODFLOW is characterized by fast, flexible and consistent high resolution and sub-domain modelling techniques. It enables very large, high resolution groundwater modelling. Results include the groundwater heads of the various aquifers.

MetaSWAP

MetaSWAP can model both shallow and deep groundwater levels; it is intended for regions with an undulating topography and unconsolidated sediments. Its strength lies in modelling the unsaturated zone and shallow subsurface. MetaSWAP covers plant-atmosphere interactions and groundwater. Results include the fluxes to and from the unsaturated zone.

WOFOST

WOrld FOod STudies (WOFOST) is a crop growth model for the quantitative analysis of the growth and production of annual field crops. WOFOST can be used to calculate attainable crop production, biomass, water use, etc. for a given location. Calculations are made based on local soil type, crop type, weather data, and crop management factors (e.g. sowing date). Results include the root zone depth, leaf area index, and water demand.

iMODFLOW-MetaSWAP-WOFOST coupling

The coupled iMODFLOW-MetaSWAP-WOFOST model benefits from the strengths of each model: iMODFLOW for the groundwater flow, MetaSWAP for the unsaturated zone, and WOFOST for the crop growth aspect. A schema of the fluxes between the models is provided in Figure 1.

iMODFLOW-MetaSWAP-WOFOST coupling

Figure 1. iMODFLOW-MetaSWAP-WOFOST coupling.

Adapter installation instructions

The iMOD Adapter is a Python package and requires Python 3.6 or higher. A number of packages need to be installed prior to installing the adapter. This can be done by using a file called "environment.yml" such as the one below:

environment.yml
name: fews

channels:
  - conda-forge
  - defaults

dependencies:
  - python=3.6
  - numpy
  - xarray
  - numba
  - pandas
  - geopandas
  - dask
  - rasterio
  - git
  - git-lfs
  - jupyterlab
  - spyder
  - jinja2
  - cookiecutter
  - matplotlib
  - pytest
  - cftime
  - netcdf4
  - black

This file can be installed as follows:

conda env create -f environment.yml

Once Python and the required packages are installed and the package manager pip is available on the Path, the adapter can be installed as follows:

pip install git+https://gitlab.com/deltares/imod/imod-fews-adapter

To test if the installation was successful, try starting the Python interpreter and type "import imodfews".

Input

Project file

An iMOD project file (*.PRJ) that describes the model and provides links to the input files needs to be available to the adapter. This project file needs to cover at least the time period that you intend to run. If you only have a runfile (*.RUN), a corresponding project file can be created in iMOD (refer to the iMOD user manual).

RUNFILE_TEMPLATE.INI template

The iMOD Adapter creates a runfile using iMOD batch functionality. For this batch function, a RUNFILE_TEMPLATE.INI file is needed with, among other things, the start and end time of the desired runfile. The highlighted fields below can be left blank and are filled in by the adapter before calling the iMOD batch function.

FUNCTION=RUNFILE

PRJFILE_IN=
RUNFILE_OUT=

ISS=1

SDATE=
EDATE=

ITT=2
IDT=1
SAVESHD=-1
SAVERIV=-1
SAVERCH=1
SAVEDRN=1
SAVEWEL=-1
SAVEFLX=-1
WINDOW=165000.00, 390000.00, 200000.00, 424000.00
CELLSIZE=100.00

run_info.xml

A run_info.xml file can be exported from Delft-FEWS using the exportRunFileActivity. This file gives the iMOD Adapter the required start and end time of the simulation, as well as the location of the state files and other custom properties needed for the adapter, as seen below.

run_info.xml
<?xml version="1.0" encoding="UTF-8"?>
<Run xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.wldelft.nl/fews/PI" xsi:schemaLocation="http://www.wldelft.nl/fews/PI http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_run.xsd" version="1.5">
    <timeZone>0.0</timeZone>
    <startDateTime date="2016-01-28" time="00:00:00"/>
    <endDateTime date="2016-01-30" time="00:00:00"/>
    <time0 date="2016-01-30" time="00:00:00"/>
    <lastObservationDateTime date="2016-01-30" time="00:00:00"/>
    <workDir>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas</workDir>
    <inputStateDescriptionFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\states\config_in\WOFOST_States_in.xml</inputStateDescriptionFile>
    <inputStateDescriptionFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\states\config_in\MetaSwap_States_in.xml</inputStateDescriptionFile>
    <inputStateDescriptionFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\states\config_in\Modflow_States_in.xml</inputStateDescriptionFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackEvt.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackPrec.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackHum.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackTmin.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackTavg.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackTmax.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackRad.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackWspeed.xml</inputMapStackFile>
    <inputMapStackFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\FromFewsToModel\mapstackSundur.xml</inputMapStackFile>
    <outputDiagnosticFile>D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas\Logs\dummy_Diagnostics.xml</outputDiagnosticFile>
    <properties>
        <string key="imod-executable" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/bin/iMOD_V4_2_1_X64R.exe"/>
        <string key="model-executable" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/bin/Driver_MetaSWAP_SVN1361_iMOD43_SVN2240.exe"/>
        <string key="project-file" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/Runfiles/AaenMaas.PRJ"/>
        <string key="state-directory" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/states"/>
        <string key="output-directory" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/output"/>
    </properties>
</Run>

Folder organization

The exported data from Delft-FEWS, including run_info.xml, are expected in a folder called FromFewsToModel. The state directory can be specified in the run_info.xml properties; the following sub-directories are expected in the state directory:

  • config_in
  • config_out
  • files_in
  • files_out

Notes to users

  • For all files that are written by this adapter, if the file to be written already exists, it will be overwritten.
  • This adapter only handles soil moisture retention curves (pF curves) as input for the init_svat.inp file (MetaSWAP), not "MeteoInputP" as input.

Example configuration files

A sample configuration file exporting necessary input data from Delft-FEWS to the model an running the adapter can be found here: Template_ExportToMMW_historical.xml.