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

uds.ugrid.sel_points() also broadcasts face_dimension on variables without it #274

Open
veenstrajelmer opened this issue Aug 13, 2024 · 1 comment

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Aug 13, 2024

The code below adds a face_dimension to variables that not defined there if some of the points are out of bounds.

import numpy as np
import xugrid as xu
import xarray as xr

uds = xu.data.adh_san_diego()
facedim = uds.grid.face_dimension
facesize = uds.grid.sizes[facedim]
uds['face_var'] = xr.DataArray(np.ones((facesize)), dims=facedim)
ds = uds.ugrid.sel_points(x=[475153,475153,1],y=[3621027,3621027,1])

print(uds.elevation.dims)
print(ds.elevation.dims)

Prints:

('node',)
('node', 'face')

If only providing points that are in bounds, this issue does not occur and ds.elevation has only a node dimension.

@veenstrajelmer veenstrajelmer changed the title uds.ugrid.sel_points() also broadcasts face_dimension on variables without it. uds.ugrid.sel_points() also broadcasts face_dimension on variables without it Aug 13, 2024
@Huite
Copy link
Collaborator

Huite commented Aug 13, 2024

This is due to the fact that isel doesn't broadcast, but .where does.

Might have to solve it by filtering variables based on dimension, then only applying where if the dimension is present.

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