Skip to content

Commit bbbdf67

Browse files
committed
begin to add xarray capability and add new variables in coords
1 parent fadc989 commit bbbdf67

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

mhkit/river/io/d3d.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def get_all_time(data: netCDF4.Dataset) -> NDArray:
3535
simulation conditions at that time.
3636
"""
3737

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

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

@@ -244,6 +244,10 @@ def get_layer_data(
244244
"name": "mesh2d_nLayers",
245245
"coords": data.variables["mesh2d_layer_sigma"][:],
246246
},
247+
"mesh2d_face_x mesh2d_face_y mesh2d_layer_sigma": {
248+
"name": "mesh2d_nLayers",
249+
"coords": data.variables["mesh2d_layer_sigma"][:],
250+
},
247251
"mesh2d_edge_x mesh2d_edge_y": {
248252
"name": "mesh2d_nInterfaces",
249253
"coords": data.variables["mesh2d_interface_sigma"][:],
@@ -637,6 +641,10 @@ def get_all_data_points(
637641
"name": "mesh2d_nLayers",
638642
"coords": data.variables["mesh2d_layer_sigma"][:],
639643
},
644+
"mesh2d_face_x mesh2d_face_y mesh2d_layer_sigma": {
645+
"name": "mesh2d_nLayers",
646+
"coords": data.variables["mesh2d_layer_sigma"][:],
647+
},
640648
"mesh2d_edge_x mesh2d_edge_y": {
641649
"name": "mesh2d_nInterfaces",
642650
"coords": data.variables["mesh2d_interface_sigma"][:],

0 commit comments

Comments
 (0)