#!/usr/bin/env python # coding: utf-8 # # DataArray - Dfs123 plotting # # A DataArray with gridded data, can be plotted in many different ways. # In[1]: import matplotlib.pyplot as plt import mikeio # ## Dfs1 # In[2]: ds = mikeio.read("../tests/testdata/vu_tide_hourly.dfs1") ds = ds.rename({"Tidal current component (geographic East)":"Tidal current u-comp"}) da = ds["Tidal current u-comp"] da # In[3]: da.geometry # In[4]: da[0:10:2].plot(); # In[5]: da[0:10:2].plot.line() plt.legend(da.time[0:10:2]); # In[6]: # plot all points on line as time series da.plot.timeseries(); # In[7]: # first 48 hours... da[:49].plot.pcolormesh(); # In[8]: # single point on line as timeseries da.sel(x=0.5).sel(time=slice("2021-08-01","2021-08-03")).plot(); # In[9]: # all data as histogram da.plot.hist(bins=40); # ## Dfs2 # In[10]: da = mikeio.read("../tests/testdata/gebco_sound.dfs2")[0] da # In[11]: da.geometry # In[12]: da.plot(figsize=(10,6)); # It is also possible to customize the labels of the axes as well as the color bar, e.g. for localized adaption. # In[13]: da.plot.contourf(figsize=(10,6), levels=4, label="Højde (m)") plt.xlabel("Længdekreds (°)") plt.ylabel("Breddekreds (°)") # In[14]: ax = da.plot.contour(figsize=(8,8), cmap="plasma") ax.set_xlim([12.5, 12.9]) ax.set_ylim([55.8, 56]); # In[15]: da.plot.hist(bins=20); # ## Dfs3 # In[16]: fn = "../tests/testdata/test_dfs3.dfs3" dfs = mikeio.open(fn) dfs # In[17]: dfs.geometry # In[18]: ds=dfs.read() ds # In[19]: ds.Temperature.plot(); # In[20]: ax = ds.Temperature[:,0,:,:].plot.contourf() ax.grid() # In[21]: ds.Temperature[:,0,:,0].plot(); # In[22]: ds=dfs.read(layers=0) ds # In[23]: ds.Temperature.plot(); # In[ ]: