diff --git a/mhkit/river/io/d3d.py b/mhkit/river/io/d3d.py index 7295d7e1..f0491e69 100644 --- a/mhkit/river/io/d3d.py +++ b/mhkit/river/io/d3d.py @@ -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) @@ -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"][:], @@ -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 = { @@ -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"][:],