Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bounds attrs are not dropped for dropped variables #799

Open
veenstrajelmer opened this issue Mar 4, 2024 · 2 comments
Open

bounds attrs are not dropped for dropped variables #799

veenstrajelmer opened this issue Mar 4, 2024 · 2 comments

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Mar 4, 2024

Bounds attrs are not dropped when linked variables are dropped upon merging. For instance, when merging the grevelingen mapfiles, the variables 'mesh2d_face_x_bnd' and 'mesh2d_face_y_bnd' since they cannot be aligned. However, the variables mesh2d_face_x and mesh2d_face_y have bounds attrs that are not dropped. When writing this to a file, we therefore end up with references to variables that are not available anymore.

MWE:

import dfm_tools as dfmt
uds = dfmt.data.fm_grevelingen_map()
print(uds.mesh2d_face_x.attrs)

Prints: {'units': 'm', 'standard_name': 'projection_x_coordinate', 'long_name': 'Characteristic x-coordinate of mesh face', 'mesh': 'mesh2d', 'location': 'face', 'bounds': 'mesh2d_face_x_bnd'}

@mgeraeds
Copy link

mgeraeds commented Mar 8, 2024

Adding on this, manually removing the bounds from the attributes does not seem to work; they will not be dropped, even with del uds['mesh2d_face_x'].attrs['bounds']. I only got it to work when first writing from an xu.UgridDataset to an xr.Dataset and then dropping the variables (through writing new attrs or using del on the 'bounds' attr).

@veenstrajelmer
Copy link
Collaborator Author

veenstrajelmer commented Mar 20, 2024

@mgeraeds you are referring to a quickplot crash when opening such a dataset. This happened only with a very old quickplot version (from 2018). With version 2.65.140745 (13-Feb-2022) and also higher versions, the missing bounds variables give a warning, but there is no crash and QuickPlot functions normally. It should still be solved eventually, but manually dropping the bounds attrs seems not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants