Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
65 stars 8 forks source link

contourf fails for face variables with tri/quad mixed topologies #298

Closed veenstrajelmer closed 2 months ago

veenstrajelmer commented 2 months ago

Since xugrid 0.12.0 contourf raises "ValueError: triangles are indices into the points and must be in the range 0 <= i < 6906 but found value -1". This cannot be reproduced with xugrid test datasets. I expect that it only happens for datsets containing both quads and triangles (so -1 values in the face_node_connectivity) and maybe the fact that this variable is defined on the faces is also relevant.

import xugrid as xu
file_nc = 'Grevelingen-FM_0000_map.nc'
uds = xu.open_dataset(file_nc)
uds['mesh2d_flowelem_bl'].ugrid.plot.contourf()

This code works fine with xugrid 0.11.2, so I expect something was changed in the code and this usecase is also not covered by tests.