Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions mhkit/river/io/d3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def get_all_time(data: netCDF4.Dataset) -> NDArray:
simulation conditions at that time.
"""

if not isinstance(data, netCDF4.Dataset):
raise TypeError("data must be a NetCDF4 object")
if not isinstance(data, (netCDF4.Dataset, xr.Dataset)):
raise TypeError("data must be a NetCDF4 object or xarray Dataset")

seconds_run = np.ma.getdata(data.variables["time"][:], False)

Expand Down Expand Up @@ -244,6 +244,10 @@ def get_layer_data(
"name": "mesh2d_nLayers",
"coords": data.variables["mesh2d_layer_sigma"][:],
},
"mesh2d_face_x mesh2d_face_y mesh2d_layer_sigma": {
"name": "mesh2d_nLayers",
"coords": data.variables["mesh2d_layer_sigma"][:],
},
"mesh2d_edge_x mesh2d_edge_y": {
"name": "mesh2d_nInterfaces",
"coords": data.variables["mesh2d_interface_sigma"][:],
Expand All @@ -253,7 +257,7 @@ def get_layer_data(
data.variables["mesh2d_waterdepth"][time_index, :], False
)
waterlevel = np.ma.getdata(data.variables["mesh2d_s1"][time_index, :], False)
coords = str(data.variables["waterdepth"].coordinates).split()
coords = str(data.variables["mesh2d_waterdepth"].coordinates).split()

elif str(data.variables[variable].coordinates) == "FlowElem_xcc FlowElem_ycc":
cords_to_layers = {
Expand Down Expand Up @@ -637,6 +641,10 @@ def get_all_data_points(
"name": "mesh2d_nLayers",
"coords": data.variables["mesh2d_layer_sigma"][:],
},
"mesh2d_face_x mesh2d_face_y mesh2d_layer_sigma": {
"name": "mesh2d_nLayers",
"coords": data.variables["mesh2d_layer_sigma"][:],
},
"mesh2d_edge_x mesh2d_edge_y": {
"name": "mesh2d_nInterfaces",
"coords": data.variables["mesh2d_interface_sigma"][:],
Expand Down
Loading