-
Notifications
You must be signed in to change notification settings - Fork 370
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
Mollweide projection - completely corrupted contourf when there are gridpoints at the pole #2137
Comments
Thanks for the report - a bit hard to figure out what is going on here. I have not found the issue but did notice that the Mollweide plot generally works here without adjusting the latitude if using a smaller numbers of color levels (up to num = 25, but also num=30). I wonder if that points to what is going on? It also works for any number of levels with transform_first=True. |
After seeing #1076, this problem appears to be similar. Was able to create some test cases based on your example to better show what is going on. Each case isolates a specific path which causes issues (there could be multiple). It also shows a comparison to the same plot, but with the endpoints of the lat grid shifted slightly away from the pole.
|
Working through the plotting functions, the problem arises from _project_linear_ring in crs.py and ultimately project_linear in trace.pyx. Here is a more reduced example, which replicates the behavior of test case 1:
With N = 100 or less, project_linear returns a single closed geometry. There is an open pull request #1739 that I wonder if would help, but there @kdpenner mentioned suspecting an issue is in trace which is also what I am seeing here. |
This seems related to the behavior in #2240 around the bounds/boundary for Geostationary. If I increased the number of points, I started getting errors. I agree something isn't quit right in |
Thanks for reminding me about my PR. I didn't expect it to go anywhere because I felt like I wasn't addressing the root issues but I am more than happy to implement suggested changes. |
Okay, I was able to track this down through trace (notably seeing POINT_OUT states in bisect once the problem starts happening) and ultimately back up to the definition of the boundary in _WarpedRectangularProjection in crs. I did not realize the boundary is discrete, so you can have points along the paths generated by countorf that register as being outside of the domain, e.g.:
Simply bumping n = 91 to n = 121 at Lines 2095 to 2106 in d1b43fb
|
Description
This is a similar issue to #1333 or #2016, but the effect is much more dramatic, not only limited to the poles.
It seems to happen when there are gridpoints exactly at the poles, not when they are further north than 89.14,
so #1334 might not fix it.
Therefore, I'm thinking that it might be a different problem.
Basically, plotting the exact same data, this is what I'm getting:
Setting the latitude grid to go from -89.9 to 89.9 degrees fixes the problem, but it still seems like a bug.
Code to reproduce
Versions
Cartopy version 0.21.0, matplotlib version 3.6.1.
The text was updated successfully, but these errors were encountered: