iMOD
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
iMOD Adapter
This page describes the iMOD module adapter, its functions, and provides an example for configuring an iMOD run in Delft-FEWS.
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-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 hte fluxes between the models is provided in Figure 1.
Figure 1. iMODFLOW-MetaSWAP-WOFOST coupling.
Adapter installation instructions
The adapter is a Python package and requires Python 3.6 or higher. Once Python is installed and the package manager pip is available on the Path, the adapter can be installed as follows:
Notes for users
WesPreAdapter
- For all files that are written by this adapter, if the file to be written already exists, then it will be overwritten.
- This program writes log messages to log file called wes.log.
- This program uses the information in the specified netcdf run file as input and uses this information to do the following:
- Take the values of the properties RADIUS_OF_CYCLONE and WIND_CONV_FAC to write it to wes_input.inp.
- Take the values for all parameters and time steps from a netcdf file exported by FEWS and write it them to wes_adapter_track.trk.
WesPostAdapter
- For all files that are written by this adapter, if the file to be written already exists, then it will be overwritten.
- This program writes log messages to log file called wes.log.
- Converts model output (wes_input.spw) in spiderweb grid format to fews netcdf rotated pole grid format.
System requirements
- The model needs Matlab Compiler runtime 2013b x64 v8.2 to be installed
- The adapter needs Java version 1.7 or higher.
- The adapter needs the following Java libraries:
- castor-0.9.5.jar
- commons-httpclient-3.0.1.jar
- Delft_Util.jar
- fews-WES-adapter.jar
- log4j-1.2.14.jar
- netcdf-4.2.jar
- slf4j-api-1.5.6.jar
- slf4j-log4j12-1.5.6.jar
- xercesImpl.jar
Start up activities
As a first activity it can be useful to delete all files present in the workDir, if for example it would be filled with files from a previous run.
<startUpActivities> <purgeActivity> <filter>workDir*</filter> </purgeActivity> </startUpActivities>
Export activities
The first steps in the general adapter run are the netcdf and run file export activities. The <exportNetcdfActivity> will be a netcdf file which can have any name containing the variables called: lateral, longitudinal, Method, Vmax, Rmax, R100, R65, R50, R35, Par_A, Par_B, Pdrop.
The <exportNetcdfRunFileActivity> will be a netcdf run file that contains information needed by the pre adapter. The information will be automatically filled by the general adapter.
<exportActivities> <exportNetcdfActivity> <exportFile>zs0file.nc</exportFile> <timeSeriesSets> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>lateral</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>longitudinal</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Method</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Vmax</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Rmax</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>R100</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>R65</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>R50</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>R35</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Par_B</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Par_A</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> <timeSeriesSet> <moduleInstanceId>Run_XBeach</moduleInstanceId> <valueType>scalar</valueType> <parameterId>Pdrop</parameterId> <locationId>Dummy</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="6"/> <relativeViewPeriod unit="day" start="-15" end="-9"/> <readWriteMode>editing visible to all future task runs</readWriteMode> </timeSeriesSet> </timeSeriesSets> </exportNetcdfActivity> <exportNetcdfRunFileActivity> <description>This run file is passed as argument to WesPreAdapter</description> <exportFile>run.nc</exportFile> <properties> <double value="1000000.0" key="RADIUS_OF_CYCLONE"/> <double value="0.88" key="WIND_CONV_FAC"/> </properties> </exportNetcdfRunFileActivity> </exportActivities>
Execute activities
The next steps are the execute activities.
The first will be the pre adapter.
The second execute activity will be the module run.
The third execute activity will be the post adapter.
<executeActivities> <executeActivity> <command> <className>nl.deltares.wes.pre.WesPreAdapter</className> <binDir>adapter\bin</binDir> </command> <arguments> <argument>run.nc</argument> </arguments> <logFile> <file>wes.log</file> <errorLinePattern>ERROR*</errorLinePattern> <warningLinePattern>WARN*</warningLinePattern> <infoLinePattern>INFO*</infoLinePattern> <debugLinePattern>DEBUG*</debugLinePattern> </logFile> <timeOut>99999999</timeOut> <ignoreDiagnostics>true</ignoreDiagnostics> </executeActivity> <executeActivity> <command> <executable>wes.exe</executable> </command> <arguments> <argument>wes_input.inp</argument> </arguments> <timeOut>99999999</timeOut> <ignoreDiagnostics>true</ignoreDiagnostics> </executeActivity> <executeActivity> <command> <className>nl.deltares.wes.post.WesPostAdapter</className> <binDir>adapter\bin</binDir> </command> <arguments> <argument>run.nc</argument> </arguments> <logFile> <file>wes.log</file> <errorLinePattern>ERROR*</errorLinePattern> <warningLinePattern>WARN*</warningLinePattern> <infoLinePattern>INFO*</infoLinePattern> <debugLinePattern>DEBUG*</debugLinePattern> </logFile> <timeOut>99999999</timeOut> <ignoreDiagnostics>true</ignoreDiagnostics> </executeActivity> </executeActivities>
Executing pre adapter
This program will read the run.nc input file and use the contents for instructions on which directory and files should be used to convert to the correct WES input format.
The Pre adapter generates a log file called wes.log, which can be read into FEWS by coupling line patterns to FEWS log messages
Take the values of the properties RADIUS_OF_CYCLONE and WIND_CONV_FAC from run.nc to write it to wes_input.inp.
Take the values for all parameters and time steps from a netcdf file exported by FEWS and write it them to wes_adapter_track.trk.
CYCLONE_PAR._FILE = wes_adapter_track.trk SPIDERS_WEB_DIMENS. = 500 36 RADIUS_OF_CYCLONE = 1000000.0 WIND CONV. FAC (TRK)= 0.88 NO._OF_HIS._DATA = 0 HIS._DATA_FILE_NAME = OBS._DATA_FILE_NAME = EXTENDED_REPORT = yes
* File for tropical cyclone * File contains Cyclone information ; TIMES in UTC * File generated by WES adapter * UNIT = Kts, Nmi ,Pa * METHOD= 1:A&B; 4:Vm,Pd; Rw default * 2:R100_etc; 5:Vm & Rw(RW may be default - US data; Pd = 2 Vm*Vm); * 3:Vm,Pd,RmW, 6:Vm (Indian data); 7: OLD METHOD - Not adviced * Dm Vm 0.0 0.0 * Date and time lat lon Method Vmax Rmax R100 R65 R50 R35 Par B Par A Pdrop * yyyy mm dd HH deg deg (-) (kts) (NM) (NM) (NM) (NM) (NM) (-) (-) (Pa) 2000 11 03 00 14.00 -80.00 4 30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1400 2000 11 03 06 15.00 -80.00 4 35 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1500 2000 11 03 12 16.00 -80.00 4 40 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1600 2000 11 03 18 17.00 -80.00 4 45 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 2000 2000 11 04 00 17.00 -80.00 4 50 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 4000 2000 11 04 06 17.00 -81.00 4 55 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 7000 2000 11 04 12 18.00 -81.00 4 60 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 10000 2000 11 04 18 18.00 -81.00 4 65 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 12000 2000 11 05 00 18.00 -81.00 4 70 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 13000 2000 11 05 06 18.00 -81.00 4 75 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 13000 2000 11 05 12 19.00 -82.00 4 80 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 12000 2000 11 05 18 19.00 -82.00 4 85 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 12000 2000 11 06 00 19.00 -82.00 4 90 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 11000 2000 11 06 06 20.00 -82.00 4 95 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 11000 2000 11 06 12 20.00 -82.00 4 100 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 11000 2000 11 06 18 20.00 -81.00 4 105 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 10000 2000 11 07 00 21.00 -81.00 4 110 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 10000 2000 11 07 06 21.00 -81.00 4 115 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 9000 2000 11 07 12 21.00 -81.00 4 120 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 9000 2000 11 07 18 21.00 -80.00 4 125 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 8000 2000 11 08 00 20.00 -80.00 4 130 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 7000 2000 11 08 06 20.00 -80.00 4 135 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 6000 2000 11 08 12 19.00 -80.00 4 140 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 5000 2000 11 08 18 19.00 -80.00 4 145 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 4000 2000 11 09 00 18.00 -79.00 4 150 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 1E+30 3000
Executing model run
This activity runs the model (wes.exe) in the workdir containing the model files with the input file names as arguments. The model creates the output file wes_input.spw which contains the grid information for FEWS (and the output file wes_input_wes.dia which is not used yet).
<executeActivity> <command> <executable>wes.exe</executable> </command> <arguments> <argument>wes_input.inp</argument> </arguments> <timeOut>99999999</timeOut> <ignoreDiagnostics>true</ignoreDiagnostics> </executeActivity>
Executing post adapter
Converts model output (wes_input.spw) in spiderweb grid format to fews netcdf rotated pole grid format, for each time step a seperate netcdf file is created because each time step has a seperate grid definition.
The post adapter writes log messages to log file called wes.log which can be read into FEWS by coupling line patterns to FEWS log messages.
<executeActivity> <command> <className>nl.deltares.wes.post.WesPostAdapter</className> <binDir>adapter\bin</binDir> </command> <arguments> <argument>run.nc</argument> </arguments> <logFile> <file>wes.log</file> <errorLinePattern>ERROR*</errorLinePattern> <warningLinePattern>WARN*</warningLinePattern> <infoLinePattern>INFO*</infoLinePattern> <debugLinePattern>DEBUG*</debugLinePattern> </logFile> <timeOut>99999999</timeOut> <ignoreDiagnostics>true</ignoreDiagnostics> </executeActivity>
Importing post adapter output
The last part of the general adapter run is importing the post adapter output. It uses <folder> and <fileNamePattern> in order to import the netcdf files for each time step.
<importActivities> <importNetcdfActivity> <folder>workdir</folder> <fileNamePatternFilter>wes_grid_*.nc</fileNamePatternFilter> <timeSeriesSets> <timeSeriesSet> <moduleInstanceId>Run_WES_Import</moduleInstanceId> <valueType>grid</valueType> <parameterId>Wind.speed</parameterId> <locationId>WilmaTest21</locationId> <timeSeriesType>external historical</timeSeriesType> <timeStep unit="hour" multiplier="1"/> <readWriteMode>read complete forecast</readWriteMode> </timeSeriesSet> </timeSeriesSets> </importNetcdfActivity> </importActivities>