-
Notifications
You must be signed in to change notification settings - Fork 32
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 #1056
base: main
Are you sure you want to change the base?
Point In Face #1056
Conversation
@ philipc2 do you think this should be an internal function or exposed to the user? |
There was a problem hiding this 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.
There was a problem hiding this 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!
The Can we implement a uxgrid = ...
# return the indicies of faces that contain the point (0, 90)
face_indices = uxgrid.get_faces_containing_point((0.0, 90.0)) I believe we have discussed this before, and a good approach would be to find the maximum radius of each face and use that to query our BallTree of the face centers. This should narrow down the possible candidates instead of needing to run |
I recommend minimizing coordinate conversions as much as possible, as they can introduce unnecessary floating-point errors. Since we already construct and store both Cartesian and spherical coordinates internally in the data array, it’s better to stick to one coordinate system. If the other system is needed, we should first retrieve it from the stored conversions rather than recomputing it. |
This would return a single face always correct? Since faces don't overlap. |
…/uxarray into zedwick/point-in-polygon
The majority of the time it would only return one, however for the case where the point is exactly on the nodes or edges (i.e. |
Ah, that is true I hadn't thought of that. Thanks for the clarification, I will work on adding that to this PR |
@hongyuchen1030 Could you give the point in the polygon function a review? The first test case |
Looking into it right now My error messages are # Assert that the point is not in the polygon
self.assertFalse(
> point_in_polygon(polygon_xyz, polygon_lonlat, point_xyz, point_lonlat, ref_point_xyz, ref_point_lonlat))
E TypeError: point_in_polygon() takes from 4 to 5 positional arguments but 6 were given
test_geometry.py:1623: TypeError And only the first one, |
The other test cases are not updated to handle the new conditions of passing in both lon and lat. The passing test case is only passing because I commented out the assertion statement. Sorry for the confusion. |
By any chance you know which specific face is not passing? |
Half the faces don't pass, and the other half do. The first 3 at least fail, if I remember correctly. Interestingly, with your changes on a gca_gca intersection to make it cartesian only, it works better if the reference point is changed to be next to the pole but not the pole itself. However, there hasn't been any improvement when doing the same thing with the current implementation of the intersection code. So something seems to have changed from the changes you are making in that PR. |
uxarray/test/test_intersections.py Lines 95 to 114 in f783f61
I've added the test case here in #1112 The correct intersection is computed up to |
Thanks for this Philip. |
@hongyuchen1030 using your branch and the code from this branch, it works properly when the reference point is not on the pole, so whatever the issue seems to be fixed in that PR. Thanks for taking the time to look at this for me though! |
I think me and @philipc2 had resolved this through the recently merged branch #1112 , Thanks again for @philipc2's help. With the updated algorithm, it should work for the the pole point as well now. |
Closes #905
Overview
Expected Usage
PR Checklist
General
Testing
Documentation
_
) and have been added todocs/internal_api/index.rst
docs/user_api/index.rst