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

Open
wants to merge 96 commits into
base: main
Choose a base branch
from

Conversation

aaronzedwick
Copy link
Member

@aaronzedwick aaronzedwick commented Nov 5, 2024

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!

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.

we need a tolerance, probably controllable by the user for this implementation

@philipc2 philipc2 mentioned this pull request Feb 24, 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.

Excellent work @aaronzedwick

A few small comments below.

Also, may you please run a few small benchmarks and profile the code on the 30km MPAS grid, similar to what I shared above.

Something like the following would be a good example:

  • Assume some fixed grid of center points, perhaps from a structured grid.
  • Compute the time it takes to determine which face each point lies within

Share the timing, with a screenshot of the profiling output like what I shared above.

aaronzedwick and others added 6 commits February 24, 2025 11:16
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
@aaronzedwick
Copy link
Member Author

@philipc2 @rajeeja Here are the profiling results you asked for!

image
Most of the time comes from the subsetting method, the actual _find_faces function takes up very little time:
image

@philipc2
Copy link
Member

@philipc2 @rajeeja Here are the profiling results you asked for!

image Most of the time comes from the subsetting method, the actual _find_faces function takes up very little time: image

Excellent! Once we optimize isel (and perhaps node_x) we will be in a great spot performance wise.

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