Skip to content

Commit eb83b05

Browse files
committed
Documentation example
1 parent 6ec0671 commit eb83b05

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/examples/Generic.qmd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,29 @@ ds3 = mikeio.read("gebco_sound_spatial.dfs2")
169169
ds3.Elevation[0].plot();
170170
```
171171

172+
## Derived items
173+
174+
Creating derived items from existing items, e.g. current speed from u and v velocities.
175+
```{python}
176+
from mikeio.generic import DerivedItem
177+
178+
fn = "../data/oresundHD_run1.dfsu"
179+
fn_derived = "oresundHD_speed.dfsu"
180+
mikeio.generic.transform(
181+
fn,
182+
fn_derived,
183+
[
184+
DerivedItem(
185+
name="Current speed",
186+
type=mikeio.EUMType.Current_Speed,
187+
unit=mikeio.EUMUnit.knot,
188+
func=lambda x: 1.94 * np.sqrt(x["U velocity"] ** 2 + x["V velocity"] ** 2),
189+
)
190+
],
191+
)
192+
```
193+
194+
172195
## Time average
173196

174197
```{python}
@@ -211,6 +234,7 @@ da_q75.plot(title="75th percentile, wind speed", label="m/s")
211234

212235
```{python}
213236
import os
237+
214238
os.remove("concat.dfs1")
215239
os.remove("oresundHD_difference.dfsu")
216240
os.remove("extracted.dfs1")
@@ -219,5 +243,6 @@ os.remove("gebco_sound_local_datum.dfs2")
219243
os.remove("gebco_sound_spatial.dfs2")
220244
os.remove("Avg_NorthSea_HD_and_windspeed.dfsu")
221245
os.remove(fn_q)
246+
os.remove("oresundHD_speed.dfsu")
222247
```
223248

0 commit comments

Comments
 (0)