#!/usr/bin/env python # coding: utf-8 # # DataArray - Dfsu plotting # # A DataArray with flexible mesh data, can be plotted in many different ways. # In[1]: import matplotlib.pyplot as plt import mikeio # ## Dfsu 2d # In[2]: fn = "../tests/testdata/oresundHD_run1.dfsu" ds = mikeio.read(fn) ds # In[3]: da = ds["Surface elevation"] da # ## Plot as map # In[4]: # default plot is a map, for multiple timestep data, the first timestep will be shown da.plot(); # In[5]: # plot last time step as contour map da[-1].plot.contour(figsize=(5,8)); # In[6]: _, ax = plt.subplots(1,2) da.plot.mesh(ax=ax[0]); da.plot.outline(ax=ax[1]); # ### Plot aggregated data # In[7]: da.max().plot(title="Max"); # In[8]: # difference between last and first timestep (da[0] - da[-1]).plot.contourf(title="Difference"); # In[9]: da.mean(axis="space").plot(title="Spatial mean as function of time"); # ## Other plots # # * time series # * histogram # In[10]: # plot all data as histogram da.plot.hist(bins=100); # In[11]: # plot all points as timeseries da.plot.line(alpha=0.01); # ## Dfsu 3d # In[12]: fn = "../tests/testdata/oresund_sigma_z.dfsu" dfs = mikeio.open(fn) dfs # ### Read a specific layer # If only a specific layer is read, then all the standard 2d plotting can be used # In[13]: ds = dfs.read(layers="top") ds # In[14]: ds.geometry.is_2d # In[15]: ds[1].plot(); # ### Default plotting behaviour for 3d files is to plot surface layer # In[16]: ds = dfs.read() ds # In[17]: ds.geometry.is_2d # In[18]: ds[1].plot(); # In[ ]: