-
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
Add 'antimeridian_mode' to DynamicAreaDefinition #431
Conversation
Codecov Report
@@ Coverage Diff @@
## main #431 +/- ##
==========================================
+ Coverage 93.95% 94.21% +0.26%
==========================================
Files 65 68 +3
Lines 11252 12346 +1094
==========================================
+ Hits 10572 11632 +1060
- Misses 680 714 +34
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. |
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.
Couple of inline comments. In general I guess this LGTM, but there should be some documentation at least listing the options.
pyresample/geometry.py
Outdated
else: | ||
xmin = np.nanmin(xarr[xarr >= 0]) | ||
xmax = np.nanmax(xarr[xarr < 0]) + 360 | ||
if antimeridian_mode == "modify_projection": |
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.
Would shift_prime_median
be more specific?
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.
Hm interesting idea. I think I chose "projection" in case other projections in the future may need different types of modifications. For example, if we were trying to support someone using +x
and +y
parameters in their projection definition, I'm not sure the +pm
would be the best thing to modify.
pyresample/geometry.py
Outdated
xmin = np.nanmin(xarr[xarr >= 0]) | ||
xmax = np.nanmax(xarr[xarr < 0]) + 360 | ||
return xmin, ymin, xmax, ymax | ||
if antimeridian_mode == "global_extents": |
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.
This is the only option that doesn't have an imperative mode, so should it be use_global_extents
?
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.
Good point. We could also remove the verb and just do global_extents
, nearest_extents
, and projection
...eh I'm not sure I like that. And yeah I need to document these. I thought I had but obviously not.
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.
Just a few clarification questions on the documentation. Looks good.
pyresample/geometry.py
Outdated
antimeridian_mode: | ||
How to handle lon/lat data crossing the anti-meridian of the | ||
projection. This currently only effects lon/lat geographic | ||
projections and data cases not covering the north or south pole. | ||
The possible options are: | ||
|
||
* modify_extents: Set the X bounds to the edges of the data, but | ||
add 360 to the right-most bound. This has the effect of making | ||
the area coordinates continuous from the left side to the | ||
right side. However, this means that some coordinates will be | ||
outside the coordinate space of the projection. Although most | ||
PROJ and pyresample functionality can handle this there may be | ||
some edge cases. | ||
* modify_projection: Change the prime meridian of the projection | ||
from 0 degrees longitude to 180 degrees longitude. This has | ||
the effect of putting the data on a continuous coordinate | ||
system. However, this means that comparing data resampled to | ||
this resulting area and an area not over the anti-meridian | ||
would be more difficult. | ||
* global_extents: Ignore the bounds of the data and use -180/180 | ||
degrees as the west and east bounds of the data. This will | ||
generate a large output area, but with the benefit of keeping | ||
the data on the original projection. Note that some resampling | ||
methods may produce artifacts when resampling on the edge of | ||
the area (the anti-meridian). |
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.
@mraspaud @pnuu @gerritholl I think the last remaining question is what are the best names for these parameters. In another comment Panu pointed out that global_extents
is the only one that doesn't have an imperative verb at the front. He also suggested using "shift_prime_meridian" instead of "modify_projection", but my worry with that is that in the future modifying the projection to support the data may not only include shifting the prime meridian.
Thoughts? Opinions?
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.
make_extent_global
or globalize_extent
would be an imperative form of global_extents
. But it's not actually global, is it? It covers all longitudes, but must not necessarily cover all latitudes. It anyway should affect only the longitude extent, not the latitude extent, shouldn't it? The docstring in lines 1091 and 1092 mentions lon/lat, but this should be only about lon?
About modify_projection
: it would seem that it's not accurate to speak of a projection at all here. When we describe data in lat/lon then the data are unprojected, or are they?
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 replace projection
by CRS
and change modify_projection
to modify_CRS
. I can see how a future case of, for example, data covering a pole may modify lat/lons by putting the pole somewhere different, yet retain spherical coordinates therefore still not being technically a projection (but rather a confusion ☺).
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.
Good point bringing up the poles. I should update the docs to reference that more. The extent handling is ignored if the data covers a pole as there isn't a "perfect" way to make the data contiguous on a single small area.
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.
The poles are a coordinate singularity, so lat/lon coordinates are simply not suitable around the poles.
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 like modify_crs
(lower case, to be more pythonic). And indeed, I was only thinking about the current case of adjusting the prime meridian.
Similarly global_extents
would be future proof for any projection type, although what @gerritholl sait about the actual globality is a valid point. Some (hasty!) suggestions for names for this: use_full_width(_extents)
, wrap_x_extents
, cover_all_meridians
.
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.
The thing about the "global_extents" not being global is a little odd. Right now it is global in the longitudinal dimension, but not necessarily in latitude. I would hope users wouldn't be too confused that a parameter dealing with the anti-meridian would only effect meridians and not parallels. We could call it expand_extents
which can give the general impression of "we're going to increase the range of the extents to fit more than just the data".
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.
ignore_extents
instead of global_extents
? and modify_crs
sounds good.
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.
Why "ignore"? What is being ignored? Oh you mean ignoring the extents of the data...eh I'm not sure I like that. I'll change to modify_crs
for that one, but still not sure on extents.
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.
The logic seems sound, great work! I'd just like to get rid of some code duplication
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.
LGTM, thanks for the hard work!
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.
LGTM
Closes #428. See #428 for more details about the possible cases here.
git diff origin/main **/*py | flake8 --diff