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

Point In Face & Get Faces Containing Point #1056

Merged
merged 104 commits into from
Mar 4, 2025
Merged

Conversation

aaronzedwick
Copy link
Member

@aaronzedwick aaronzedwick commented Nov 5, 2024

Adds several new features:

  • point_in_face function to determine if a point is in a face.
  • get_faces_containing_point which given a point finds the face (or faces) the point resides in.
  • max_face_radius which finds the largest face radius and stores it within the grid.
  • haversine_distance function which finds the haversine distance between two given points.
  • A few fixes to coordinate construction bugs

Closes #905, #1141

Overview

Expected Usage

from uxarray.grid.geometry import point_in_polygon

# Defined polygon
polygon = [ [-10,  10, -10, 10], [10, 10, -10, -10]]

# Point to check
point = [10, 10]

point_in_polygon(polygon, point, inclusive=True)

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
Copy link
Member Author

@ philipc2 do you think this should be an internal function or exposed to the user?

@aaronzedwick aaronzedwick changed the title DRAFT: Point In Polygon Point In Polygon Nov 27, 2024
@aaronzedwick aaronzedwick marked this pull request as ready for review November 27, 2024 15:13
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 an ASV benchmark. I'd suggest doing a parameterized benchmark for the 120 and 480 km MPAS grids.

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 use the optimized functions from #1072 and try to write the function entirely in Numba. This may require us to pass in both the cartesian and spherical versions of point & polygon. Let me know if you have any questions!

@philipc2 philipc2 mentioned this pull request Feb 26, 2025
6 tasks
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 add a couple points in the "Overview" of the description of this PR.

@aaronzedwick
Copy link
Member Author

aaronzedwick commented Feb 28, 2025

Please add a couple points in the "Overview" of the description of this PR.

Done! It made me realize just how big this PR has gotten!

@aaronzedwick aaronzedwick added the run-benchmark Run ASV benchmark workflow label Feb 28, 2025
Copy link
Contributor

@rajeeja rajeeja left a comment

Choose a reason for hiding this comment

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

Resolve comments.

@aaronzedwick aaronzedwick requested a review from philipc2 March 3, 2025 15:09
@aaronzedwick aaronzedwick removed the run-benchmark Run ASV benchmark workflow label Mar 3, 2025
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.

For the notebook:

  • Add an introduction below the title consistent with how other notebooks are formatted.
  • I don't think we should be showcasing the point_in_face function from the start. We should highlight the Grid functionality. I think we can restructure the notebook to remove the point_in_face part
  • Consider adding intermediate markdown blocks between each cell and try to avoid the inline comments, these should be in Markdown

image

@aaronzedwick
Copy link
Member Author

For the notebook:

  • Add an introduction below the title consistent with how other notebooks are formatted.
  • I don't think we should be showcasing the point_in_face function from the start. We should highlight the Grid functionality. I think we can restructure the notebook to remove the point_in_face part
  • Consider adding intermediate markdown blocks between each cell and try to avoid the inline comments, these should be in Markdown

image

Removing the point_in_face part doesn't leave much of the notebook left; do you think this function needs a notebook? It is a pretty self-explanatory function to use.

@philipc2
Copy link
Member

philipc2 commented Mar 4, 2025

For the notebook:

  • Add an introduction below the title consistent with how other notebooks are formatted.
  • I don't think we should be showcasing the point_in_face function from the start. We should highlight the Grid functionality. I think we can restructure the notebook to remove the point_in_face part
  • Consider adding intermediate markdown blocks between each cell and try to avoid the inline comments, these should be in Markdown

image

Removing the point_in_face part doesn't leave much of the notebook left; do you think this function needs a notebook? It is a pretty self-explanatory function to use.

Maybe we can hold off on the notebook for right now, and keep the examples contained within the docstring?

@philipc2
Copy link
Member

philipc2 commented Mar 4, 2025

Using this syntax/style would be good

    Examples
    --------
    >>> import uxarray as ux
    Open a grid from a file path
    >>> uxgrid = ux.open_grid("grid_filename.nc")

    Lazily load grid variables using Dask
    >>> uxgrid = ux.open_grid("grid_filename.nc", chunks=-1)

@aaronzedwick
Copy link
Member Author

Using this syntax/style would be good

    Examples
    --------
    >>> import uxarray as ux
    Open a grid from a file path
    >>> uxgrid = ux.open_grid("grid_filename.nc")

    Lazily load grid variables using Dask
    >>> uxgrid = ux.open_grid("grid_filename.nc", chunks=-1)

Ok! Yeah, I think this works better.

@aaronzedwick aaronzedwick requested a review from philipc2 March 4, 2025 16:55
Co-authored-by: Philip Chmielowiec <[email protected]>
@aaronzedwick aaronzedwick requested a review from philipc2 March 4, 2025 17:59
@aaronzedwick aaronzedwick requested a review from philipc2 March 4, 2025 18:34
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.

Excellent work!

@philipc2 philipc2 merged commit da45ee7 into main Mar 4, 2025
20 checks passed
aaronzedwick and others added 2 commits March 4, 2025 11:57
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.

Implement Grid.get_faces_containing_point() Point in Face
4 participants