Getting started
This guide will help you get started with MIKE+Py, from installation to running your first operations.
Requirements
- A licensed installation of MIKE+ (MIKE+Py is compatible with MIKE+ 2023 and later).
- Python (x64) version 3.9 - 3.11.
- (Windows) VC++ redistributables (often already installed if you have MIKE+).
mikeio and mikeio1d
Due to underlying library dependencies, mikeplus currently has known conflicts:
mikeiocannot be imported in the same Python process asmikeplus.mikeio1dmust be imported aftermikeplus.
Please plan your scripts accordingly. For instance, if you need functionality from both mikeio and mikeplus, consider using separate Python processes or scripts. The environment variable MIKEPLUSPY_DISABLE_CONFLICT_CHECKS=true can be set to bypass these checks at your own risk.
Installation
uv is an extremely fast Python package and project manager that is 10-100x faster than pip, and also makes it easy to install Python and manage projects. With uv, creating a virtual environment is as easy as uv venv.
To install MIKE+Py, run this command in your terminal:
pip install mikeplusuv pip install mikeplusThe Python package is named mikeplus (for import mikeplus) and is installed from PyPI using pip install mikeplus. The development repository is named mikepluspy.
Accessing Model Data
The core of MIKE+Py is the Database object, which provides an interface to your MIKE+ model. You can open a model, access its tables, and query data.
Here’s how to open a database and read a table into a pandas DataFrame:
import mikeplus as mp
with mp.open("your_model_project.sqlite") as db:
db.tables.msm_Node.select().to_pandas()Running a Simulation
MIKE+Py allows you to execute simulations defined in your MIKE+ model directly from Python.
This example runs the currently active simulation in the model:
import mikeplus as mp
with mp.open("your_model_project.sqlite") as db:
print(f"Running simulation: {db.active_simulation} for model type: {db.active_model}")
# Run the active simulation
result_files = db.run()
print("Simulation finished. Result files:")
for res_file in result_files:
print(res_file)