import mikeio
= mikeio.read("data/sirius_idf_rainfall.dfs0") ds
9 MIKE IO
This section introduces MIKE IO, a fundamental DHI Python package. You’ll learn what MIKE IO is, the scope of its usage in this course, how to install it, and grasp its basic concepts. We provide a brief overview here; the next section delves into more detail.
9.1 What is MIKE IO?
MIKE IO is an open-source Python package developed by DHI, which you might recall from Module 1. It empowers modelers with full flexibility by bridging the gap between various MIKE file formats and Scientific Python’s rich and powerful package ecosystem.
9.2 Usage in course
For MIKE+ modelers, a key file format is dfs0
, DHI’s standard for tabular time series data. You’re likely familiar with dfs0
files for storing data such as rainfall, water levels, or discharge.
This course primarily focuses on the dfs0
functionality of MIKE IO, since it’s most relevant for handling time series data in MIKE+. While MIKE IO also supports other formats like dfs2
, dfsu
, and mesh
files, they are intermediate topics beyond the scope of this introductory course.
It’s important to note that this course primarily focuses on using MIKE IO to get time series data into Pandas DataFrames. This approach is chosen to:
- Reduce the initial learning curve for Python beginners by leveraging Pandas skills.
- Provide a method that is sufficiently powerful for most common time series tasks in MIKE+ modelling.
MIKE IO itself has a lot of other useful functionalities, especially for working directly with Dataset
and DataArray
objects, and for handling multidimensional data (like dfs2
or dfsu
files). We encourage you to explore the official MIKE IO documentation after mastering the basics of Pandas.
9.3 Installation
Install MIKE IO with:
uv pip install mikeio
Always check the official MIKE IO’s documentation for the most up-to-date installation instructions and information on the latest versions.
9.4 Quick glance
Let’s take a quick look at some core MIKE IO objects and how to access them. When you read a dfs0
file, MIKE IO typically returns a Dataset
object.
Example dfs0 is from MIKE+ Example Project: Sirius.
This Dataset
object, ds
, holds the data and metadata. You can easily access its contents, such as the items:
ds.items
The time axis is a Pandas DatetimeIndex
, shared between all items:
ds.time
To access data for a specific item, you can select it from the Dataset
, which returns a DataArray
object:
= ds[0] # Access the first item from ds.items da
9.5 Key Concepts
Understanding a few key concepts in MIKE IO will be helpful as you progress through this course:
- Dataset
-
A
Dataset
is a collection of one or moreDataArray
objects that share the same time axis. Think of it as the entire content of adfs0
file. - DataArray
-
A
DataArray
holds the data for a single item, including its time series values and associated metadata. This is comparable to a single column in adfs0
file when viewed in a tabular format. - Items
-
Each
DataArray
within aDataset
represents an “item.” An item is characterized by its name, type (e.g., water level, discharge), unit (e.g., meters, m\(^3\)/s), and value type (e.g., instantaneous, accumulated), which are crucial for correct data interpretation in MIKE software.
9.6 Additional reading (optional)
The following sections of MIKE IO’s documentation are particularly relevant for this course: