Python Scripting in MIKE SHE

This section describes the MShePy module, which enables the use of Python scripting with MIKE SHE. This includes:

1.       running Python plugins during a MIKE SHE simulation;

2.       running MIKE SHE simulations by Python scripts.

In the first case, the user can add plugins to a MIKE SHE model. A Plugin consists of a collection of code functions in Python performing custom func­tionalities. During preprocessing, the Python plugins are attached to the model and once the simulation is started, functions (or "slots") in the plugins will be connected to signals (e.g. before a time step). Signals will be emitted by MIKE SHE and trigger execution of one or more custom functions defined in the plugin. Once the function has finished to perform arbitrary tasks (e.g. exchange data with MIKE SHE), MIKE SHE will continue the normal execu­tion.

Python_Plugins.png 

In the second case, the user can call and execute the water movement of a MIKE SHE model from a Python shell. This allows controlling the simulation time from the Python shell and exchange items between the MIKE SHE model and the Python environment before, during, and after the simulation.

Requirements

The MShePy module is available from MIKE Zero 2019 version 1. Only water movement (WM) can be accessed through MShePy. Thus, water quality sim­ulations, the preprocessor and other components are currently not supported.

All water movement components can be accessed by MShePy. This includes:

·         Overland flow

·         River exchange items

·         Unsaturated flow

·         Evapotranspiration

·         Saturated flow

The Python (e.g. from https://www.python.org/) 64-bit versions currently sup­ported are version 3.6 and 3.7.