@@ -183,20 +183,31 @@ def get_layer_data(data, variable, layer_index=-1, time_index=-1):
183183 v = np .ma .getdata (var [time_index ,:], False )
184184
185185 #waterdepth
186- cords_to_layers = {'FlowElem_xcc FlowElem_ycc' :{'name' :'laydim' ,
187- 'coords' :data .variables ['LayCoord_cc' ][:]},
188- 'FlowLink_xu FlowLink_yu' : {'name' :'wdim' ,
189- 'coords' :data .variables ['LayCoord_w' ][:]}}
186+ if "mesh2d" in variable :
187+ cords_to_layers = {'mesh2d_face_x mesh2d_face_y' : {'name' :'mesh2d_nLayers' ,
188+ 'coords' :data .variables ['mesh2d_layer_sigma' ][:]},
189+ 'mesh2d_edge_x mesh2d_edge_y' : {'name' :'mesh2d_nInterfaces' ,
190+ 'coords' :data .variables ['mesh2d_interface_sigma' ][:]}}
191+ bottom_depth = np .ma .getdata (data .variables ['mesh2d_waterdepth' ][time_index , :], False )
192+ waterlevel = np .ma .getdata (data .variables ['mesh2d_s1' ][time_index , :], False )
193+ coords = str (data .variables ['waterdepth' ].coordinates ).split ()
194+
195+ else :
196+ cords_to_layers = {'FlowElem_xcc FlowElem_ycc' :{'name' :'laydim' ,
197+ 'coords' :data .variables ['LayCoord_cc' ][:]},
198+ 'FlowLink_xu FlowLink_yu' : {'name' :'wdim' ,
199+ 'coords' :data .variables ['LayCoord_w' ][:]}}
200+ bottom_depth = np .ma .getdata (data .variables ['waterdepth' ][time_index , :], False )
201+ waterlevel = np .ma .getdata (data .variables ['s1' ][time_index , :], False )
202+ coords = str (data .variables ['waterdepth' ].coordinates ).split ()
203+
190204 layer_dim = str (data .variables [variable ].coordinates )
191205
192-
193206 cord_sys = cords_to_layers [layer_dim ]['coords' ]
194207 layer_percentages = np .ma .getdata (cord_sys , False ) #accumulative
195- bottom_depth = np .ma .getdata (data .variables ['waterdepth' ][time_index , :], False )
196- waterlevel = np .ma .getdata (data .variables ['s1' ][time_index , :], False )
208+
197209 if layer_dim == 'FlowLink_xu FlowLink_yu' :
198210 #interpolate
199- coords = str (data .variables ['waterdepth' ].coordinates ).split ()
200211 x_laydim = np .ma .getdata (data .variables [coords [0 ]][:], False )
201212 y_laydim = np .ma .getdata (data .variables [coords [1 ]][:], False )
202213 points_laydim = np .array ([ [x , y ] for x , y in zip (x_laydim , y_laydim )])
@@ -464,10 +475,16 @@ def get_all_data_points(data, variable, time_index=-1):
464475 assert abs (time_index ) <= max_time_index , (f'time_index must be less than'
465476 + 'the max time index {max_time_index}' )
466477
467- cords_to_layers = {'FlowElem_xcc FlowElem_ycc' :{'name' :'laydim' ,
468- 'coords' :data .variables ['LayCoord_cc' ][:]},
469- 'FlowLink_xu FlowLink_yu' : {'name' :'wdim' ,
470- 'coords' :data .variables ['LayCoord_w' ][:]}}
478+ if "mesh2d" in variable :
479+ cords_to_layers = {'mesh2d_face_x mesh2d_face_y' : {'name' :'mesh2d_nLayers' ,
480+ 'coords' :data .variables ['mesh2d_layer_sigma' ][:]},
481+ 'mesh2d_edge_x mesh2d_edge_y' : {'name' :'mesh2d_nInterfaces' ,
482+ 'coords' :data .variables ['mesh2d_interface_sigma' ][:]}}
483+ else :
484+ cords_to_layers = {'FlowElem_xcc FlowElem_ycc' :{'name' :'laydim' ,
485+ 'coords' :data .variables ['LayCoord_cc' ][:]},
486+ 'FlowLink_xu FlowLink_yu' : {'name' :'wdim' ,
487+ 'coords' :data .variables ['LayCoord_w' ][:]}}
471488
472489 layer_dim = str (data .variables [variable ].coordinates )
473490
0 commit comments