#!/usr/bin/env python # coding: utf-8 # # Dfs2 - Slicing # In[1]: import mikeio import matplotlib.pyplot as plt # In[2]: ds = mikeio.read("../tests/testdata/waves.dfs2") ds # In[3]: ds[0].plot() plt.axvline(x=1400,color='k',linestyle='dashed', label="Transect") plt.legend(); # 1. Use `Dataset/DataArray.sel` with physical coordinates. # In[4]: ds.sel(x=1400)[0].plot() # 2. Use grid coordinates with `Dataset/DataArray.isel` # In[5]: ds.geometry.find_index(x=1400) # In[6]: ds.isel(x=27)[0].plot() # In[7]: ds.sel(x=1400).to_dfs("waves_x1400.dfs1") # In[8]: dsnew = mikeio.read("waves_x1400.dfs1") dsnew # In[9]: import os os.remove("waves_x1400.dfs1")