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

Add Inverse Face Indices to Subsetted Grids #1122

Merged
merged 20 commits into from
Jan 9, 2025

Conversation

aaronzedwick
Copy link
Member

Closes #1114

Overview

Expected Usage

import uxarray as ux

grid_path = "/path/to/grid.nc"

grid = ux.open_grid(grid_path)

coord = [0, 0]
subset = grid.subset.nearest_neighbor(coord, k=1, element="face centers", inverse_indices=True)

inverse_face_indices = subset.inverse_face_indices.values

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Docstrings have updated with any function changes
  • Internal functions have a preceding underscore (_) and have been added to docs/internal_api/index.rst
  • User functions have been added to docs/user_api/index.rst

@aaronzedwick aaronzedwick changed the title Adds Inverse Face Indices to Subsetted Grids Add Inverse Face Indices to Subsetted Grids Jan 2, 2025
@aaronzedwick aaronzedwick requested a review from philipc2 January 2, 2025 22:15
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial implementation looks good; a few design considerations.

uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/slice.py Outdated Show resolved Hide resolved
@philipc2
Copy link
Member

philipc2 commented Jan 3, 2025

May you include this in the cross_section implementations also?

@aaronzedwick
Copy link
Member Author

aaronzedwick commented Jan 3, 2025

May you include this in the cross_section implementations also?

Sure. Would that be a different attribute or stored in the same inverse indices?

@philipc2
Copy link
Member

philipc2 commented Jan 3, 2025

May you include this in the cross_section implementations also?

Sure. Would that be a different attribute or stored in the same inverse indices?

Should be the same parameter for consistency, stored within the inverse_indices

@aaronzedwick aaronzedwick requested a review from philipc2 January 3, 2025 22:00
uxarray/grid/grid.py Outdated Show resolved Hide resolved
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidently approved in the previous review, please disregard.

@aaronzedwick aaronzedwick requested a review from philipc2 January 6, 2025 19:51
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a test that directly uses Grid.isel(). Docstrings need to be updated to describe the inverse_indicesparameter.

uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Show resolved Hide resolved
@aaronzedwick aaronzedwick requested a review from philipc2 January 7, 2025 16:01
@aaronzedwick aaronzedwick requested a review from rajeeja January 7, 2025 21:05
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work.

There are a few instances where you refer to "face indices" as "face centers".

Can you make sure that we refer to the indices as "node", "edge" and "face" instead of reffering to them as "node center", "edge center", or "face center"

uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Outdated Show resolved Hide resolved
uxarray/grid/grid.py Outdated Show resolved Hide resolved
@rajeeja
Copy link
Contributor

rajeeja commented Jan 8, 2025

Seems to work, still parsing the code, in the meantime - it'd be good to add or extend one of the examples in subset.ipynb

@aaronzedwick
Copy link
Member Author

Seems to work, still parsing the code, in the meantime - it'd be good to add or extend one of the examples in subset.ipynb

Yeah, this had crossed my mind as well.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@aaronzedwick aaronzedwick requested a review from philipc2 January 8, 2025 19:41
@aaronzedwick aaronzedwick requested a review from philipc2 January 9, 2025 18:45
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @aaronzedwick !

Three small comments, otherwise all looks fantastic.

uxarray/grid/grid.py Show resolved Hide resolved
uxarray/grid/grid.py Show resolved Hide resolved
test/test_subset.py Show resolved Hide resolved
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Copy link
Member

@philipc2 philipc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@philipc2 philipc2 merged commit 0e45eda into main Jan 9, 2025
15 checks passed
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

Successfully merging this pull request may close these issues.

Add an inverse_indices attribute to isel
3 participants