import matplotlib.pyplot as plt
import mikeio
DataArray - Dfsu plotting
A DataArray with flexible mesh data, can be plotted in many different ways.
Dfsu 2d
= "../tests/testdata/oresundHD_run1.dfsu"
fn = mikeio.read(fn)
ds ds
<mikeio.Dataset>
dims: (time:5, element:3612)
time: 2018-03-07 00:00:00 - 2018-03-11 00:00:00 (5 records)
geometry: Dfsu2D (3612 elements, 2046 nodes)
items:
0: Surface elevation <Surface Elevation> (meter)
1: Total water depth <Water Depth> (meter)
2: U velocity <u velocity component> (meter per sec)
3: V velocity <v velocity component> (meter per sec)
= ds["Surface elevation"]
da da
<mikeio.DataArray>
name: Surface elevation
dims: (time:5, element:3612)
time: 2018-03-07 00:00:00 - 2018-03-11 00:00:00 (5 records)
geometry: Dfsu2D (3612 elements, 2046 nodes)
Plot as map
# default plot is a map, for multiple timestep data, the first timestep will be shown
; da.plot()
# plot last time step as contour map
-1].plot.contour(figsize=(5,8)); da[
= plt.subplots(1,2)
_, ax =ax[0]);
da.plot.mesh(ax=ax[1]); da.plot.outline(ax
Plot aggregated data
max().plot(title="Max"); da.
# difference between last and first timestep
0] - da[-1]).plot.contourf(title="Difference"); (da[
="space").plot(title="Spatial mean as function of time"); da.mean(axis
Other plots
- time series
- histogram
# plot all data as histogram
=100); da.plot.hist(bins
# plot all points as timeseries
=0.01); da.plot.line(alpha
Dfsu 3d
= "../tests/testdata/oresund_sigma_z.dfsu"
fn = mikeio.open(fn)
dfs dfs
Dfsu3DSigmaZ
number of elements: 17118
number of nodes: 12042
projection: UTM-33
number of sigma layers: 4
max number of z layers: 5
items:
0: Temperature <Temperature> (degree Celsius)
1: Salinity <Salinity> (PSU)
time: 3 steps with dt=10800.0s
1997-09-15 21:00:00 -- 1997-09-16 03:00:00
Read a specific layer
If only a specific layer is read, then all the standard 2d plotting can be used
= dfs.read(layers="top")
ds ds
<mikeio.Dataset>
dims: (time:3, element:3700)
time: 1997-09-15 21:00:00 - 1997-09-16 03:00:00 (3 records)
geometry: Dfsu2D (3700 elements, 2090 nodes)
items:
0: Temperature <Temperature> (degree Celsius)
1: Salinity <Salinity> (PSU)
ds.geometry.is_2d
True
1].plot(); ds[
Default plotting behaviour for 3d files is to plot surface layer
= dfs.read()
ds ds
<mikeio.Dataset>
dims: (time:3, element:17118)
time: 1997-09-15 21:00:00 - 1997-09-16 03:00:00 (3 records)
geometry: Dfsu3DSigmaZ (17118 elements, 4 sigma-layers, 5 z-layers)
items:
0: Temperature <Temperature> (degree Celsius)
1: Salinity <Salinity> (PSU)
ds.geometry.is_2d
False
1].plot(); ds[