Getting started

Dataset

The Dataset is the common MIKE IO data structure for data read from dfs files. The mikeio.read method returns a Dataset with a DataArray for each item.

Each DataArray have the following properties:

Types and units

The dfs items in MIKE IO are represented by the ItemInfo class. An ItemInfo consists of:

import mikeio

mikeio.ItemInfo("Viken", mikeio.EUMType.Water_Level)
Viken <Water Level> (meter)
mikeio.ItemInfo(mikeio.EUMType.Wind_speed)
Wind speed <Wind speed> (meter per sec)

Dfs0

A dfs0 file is also called a time series file.

Read Dfs0 to Dataset:

ds = mikeio.read("../data/da_diagnostic.dfs0")
ds
<mikeio.Dataset>
dims: (time:744)
time: 2017-10-27 00:00:00 - 2017-10-29 18:00:00 (744 non-equidistant records)
geometry: GeometryUndefined()
items:
  0:  State 1Sign. Wave Height <Significant wave height> (meter)
  1:  State 2Sign. Wave Height <Significant wave height> (meter)
  2:  Mean StateSign. Wave Height <Significant wave height> (meter)
  3:  MeasurementSign. Wave Height <Significant wave height> (meter)

Read more on the Dfs0 page.

Convert the timeseries dataset to a pandas DataFrame:

df = ds.to_dataframe()
df.head()
State 1Sign. Wave Height State 2Sign. Wave Height Mean StateSign. Wave Height MeasurementSign. Wave Height
2017-10-27 00:00:00 1.749465 1.749465 1.749465 1.72
2017-10-27 00:10:00 1.811340 1.796895 1.807738 NaN
2017-10-27 00:20:00 1.863424 1.842759 1.853422 NaN
2017-10-27 00:30:00 1.922261 1.889839 1.897670 NaN
2017-10-27 00:40:00 1.972455 1.934886 1.935281 NaN

Dfs2

A dfs2 file is also called a grid series file. Values in a dfs2 file are ‘element based’, i.e. values are defined in the centre of each grid cell.

ds = mikeio.read("../data/gebco_sound.dfs2")
ds
<mikeio.Dataset>
dims: (time:1, y:264, x:216)
time: 2020-05-15 11:04:52 (time-invariant)
geometry: Grid2D (ny=264, nx=216)
items:
  0:  Elevation <Total Water Depth> (meter)

Read more on the Dfs2 page.

Generic dfs

MIKE IO has generic functionality that works for all dfs files:

  • concat() - Concatenates files along the time axis
  • extract() - Extract timesteps and/or items to a new dfs file
  • diff() - Calculate difference between two dfs files with identical geometry
  • sum() - Calculate the sum of two dfs files
  • scale() - Apply scaling to any dfs file
  • avg_time() - Create a temporally averaged dfs file
  • quantile() - Create a dfs file with temporal quantiles

All generic methods creates a new dfs file.

from mikeio import generic
generic.concat(["fileA.dfs2", "fileB.dfs2"], "new_file.dfs2")

Additional resources