import pandas as pd
import mikeio
@@ -818,7 +818,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu", time=[0,1])[0]
da1 = mikeio.read("../data/HD2D.dfsu", time=[2,3])[0]
da2 da1.time
@@ -826,7 +826,7 @@
+
= mikeio.DataArray.concat([da1,da2])
da3 da3
@@ -1135,7 +1135,7 @@ interp_na
Wrapper of xarray.DataArray.interpolate_na
Examples
-
+
import numpy as np
import pandas as pd
= pd.date_range("2000", periods=3, freq="D")
@@ -1150,7 +1150,7 @@ time
+
da.interp_na()
<mikeio.DataArray>
@@ -1339,7 +1339,7 @@
Examples
-
+
= mikeio.read("../data/europe_wind_long_lat.dfs2")[0]
da da
@@ -1350,7 +1350,7 @@
+
=-1) da.isel(time
<mikeio.DataArray>
@@ -1360,7 +1360,7 @@
+
=slice(10,20), y=slice(40,60)) da.isel(x
<mikeio.DataArray>
@@ -1370,7 +1370,7 @@
+
= mikeio.read("../data/oresund_sigma_z.dfsu").Temperature
da =range(200)) da.isel(element
@@ -2061,7 +2061,7 @@
Examples
-
+
= mikeio.read("../data/random.dfs1")[0]
da da
@@ -2072,7 +2072,7 @@
+
=slice(None, "2012-1-1 00:02")) da.sel(time
<mikeio.DataArray>
@@ -2082,7 +2082,7 @@
+
=100) da.sel(x
<mikeio.DataArray>
@@ -2093,7 +2093,7 @@
+
= mikeio.read("../data/oresund_sigma_z.dfsu").Temperature
da da
@@ -2109,7 +2109,7 @@
+
="1997-09-15") da.sel(time
<mikeio.DataArray>
@@ -2125,7 +2125,7 @@
+
=340000, y=6160000, z=-3) da.sel(x
<mikeio.DataArray>
@@ -2136,7 +2136,7 @@
+
="bottom") da.sel(layers
<mikeio.DataArray>
diff --git a/api/Dataset.html b/api/Dataset.html
index c1700d466..f21b050fe 100644
--- a/api/Dataset.html
+++ b/api/Dataset.html
@@ -438,7 +438,7 @@
Examples
-
+
import mikeio
"../data/europe_wind_long_lat.dfs2") mikeio.read(
diff --git a/api/EUMType.html b/api/EUMType.html
index ba3881d66..94e2c2349 100644
--- a/api/EUMType.html
+++ b/api/EUMType.html
@@ -370,14 +370,14 @@ EUMType
EUM type
Examples
-
+
import mikeio
mikeio.EUMType.Temperature
Temperature
-
+
mikeio.EUMType.Temperature.units
[degree Celsius, degree Fahrenheit, degree Kelvin]
diff --git a/api/EUMUnit.html b/api/EUMUnit.html
index ae7d700c6..24b5de04d 100644
--- a/api/EUMUnit.html
+++ b/api/EUMUnit.html
@@ -370,7 +370,7 @@ EUMUnit
EUM unit
Examples
-
+
import mikeio
mikeio.EUMUnit.degree_Kelvin
diff --git a/api/Grid1D.html b/api/Grid1D.html
index b531020be..c8db5bc8b 100644
--- a/api/Grid1D.html
+++ b/api/Grid1D.html
@@ -463,7 +463,7 @@
Examples
-
+
import mikeio
=3,dx=0.1) mikeio.Grid1D(nx
@@ -471,7 +471,7 @@
x: [0, 0.1, 0.2] (nx=3, dx=0.1)
-
+
=[0.1, 0.5, 0.9]) mikeio.Grid1D(x
<mikeio.Grid1D>
@@ -657,7 +657,7 @@
Examples
-
+
import mikeio
= mikeio.Grid1D(nx=3,dx=0.1)
g g
@@ -666,14 +666,14 @@
+
1,2]) g.isel([
<mikeio.Grid1D>
x: [0.1, 0.2] (nx=2, dx=0.1)
-
+
1) g.isel(
GeometryUndefined()
diff --git a/api/ItemInfo.html b/api/ItemInfo.html
index 490c8444c..bbdea9888 100644
--- a/api/ItemInfo.html
+++ b/api/ItemInfo.html
@@ -425,14 +425,14 @@
Examples
-
+
import mikeio
"Viken", mikeio.EUMType.Water_Level) mikeio.ItemInfo(
Viken <Water Level> (meter)
-
+
mikeio.ItemInfo(mikeio.EUMType.Wind_speed)
Wind speed <Wind speed> (meter per sec)
diff --git a/api/Mesh.html b/api/Mesh.html
index 4266439da..3b1e01ed6 100644
--- a/api/Mesh.html
+++ b/api/Mesh.html
@@ -416,7 +416,7 @@
Examples
-
+
import mikeio
"../data/odense_rough.mesh") mikeio.Mesh(
@@ -472,7 +472,7 @@ Re
Examples
-
+
import mikeio
= mikeio.open("../data/odense_rough.mesh")
msh msh.to_shapely()
diff --git a/api/PfsDocument.html b/api/PfsDocument.html
index 18776f901..4e39ce964 100644
--- a/api/PfsDocument.html
+++ b/api/PfsDocument.html
@@ -577,7 +577,7 @@
Examples
-
+
import pandas as pd
import mikeio
= pd.DataFrame(dict(station=["Foo", "Bar"],include=[0,1]), index=[1,2])
@@ -611,7 +611,7 @@ df
-
+
"STATION_") mikeio.PfsSection.from_dataframe(df,
[STATION_1]
@@ -779,7 +779,7 @@
Examples
-
+
= mikeio.read_pfs("../data/pfs/lake.sw")
pfs ="OUTPUT_") pfs.SW.OUTPUTS.to_dataframe(prefix
diff --git a/api/PfsSection.html b/api/PfsSection.html
index bdbf1f917..5e5b0edd2 100644
--- a/api/PfsSection.html
+++ b/api/PfsSection.html
@@ -496,7 +496,7 @@
Examples
-
+
import pandas as pd
import mikeio
= pd.DataFrame(dict(station=["Foo", "Bar"],include=[0,1]), index=[1,2])
@@ -530,7 +530,7 @@ df
-
+
"STATION_") mikeio.PfsSection.from_dataframe(df,
[STATION_1]
@@ -693,7 +693,7 @@
Examples
-
+
= mikeio.read_pfs("../data/pfs/lake.sw")
pfs ="OUTPUT_") pfs.SW.OUTPUTS.to_dataframe(prefix
diff --git a/api/dataset._data_plot._DataArrayPlotterFM.html b/api/dataset._data_plot._DataArrayPlotterFM.html
index 12c4f2464..505e3fcab 100644
--- a/api/dataset._data_plot._DataArrayPlotterFM.html
+++ b/api/dataset._data_plot._DataArrayPlotterFM.html
@@ -381,7 +381,7 @@ dataset._data_plot._DataArrayPlotterFM
If DataArray is 3D the surface layer will be plotted.
Examples
-
+
import mikeio
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot()
@@ -440,7 +440,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot.contour()
@@ -459,7 +459,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot.contourf()
@@ -561,7 +561,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot.mesh()
@@ -580,7 +580,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot.outline()
@@ -599,7 +599,7 @@
Examples
-
+
= mikeio.read("../data/HD2D.dfsu")["Surface elevation"]
da da.plot.patch()
diff --git a/api/dataset._data_plot._DataArrayPlotterFMVerticalColumn.html b/api/dataset._data_plot._DataArrayPlotterFMVerticalColumn.html
index 03779bc23..dcb4ff7a2 100644
--- a/api/dataset._data_plot._DataArrayPlotterFMVerticalColumn.html
+++ b/api/dataset._data_plot._DataArrayPlotterFMVerticalColumn.html
@@ -376,7 +376,7 @@ dataset._data_plot._DataArrayPlotterFMVertic
If DataArray has multiple time steps, the first step will be plotted.
Examples
-
+
import mikeio
= mikeio.read("../data/oresund_sigma_z.dfsu")
ds = ds.sel(x=333934.1, y=6158101.5)
@@ -390,7 +390,7 @@ dsp
-
+
=False, marker='o') da.plot(extrapolate
@@ -400,7 +400,7 @@
-
+
da.plot.pcolormesh()
@@ -410,7 +410,7 @@
-
+
da.plot.hist()
(array([1., 0., 0., 1., 1., 0., 1., 4., 1., 3.]),
diff --git a/api/dataset._data_plot._DataArrayPlotterFMVerticalProfile.html b/api/dataset._data_plot._DataArrayPlotterFMVerticalProfile.html
index 3b800e574..4a757b023 100644
--- a/api/dataset._data_plot._DataArrayPlotterFMVerticalProfile.html
+++ b/api/dataset._data_plot._DataArrayPlotterFMVerticalProfile.html
@@ -375,7 +375,7 @@ dataset._data_plot._DataArrayPlotterFMVertic
If DataArray has multiple time steps, the first step will be plotted.
Examples
-
+
import mikeio
= mikeio.read("../data/oresund_vertical_slice.dfsu")["Temperature"]
da da.plot()
@@ -387,7 +387,7 @@
-
+
da.plot.hist()
(array([ 1., 2., 19., 70., 202., 384., 336., 167., 127., 15.]),
diff --git a/api/dataset._data_plot._DataArrayPlotterGrid2D.html b/api/dataset._data_plot._DataArrayPlotterGrid2D.html
index ed6662eee..a087b31b1 100644
--- a/api/dataset._data_plot._DataArrayPlotterGrid2D.html
+++ b/api/dataset._data_plot._DataArrayPlotterGrid2D.html
@@ -378,7 +378,7 @@ dataset._data_plot._DataArrayPlotterGrid2D
If DataArray has multiple time steps, the first step will be plotted.
Examples
-
+
import mikeio
= mikeio.read("../data/gebco_sound.dfs2")["Elevation"]
da da.plot()
@@ -434,7 +434,7 @@
Examples
-
+
= mikeio.read("../data/gebco_sound.dfs2")["Elevation"]
da da.plot.contour()
@@ -459,7 +459,7 @@
Examples
-
+
= mikeio.read("../data/gebco_sound.dfs2")["Elevation"]
da da.plot.contourf()
@@ -567,7 +567,7 @@
Examples
-
+
= mikeio.read("../data/gebco_sound.dfs2")["Elevation"]
da da.plot.pcolormesh()
diff --git a/api/from_pandas.html b/api/from_pandas.html
index 61032da13..493f6db98 100644
--- a/api/from_pandas.html
+++ b/api/from_pandas.html
@@ -423,7 +423,7 @@ Re
Examples
-
+
import pandas as pd
import mikeio
diff --git a/api/from_polars.html b/api/from_polars.html
index 76edcb49d..8889e26c0 100644
--- a/api/from_polars.html
+++ b/api/from_polars.html
@@ -429,7 +429,7 @@ Re
Examples
-
+
import polars as pl
import mikeio
from datetime import datetime
diff --git a/examples/Dfsu-2D-interpolation.html b/examples/Dfsu-2D-interpolation.html
index 0b4f1da62..80df16e84 100644
--- a/examples/Dfsu-2D-interpolation.html
+++ b/examples/Dfsu-2D-interpolation.html
@@ -383,10 +383,10 @@ Dfsu - 2D interpolation
-
+
import mikeio
-
+
= mikeio.read("../data/wind_north_sea.dfsu", items="Wind speed")
ds ds
@@ -398,7 +398,7 @@ Dfsu - 2D interpolation
0: Wind speed <Wind speed> (meter per sec)
-
+
= ds.Wind_speed
da ; da.plot()
@@ -416,7 +416,7 @@ Interpolate to gridThen interpolate all data to the new grid and plot.
The interpolated data is then saved to a dfs2 file.
-
+
= da.geometry.get_overset_grid(dx=0.1)
g g
@@ -426,7 +426,7 @@ Interpolate to grid
-
+
= da.interp_like(g)
da_grid da_grid
@@ -437,7 +437,7 @@ Interpolate to grid
-
+
; da_grid.plot()
@@ -450,14 +450,14 @@ Interpolate to grid
Save to dfs2 file
-
+
"wind_north_sea_interpolated.dfs2") da_grid.to_dfs(
Save to NetCDF
-
+
= da_grid.to_xarray()
xr_da "wind_north_sea_interpolated.nc") xr_da.to_netcdf(
@@ -478,7 +478,7 @@ Save to GeoTiff
This section requires the rasterio
package.
-
+
import numpy as np
import rasterio
from rasterio.transform import from_origin
@@ -502,7 +502,7 @@ Save to GeoTiff
Interpolate to other mesh
Interpolate the data from this coarse mesh onto a finer resolution mesh
-
+
= mikeio.Mesh('../data/north_sea_2.mesh')
msh msh
@@ -512,7 +512,7 @@ Interpolate to other mesh
projection: LONG/LAT
-
+
= da.interp_like(msh)
dsi dsi
@@ -523,7 +523,7 @@ Interpolate to other mesh
geometry: Dfsu2D (2259 elements, 1296 nodes)
-
+
0].plot(figsize=(9,7), show_mesh=True); da[
@@ -533,7 +533,7 @@ Interpolate to other mesh
-
+
0].plot(figsize=(9,7), show_mesh=True); dsi[
@@ -545,14 +545,14 @@ Interpolate to other mesh
Note: 3 of the new elements are outside the original mesh and data are therefore NaN by default
-
+
= np.where(np.isnan(dsi[0].to_numpy()))[0]
nan_elements nan_elements
array([ 249, 451, 1546])
-
+
2]) da.geometry.contains(msh.element_coordinates[nan_elements,:
array([False, False, False])
@@ -561,10 +561,10 @@
We can force extrapolation to avoid the NaN values
-
+
= da.interp_like(msh, extrapolate=True) dat_interp
-
+
= np.sum(np.isnan(dat_interp.values))
n_nan_elements n_nan_elements
@@ -577,14 +577,14 @@ Interpola
We want to interpolate scatter data onto an existing mesh and create a new dfsu with the interpolated data.
This uses lower level private utility methods not part of the public API.
Interpolating from scatter data will soon be possible in a simpler way.
-
+
from mikeio.spatial._utils import dist_in_meters
from mikeio._interpolation import get_idw_interpolant
-
+
= mikeio.open("../data/wind_north_sea.dfsu") dfs
-
+
; dfs.geometry.plot.mesh()
@@ -594,7 +594,7 @@ Interpola
-
+
# scatter data: x,y,value for 4 points
= np.array([[1,50,1], [4, 52, 3], [8, 55, 2], [-1, 55, 1.5]])
scatter scatter
@@ -611,35 +611,35 @@ Interpola
calc IDW interpolatant weights
Interpolate
-
+
= dist_in_meters(scatter[:,:2], dfs.geometry.element_coordinates[0,:2])
dist dist
array([4.00139539, 3.18881018, 6.58769411, 2.69722991])
-
+
= get_idw_interpolant(dist, p=2)
w w
array([0.19438779, 0.30607974, 0.07171749, 0.42781498])
-
+
2], w) # interpolated value in element 0 np.dot(scatter[:,
np.float64(1.8977844597276883)
Let’s do the same for all points in the mesh and plot in the end
-
+
= np.zeros((1, dfs.geometry.n_elements))
dati for j in range(dfs.geometry.n_elements):
= dist_in_meters(scatter[:, :2], dfs.geometry.element_coordinates[j, :2])
dist = get_idw_interpolant(dist, p=2)
w 0, j] = np.dot(scatter[:, 2], w) dati[
-
+
= mikeio.DataArray(data=dati, geometry=dfs.geometry, time=dfs.start_time)
da da
@@ -650,7 +650,7 @@ Interpola
geometry: Dfsu2D (958 elements, 570 nodes)
-
+
="Interpolated scatter data"); da.plot(title
@@ -660,13 +660,13 @@ Interpola
-
+
"interpolated_scatter.dfsu") da.to_dfs(
Clean up
-
+
import os
"wind_north_sea_interpolated.dfs2")
diff --git a/examples/Generic.html b/examples/Generic.html
index 3b075f881..dac9fa20e 100644
--- a/examples/Generic.html
+++ b/examples/Generic.html
@@ -394,7 +394,7 @@ os.remove(Generic dfs processing
quantile: Create temporal quantiles of dfs file
-
+