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

Associate data from one aspect (node, face, edge) to another aspect (node, face, edge) #173

Open
Huite opened this issue Nov 14, 2023 · 0 comments

Comments

@Huite
Copy link
Collaborator

Huite commented Nov 14, 2023

E.g. if we have data defined on the nodes, and not on the faces, we can "interpolate" the data from the nodes to the edges. The easiest way to do so is via the connectivity arrays. The most straightforward way is by directly indexing, and then reducing.

For the rectangular connectivities, this could be done directly, although the indexing operation is extremely slow in delayed operations (due to a dask bug) -- but this can be worked around by stacking and unstacking xarray arrays.

However, such operations do not work as nicely for the more irregular connectivities like the node_face_connectivity, which is now returned as sparse array. These can be converted to dense rectangular arrays, but an alternative is converting to COO format, to get the row numbers. The row numbers can then be used in a groupby reduction.

This opens another nice option, which is to parametrize the reduce operation. Like pandas / xarray groupby or resample, the objects has associated reduction methods, e.g. groupby("...").sum() or groupby("...").mean(). By returning the groupby object (or something similar), the user can make their own choice in the reduction method.

The methods would be defined on the UgridDataArray accessor, since the data is by definition associated with only one aspect.

API could look something like:

uda.to_face().mean()  # only valid for node and edge data
uda.to_node().sum()  # only valid for edge and face data
uda.to_edge().max()  # only valid for node and face data
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

1 participant