Skip to main content

A package that works with the DHI dfs libraries to facilitate creating, writing and reading dfs0, dfs2, dfs3, dfsu and mesh files.

Project description


Facilitate creating, reading and writing dfs0, dfs2, dfs1 and dfs3 files. Reading Res1D data.


  • Python x64 >=3.6
  • Mike SDK
  • Python packages:
    • Pythonnet
    • Numpy
    • Pandas


mikeio is not yet on PyPI, and until then you can install the package either by

pip install git+


  1. downloading the zip file.
  2. pip install


Reading dfs0 file into Pandas DataFrame

from mikeio.dfs0 import dfs0
dfs = dfs0()
ts = dfs.read_to_pandas('simple.dfs0')

Create simple timeseries

from datetime import datetime, timedelta
import numpy as np
from mikeio.dfs0 import dfs0

# create a list containing data for each item
data = []

# Some random values for first (and only) item
d = np.random.random([100])

dfs = dfs0()
           start_time=datetime(2017, 1, 1),

Create equidistant dfs0 with weekly timestep

from mikeio.eum import TimeStep
d1 = np.random.random([1000])
d2 = np.random.random([1000])
data = []

dfs = dfs0.dfs0()
           start_time=datetime(2017, 1, 1),
           names=['Random1', 'Random2'],
           title='Hello Test')

For more examples see this notebook

Read dfs2 data

from mikeio.dfs2 import dfs2
dfs2File = r"20150101-DMI-L4UHfnd-NSEABALTIC-v01-fv01-DMI_OI.dfs2"
dfs = dfs2()
res =

Create dfs2

For a complete example of conversion from netcdf to dfs2 see this notebook.

Another example of downloading meteorlogical forecast from the Global Forecasting System and converting it to a dfs2 ready to be used by a MIKE 21 model.

DFS Utilities to query variable type, time series types (useful when creating a new dfs file)

>>> from mikeio.dfs_util import type_list, unit_list
>>> type_list('Water level')
{100000: 'Water Level', 100307: 'Water level change'}

>>> unit_list(100307)
{1000: 'meter', 1003: 'feet'}

Read Res1D file Return Pandas DataFrame

import res1d as r1d
p1 = r1d.ExtractionPoint()
p1.BranchName  = 'branch1'
p1.Chainage = 10.11
p1.VariableType  = 'Discharge'
ts ='res1dfile.res1d', [p1])

Read dfsu files

import matplotlib.pyplot as plt
from mikeio.dfsu import dfsu

dfs = dfsu()

filename = "HD.dfsu"
res =

idx = dfs.find_closest_element_index(x=608000, y=6907000)

# data has two dimensions time, x


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mikeio, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size mikeio-0.2.2.tar.gz (17.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page