Closed owenlittlejohns closed 3 years ago
Thanks for filing the issue!
It has probably been nearly 10 years since I originally wrote this code in my Polar2Grid project so you'll have to forgive my lack of memory for why it is the way it is. My gut reaction is that this if statement and the logic for projection circumference just get removed. Do you think you and your colleagues could try installing a development version of pyresample with that elif
commented out and see if it fixes the issue? That would be the first step in moving forward with this.
The two things I can think of for why this is here is:
I just need to make sure I walk through the various use cases of doing things like a global mercator area versus global lon/lat area versus a lon/lat area that has -180/180 as its origin/center.
Thanks for the quick response. We'll try installing a development version commenting out the elif
and see what we get! (Not sure on the timeframe, but will keep you posted)
@djhoese - I just got chance to try out a development version of pyresample
locally. I tried two things:
elif
, as suggested.elif
statement with a check for x_tmp < origin_x
. This made the full statement:elif proj_circum != 0 and (origin_x - x_tmp) >= (0.75 * proj_circum):
x_tmp += proj_circum
I tried both of these approaches with my example file (as shown above) for some of the target grids we see fairly often:
In all cases, and both approaches, the output contained the data on both sides of the anti-meridian as expected!
Panoply Georeferenced Image | Gridded contour plot using target grid |
---|---|
Great! How would you feel about making a pull request with the first change (removing the whole elif
)?
Sounds good to me!
Code Sample, a minimal, complete, and verifiable piece of code
Input data swath crossing anti-meridian: Available here, also attached to this issue.
Note, this summarises code from various parts of a larger service - so is a little rough, particularly with handling the fill value.
Problem description
When taking an input swath that crosses the anti-meridian and reformatting it to a whole-Earth geographic grid, the EWA algorithm does not include data where 90 < longitude (degrees east) < 180. (We've confirmed that this behaviour is limited to the EWA algorithm, other interpolation methods work nicely).
My colleagues and I have looked into this a bit, and think the issue may be in
ll2cr_static
. There's a check for anti-meridian crossing. If the pixel is determined to cross the anti-meridian, the x coordinate (longitude in this case) is incremented by the projection circumference (360 degrees for geographic):In our case, we have a whole-Earth output grid, so
origin_x = -180
andproj_circum = 360.0
. The anti-meridian crossing condition for these values is satisfied forlongitude
≥ 90 (degrees east). In the case oflongitude
= 90 degrees east, this shift meanslongitude_incremented
= 450 degrees east. This is likely leading to the affected longitudes being considered outside of the target grid.Our team was wondering if this could be mitigated by an additional check to the
elif
condition that ensures the x coordinate is less than the lefthand edge of the target grid:x_tmp < origin_x
. Alternatively, maybe the projection could be checked to see if the target grid is geographic? (Or maybe a combination of both checks)Expected Output
This is the input used in the sample code above. The output should resemble the input, but be geographically gridded to the target area:
Actual Result
The output below shows the non-fill pixels once the
sea_surface_temperature
has been projected. The output target area is essentially whole-Earth, but the pixels west of the anti-meridian are filled.Versions of Python, package at hand and relevant dependencies
Tested under
pyresample
v1.17.0 and v1.20.0 in Python 3.7.