#!/usr/bin/env python # coding: utf-8 # # More Dfsu spectral files # In[1]: import matplotlib.pyplot as plt import mikeio # ## Output from directional-sector-MIKE 21 SW run # # MIKE 21 SW can be run with dicretized directions only in a directional sector. The reading and plotting of such spectra are also supported in MIKE IO. # In[2]: fn = "../tests/testdata/MIKE21SW_dir_sector_area_spectra.dfsu" dfs = mikeio.open(fn) dfs # In[3]: dfs.geometry.is_spectral # In[4]: da = dfs.read(time=0)["Energy density"] da # In[5]: da.plot(); # In[6]: da_pt = da.isel(element=0) da_pt # In[7]: da_pt.plot(rmax=10, vmin=0); # ## Frequency spectra # # Frequency spectra have 0 directions. They can be of type point, line and area. # ### Point frequency spectrum # In[8]: fn = "../tests/testdata/pt_freq_spectra.dfsu" # In[9]: da = mikeio.read(fn)[0] da # In[10]: da.sel(time="2017-10-27 02:00").plot(); # In[11]: da.frequencies # Compute significant wave height time series # In[12]: Hm0 = da.to_Hm0() Hm0 # In[13]: Hm0.plot(); # ### Area frequency spectra # In[14]: fn = "../tests/testdata/area_freq_spectra.dfsu" da = mikeio.read(fn)[0] da # In[15]: da.n_frequencies, da.n_directions # In[16]: da.plot(); # In[17]: da.sel(x=2.7, y=52.4).plot(); # In[18]: elem = 0 plt.plot(da.frequencies, da[:,elem].to_numpy().T) plt.legend(da.time) plt.xlabel("frequency [Hz]") plt.ylabel("directionally integrated energy [m*m*s]") plt.title(f"Area dfsu file, frequency spectrum in element {elem}"); # ## Directional spectra # # Directional spectra have 0 frequencies. They can be of type point, line and area. # ### Line directional spectra # In[19]: fn = "../tests/testdata/line_dir_spectra.dfsu" da = mikeio.read(fn)[0] da # In[20]: da.n_frequencies, da.n_directions # In[21]: da5 = da.isel(time=0).isel(node=5) da5 # In[22]: da5.plot(); # In[ ]: