Skip to content

Commit cd78e8b

Browse files
committed
more robust reading of DFM grids
1 parent ec2229e commit cd78e8b

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

stompy/grid/multi_ugrid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def __init__(self,paths,cleanup_dfm='auto',xr_kwargs={},grid=None,
394394
if f in g.cells.dtype.names:
395395
log.warning("Dropping extra cell field %s to avoid max_sides issues"%f)
396396
g.delete_cell_field(f)
397+
g.edge_to_cells(recalc=True) # 20250813: failing to merge, seems to be edge ordering.
397398
if is_dfm:
398399
# kludge DFM output (ver. 2021.03) has nNetElem and nFlowElem, which appear to
399400
# both be for the cell dimension

stompy/grid/unstructured_grid.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,14 @@ def process_as_index(varname):
865865
if 'face_edge_connectivity' in mesh.attrs:
866866
v=mesh.attrs['face_edge_connectivity']
867867
if v in nc:
868+
start_index=nc[v].attrs.get('start_index',0)
868869
# Some files advertise variable they don't have. Trust no one.
869-
ug.cells['edges'] = nc[v].values
870+
ug.cells['edges'] = nc[v].values - start_index
870871
if 'edge_face_connectivity' in mesh.attrs:
871872
v=mesh.attrs['edge_face_connectivity']
872873
if v in nc:
873-
cells = nc[v].values
874+
start_index=nc[v].attrs.get('start_index',0)
875+
cells = nc[v].values - start_index
874876
ug.edges['cells'] = np.where( np.isfinite(cells), cells, -1)
875877

876878
if dialect=='fishptm':

0 commit comments

Comments
 (0)