This method currently has limited functionality for spatial interpolation. It will be extended in the future.
The spatial parameters available depend on the geometry of the Dataset:
Grid1D: x
Grid2D: x, y
Grid3D: [not yet implemented!]
GeometryFM: (x,y)
GeometryFMLayered: (x,y) [surface point will be returned!]
Parameters
Name
Type
Description
Default
time
(float, pd.DatetimeIndex or DataArray)
timestep in seconds or discrete time instances given by pd.DatetimeIndex (typically from another DataArray da2.time), by default None (=don’t interp in time)
None
x
float
x-coordinate of point to be interpolated to, by default None
None
y
float
y-coordinate of point to be interpolated to, by default None
None
z
float
z-coordinate of point to be interpolated to, by default None
None
n_nearest
int
When using IDW interpolation, how many nearest points should be used, by default: 3
3
interpolant
tuple
Precomputed interpolant, by default None
None
**kwargs
Any
Additional keyword arguments to be passed to the interpolation
{}
Returns
Name
Type
Description
DataArray
new DataArray with interped data
See Also
sel : Select data using label indexing interp_like : Interp to another time/space of another DataArray interp_time : Interp in the time direction only
Examples
>>> da = mikeio.read("random.dfs1")[0]>>> da.interp(time=3600)>>> da.interp(x=110)
>>> da = mikeio.read("HD2D.dfsu").Salinity>>> da.interp(x=340000, y=6160000)
Specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’, where ‘zero’, ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of zeroth, first, second or third order; ‘previous’ and ‘next’ simply return the previous or next value of the point) or as an integer specifying the order of the spline interpolator to use. Default is ‘linear’.
'linear'
extrapolate
bool
Default True. If False, a ValueError is raised any time interpolation is attempted on a value outside of the range of x (where extrapolation is necessary). If True, out of bounds values are assigned fill_value
True
fill_value
float
Default NaN. this value will be used to fill in for points outside of the time range.
np.nan
Returns
Name
Type
Description
DataArray
isel
DataArray.isel(idx=None, axis=0, **kwargs)
Return a new DataArray whose data is given by integer indexing along the specified dimension(s).
Note that the data will be a view of the original data if possible (single index or slice), otherwise a copy (fancy indexing) following NumPy convention.
The spatial parameters available depend on the dims (i.e. geometry) of the DataArray:
Grid1D: x
Grid2D: x, y
Grid3D: x, y, z
GeometryFM: element
Parameters
Name
Type
Description
Default
idx
int | Sequence[int] | slice | None
Index, or indices, along the specified dimension(s)
None
axis
int | str
axis number or “time”, by default 0
0
time
int
time index,by default None
required
x
int
x index, by default None
required
y
int
y index, by default None
required
z
int
z index, by default None
required
element
int
Bounding box of coordinates (left lower and right upper) to be selected, by default None
required
**kwargs
Any
Not used
{}
Returns
Name
Type
Description
DataArray
new DataArray with selected data
See Also
dims : Get axis names sel : Select data using labels
Examples
da = mikeio.read("../data/europe_wind_long_lat.dfs2")[0]da
da = mikeio.read("../data/oresund_sigma_z.dfsu").Temperatureda.isel(element=range(200))
<mikeio.DataArray>
name: Temperature
dims: (time:3, element:200)
time: 1997-09-15 21:00:00 - 1997-09-16 03:00:00 (3 records)
geometry: Flexible Mesh Geometry: Dfsu3DSigmaZ
number of nodes: 638
number of elements: 200
number of layers: 6
number of sigma layers: 4
projection: UTM-33
max
DataArray.max(axis=0, **kwargs)
Max value along an axis.
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with max values
See Also
nanmax : Max values with NaN values removed
mean
DataArray.mean(axis=0, **kwargs)
Mean value along an axis.
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with mean values
See Also
nanmean : Mean values with NaN values removed
min
DataArray.min(axis=0, **kwargs)
Min value along an axis.
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with min values
See Also
nanmin : Min values with NaN values removed
nanmax
DataArray.nanmax(axis=0, **kwargs)
Max value along an axis (NaN removed).
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with max values
See Also
nanmax : Max values with NaN values removed
nanmean
DataArray.nanmean(axis=0, **kwargs)
Mean value along an axis (NaN removed).
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with mean values
See Also
mean : Mean values
nanmin
DataArray.nanmin(axis=0, **kwargs)
Min value along an axis (NaN removed).
Parameters
Name
Type
Description
Default
axis
int | str
axis number or “time” or “space”, by default 0
0
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
array with min values
See Also
nanmin : Min values with NaN values removed
nanquantile
DataArray.nanquantile(q, *, axis=0, **kwargs)
Compute the q-th quantile of the data along the specified axis, while ignoring nan values.
Wrapping np.nanquantile
Parameters
Name
Type
Description
Default
q
float | Sequence[float]
Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive.
Return a new DataArray whose data is given by selecting index labels along the specified dimension(s).
In contrast to DataArray.isel, indexers for this method should use labels instead of integers.
The spatial parameters available depend on the geometry of the DataArray:
Grid1D: x
Grid2D: x, y, coords, area
Grid3D: [not yet implemented! use isel instead]
GeometryFM: (x,y), coords, area
GeometryFMLayered: (x,y,z), coords, area, layers
Parameters
Name
Type
Description
Default
time
(str, pd.DatetimeIndex, DataArray)
time labels e.g. “2018-01” or slice(“2018-1-1”,“2019-1-1”), by default None
None
x
float
x-coordinate of point to be selected, by default None
required
y
float
y-coordinate of point to be selected, by default None
required
z
float
z-coordinate of point to be selected, by default None
required
coords
np.array(float, float)
As an alternative to specifying x, y and z individually, the argument coords can be used instead. (x,y)- or (x,y,z)-coordinates of point to be selected, by default None
required
area
(float, float, float, float)
Bounding box of coordinates (left lower and right upper) to be selected, by default None
required
layers
int or str or list
layer(s) to be selected: “top”, “bottom” or layer number from bottom 0,1,2,… or from the top -1,-2,… or as list of these; only for layered dfsu, by default None
required
**kwargs
Any
Additional keyword arguments
{}
Returns
Name
Type
Description
DataArray
new DataArray with selected data
See Also
isel : Select data using integer indexing interp : Interp data in time and space
da = mikeio.read("../data/oresund_sigma_z.dfsu").Temperatureda
<mikeio.DataArray>
name: Temperature
dims: (time:3, element:17118)
time: 1997-09-15 21:00:00 - 1997-09-16 03:00:00 (3 records)
geometry: Flexible Mesh Geometry: Dfsu3DSigmaZ
number of nodes: 12042
number of elements: 17118
number of layers: 9
number of sigma layers: 4
projection: UTM-33
da.sel(time="1997-09-15")
<mikeio.DataArray>
name: Temperature
dims: (element:17118)
time: 1997-09-15 21:00:00 (time-invariant)
geometry: Flexible Mesh Geometry: Dfsu3DSigmaZ
number of nodes: 12042
number of elements: 17118
number of layers: 9
number of sigma layers: 4
projection: UTM-33
values: [16.31, 16.43, ..., 16.69]