# Getting started

## {{< fa database >}} Dataset
The [Dataset](dataset.qmd) is the common MIKE IO data structure for data read from dfs files. 
The  [](`mikeio.read`) method returns a Dataset with a [DataArray](dataarray.qmd) for each item.

Each DataArray have the following properties:

* **item** - an  [](`mikeio.ItemInfo`) with name, type and unit
* **time** - a [](`pandas.DatetimeIndex`) with the time instances of the data
* **geometry** - a Geometry object with the spatial description of the data
* **values** - a [](`numpy.ndarray`)

## {{< fa weight-hanging >}} Types and units

The dfs items in MIKE IO are represented by the [ItemInfo class](`mikeio.ItemInfo`).
An ItemInfo consists of:

* name - a user-defined string 
* type - an [EUMType](`mikeio.EUMType`) 
* unit - an [EUMUnit](`mikeio.EUMUnit`)

```{python}
import mikeio

mikeio.ItemInfo("Viken", mikeio.EUMType.Water_Level)
```

```{python}
mikeio.ItemInfo(mikeio.EUMType.Wind_speed)
```

## {{< fa chart-line >}} Dfs0
A dfs0 file is also called a time series file. 

Read Dfs0 to Dataset:

```{python}
ds = mikeio.read("../data/da_diagnostic.dfs0")
ds
```

Read more on the [Dfs0 page](dfs0.qmd).

Convert the timeseries dataset to a pandas DataFrame:

```{python}
df = ds.to_dataframe()
df.head()
```


## {{< fa map >}} 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. 

```{python}
ds = mikeio.read("../data/gebco_sound.dfs2")
ds
```

Read more on the [Dfs2 page](dfs2.qmd).


## {{< fa toolbox >}} Generic dfs
MIKE IO has [`generic`](generic.qmd) functionality that works for all dfs files: 

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

All generic methods creates a new dfs file.

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

## {{< fa book >}} Additional resources

* Online book: [Getting started with Dfs files in Python using MIKE IO](https://dhi.github.io/getting-started-with-mikeio)
* Online book: [Python for marine modelers using MIKE IO and ModellSkill](https://dhi.github.io/book-learn-mikeio-modelskill)
* [DFS file system specification](https://docs.mikepoweredbydhi.com/core_libraries/dfs/dfs-file-system)