-
Notifications
You must be signed in to change notification settings - Fork 94
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
Refactor area boundary sides retrieval with _geographic_sides
and _projection_sides
methods
#566
Conversation
_geographic_sides
and _projection_sides
method
_geographic_sides
and _projection_sides
method_geographic_sides
and _projection_sides
methods
pyresample/gradient/__init__.py
Outdated
return False | ||
try: | ||
poly = get_polygon(self.prj, geo_def) | ||
except Exception: |
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.
Can we use a more specific exception here?
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.
Done. It can arise from
NotImplementedError
inget_geo_bounding_box
(totally out of Earth disk)ValueError
when not valid boundary coordinates (all nan or inf)ValueError
when not at least 4 valid vertices can be retrieved for boundary sides creation.
pyresample/geometry.py
Outdated
warnings.warn("The `frequency` argument is pending deprecation, use `vertices_per_side` instead", | ||
PendingDeprecationWarning, stacklevel=2) | ||
vertices_per_side = vertices_per_side or frequency | ||
x, y = self._get_bbox_elements(self.get_proj_coords, vertices_per_side) |
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.
My only guess is to merge with main
and see if it behaves better.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #566 +/- ##
==========================================
- Coverage 94.09% 94.06% -0.04%
==========================================
Files 85 85
Lines 13235 13250 +15
==========================================
+ Hits 12453 12463 +10
- Misses 782 787 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@djhoese ok now it works. Ready for review and eventually merge ;) |
@@ -1563,8 +1598,16 @@ def is_geostationary(self): | |||
return False | |||
return 'geostationary' in coord_operation.method_name.lower() | |||
|
|||
def _get_geo_boundary_sides(self, vertices_per_side=None): | |||
"""Retrieve the boundary sides list for geostationary projections.""" | |||
def _get_geostationary_boundary_sides(self, vertices_per_side=None, coordinates="geographic"): |
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.
I'm not a huge fan of this keyword argument, but this is also a private method at the moment so maybe it's OK for now. I can see how the beginning and end of the method are the same so splitting it into two separate methods based on coordinate type would be annoying. @mraspaud other ideas?
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.
I would suggest to merge meanwhile, and we can split this in two functions later on ...
With this PR merged, I can open other 3 parallel PRs.
new_dim1_sides = [] | ||
new_dim2_sides = [] | ||
for dim1_side, dim2_side in zip(dim1_sides, dim2_sides): | ||
# FIXME: ~(~np.isfinite(dim1_side) | ~np.isfinite(dim1_side)) |
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.
Does something need to happen with this?
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.
Right now Inf
that are present somewhere on the boundary can pass in the sides (and mess up stuffs in downstream tasks). But I can't set this now, because for all out-of-Earth boundary, removing every Inf
and not retrieving boundary sides crash pykdtree
and gradient
.
I will fix this in the out-of-Earth boundary PR
Ugh, that's what I get for trying to fix something in the github GUI. Working on it... |
I'll merge this when CI passes. Another idea (for a much later PR) I had and maybe mentioned during out last meeting: How useful are some of these helper methods outside of boundary creation? What if the new Boundary classes had a |
git diff origin/main **/*py | flake8 --diff
This PR introduces the methods:
_get_geographic_sides
_get_projection_sides
These two methods allow to retrieve the boundary sides for whatever
pyresample
area, whether is geostationary or not.In a future PR, these two methods will also include the logic to retrieve the boundary of
AreaDefinition
with out-of-Earth coordinates.This PR:
get_area_slices
methodAreaSlicer
andSwathSlicer
class yetBUT :
_get_geographic_sides
is called withinget_bbox_lonlats
get_bbox_lonlats
returns non-Inf
sides vertices for geostationary area !get_edge_lonlats
andboundary()
depends onget_bbox_lonlats
, they now also returns non-Inf
GEO verticesget_bbox_lonlats
has not yet be fixed to be correct._get_geographic_sides
SphericalBoundary
classget_bbox_lonlats
is gonna be deprecated in upcoming PRs_get_projection_sides
SphericalBoundary
andPlanarBoundary
classget_edge_bbox_in_projection_coordinates
inSwathSlicer
/AreaSlicer
get_geostationary_bounding_box_in_proj_coords
inAreaSlicer