read
*, items=None, time=None, keepdims=False, **kwargs) read(filename,
Read all or a subset of the data from a dfs file.
All dfs files can be subsetted with the items and time arguments. But the following file types also have the shown additional arguments:
- Dfs2: area
- Dfs3: layers
- Dfsu-2d: (x,y), elements, area
- Dfsu-layered: (xy,z), elements, area, layers
Parameters
Name | Type | Description | Default |
---|---|---|---|
filename | str | Path | full path and file name to the dfs file. | required |
items | str | int | Sequence[str | int] | None | Read only selected items, by number (0-based), or by name, by default None (=all) | None |
time | int | str | slice | None | Read only selected time steps, by default None (=all) | None |
keepdims | bool | When reading a single time step only, should the time-dimension be kept in the returned Dataset? by default: False | False |
x | Dfsu: Read only data for elements containing the (x,y) or (x,y,z) points(s), by default None | required | |
y | Dfsu: Read only data for elements containing the (x,y) or (x,y,z) points(s), by default None | required | |
z | Dfsu: Read only data for elements containing the (x,y) or (x,y,z) points(s), by default None | required | |
area | Dfs2/Dfsu: read only data within an area given by a bounding box of coordinates (left, lower, right, upper), by default None (=all) | required | |
layers | Dfs3/Dfsu-layered: read only data from specific layers, by default None (=all layers) | required | |
error_bad_data | raise error if data is corrupt, by default True, | required | |
fill_bad_data_value | fill value for to impute corrupt data, used in conjunction with error_bad_data=False default np.nan | required | |
**kwargs | Any | Additional keyword arguments | {} |
Returns
Name | Type | Description |
---|---|---|
Dataset | A Dataset with specification according to the file type |
See also
mikeio.open - open a Dfs file and only read the header
Examples
>>> ds = mikeio.read("ts.dfs0")
>>> ds = mikeio.read("ts.dfs0", items=0)
>>> ds = mikeio.read("ts.dfs0", items="Temperature")
>>> ds = mikeio.read("sw_points.dfs0, items="*Buoy 4*")
>>> ds = mikeio.read("ts.dfs0", items=["u","v"], time="2016")
>>> ds = mikeio.read("tide.dfs1", time="2018-5")
>>> ds = mikeio.read("tide.dfs1", time=slice("2018-5-1","2018-6-1"))
>>> ds = mikeio.read("tide.dfs1", items=[0,3,6], time=-1)
>>> ds = mikeio.read("tide.dfs1", time=-1, keepdims=True)
>>> ds = mikeio.read("era5.dfs2", area=(10,50,16,58))
>>> ds = mikeio.read("HD2D.dfsu")
>>> ds = mikeio.read("HD2D.dfsu", x=2.2, y=54.2)
>>> ds = mikeio.read("HD2D.dfsu", elements=183)
>>> ds = mikeio.read("HD2D.dfsu", elements=range(0,2000))
>>> ds = mikeio.read("HD2D.dfsu", area=(10,50,16,58))
>>> ds = mikeio.read("MT3D_sigma_z.dfsu", x=11.4, y=56.2)
>>> ds = mikeio.read("MT3D_sigma_z.dfsu", x=11.4, y=56.2, z=-1.1)
>>> ds = mikeio.read("MT3D_sigma_z.dfsu", elements=lst_of_elems)
>>> ds = mikeio.read("MT3D_sigma_z.dfsu", layers="bottom")
>>> ds = mikeio.read("MT3D_sigma_z.dfsu", layers=[-2,-1])
>>> ds = mikeio.read("HD2D.dfsu", error_bad_data=False) # replace corrupt data with np.nan
>>> ds = mikeio.read("HD2D.dfsu", error_bad_data=False, fill_bad_data_value=0.0) # replace corrupt data with 0.0