File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,61 @@ Grid1D's primary properties and methods are:
32
32
* ` isel() `
33
33
34
34
See [ API specification] ( `mikeio.Grid1D` ) for details.
35
+
36
+
37
+ ## Creating a dfs1 file
38
+
39
+ 1 . Create a datetime index
40
+ 2 . Create a data array with dimensions (time, x)
41
+
42
+ In this example the grid consist of two points (west and east), but the same approach can be used for any number of points.
43
+
44
+ ``` {python}
45
+ import numpy as np
46
+ import pandas as pd
47
+ import matplotlib.pyplot as plt
48
+ import mikeio
49
+
50
+ t = pd.date_range("2021-01-01", periods=100, freq="15min")
51
+ t_rel = (t - t[0]).total_seconds().values
52
+
53
+ west = np.sin(t_rel / 3600)
54
+ east = 1.2*np.sin(t_rel / 3600 + 0.5)
55
+
56
+ data = np.column_stack((west, east))
57
+ data.shape
58
+ ```
59
+
60
+ 3 . Create a ` Grid1D ` geometry with the number of points in the x-direction and the spacing.
61
+
62
+ ``` {python}
63
+ geometry = mikeio.Grid1D(nx=2, dx=1)
64
+ geometry
65
+ ```
66
+
67
+ 4 . Create a ` DataArray ` object with the data, time, geometry, and item information.
68
+
69
+ ``` {python}
70
+ da = mikeio.DataArray(
71
+ data,
72
+ time=t,
73
+ geometry=geometry,
74
+ item=mikeio.ItemInfo("Water level", mikeio.EUMType.Water_Level),
75
+ )
76
+ da
77
+ ```
78
+
79
+ ``` {python}
80
+ da.plot.timeseries()
81
+ ```
82
+
83
+ Optional, repeat step 4 for additional items to create a Dataset.
84
+
85
+ 5 . Write to a dfs1 file.
86
+
87
+ ``` {python}
88
+ da.to_dfs("boundary.dfs1")
89
+ ```
90
+
91
+
92
+
You can’t perform that action at this time.
0 commit comments