Closed veenstrajelmer closed 5 months ago
Seems easy to fix, fortunately. When calling from_dataset, a _prepare_connectivity
method is called in Ugrid1d, Ugrid2d.
https://github.com/Deltares/xugrid/blob/a140d3144c483e3e4d8292f12fd03dea435b3814/xugrid/ugrid/ugridbase.py#L385
The problem is this line: https://github.com/Deltares/xugrid/blob/a140d3144c483e3e4d8292f12fd03dea435b3814/xugrid/ugrid/ugridbase.py#L392
If we use data.to_numpy().copy()
here, we should be good?
face_node_connectivity in original dataset is corrupted by
xu.core.wrap.UgridDataset
. The minimal value is 1 before, and -999 (the fillvalue) after wrapping it. This is normally not a problem, but in some of the workflows we wrap them preliminary to identify hanging edges, before we do some other actions on the dataset (like removing these edges) and than wrap it again. If we deepcopy the ds before we wrap it, no issue occurs.To reproduce Minimal reproducible example:
Expected behaviour No alteration of input
ds
byxu.core.wrap.UgridDataset
Additional info This was initially documented in https://github.com/Deltares/dfm_tools/issues/680, but that issue did not yet contain a minimal xugrid/xarray example.