-
Notifications
You must be signed in to change notification settings - Fork 271
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
BUG: use of pcolormesh silently drops rays and mis-locates gates #178
Conversation
Thanks Eric! We actually knew about this.. I bumped into it when plotting synthetic RHIs (RHIs from PPI data).. @jjhelmus will take a look and then we will merge this very welcome PR! |
Glad it was helpful and not an unknown - though unless you were to read that part of pcolor's docs you wouldn't necessarily notice. Let me know if I can help tweak anything, @jjhelmus . |
@deeplycloudy Thanks for the contribution! When I looked at this problem I tried to approach it in range, azimuth, elevation coordinates (antenna coordinates) in which the boundaries are well defined for a given scan type but you need to take into account periodic conditions, etc. In the end I deciding that dropping one ray and gate was probably a better idea than trying to interpolate (at least for the time being). In Cartesian space this might be a bit easier although the edges and corners still cause problems. The dx/2 solution seems a bit hackish to me and I can think of cases where it will still cause issues (for example when the first range bin reports to be at 0). Let me try to prototype something that calculates edges in antenna coordinates before we jump and merge this. No matter what solution we decide upon I think a flag to turn off the interpolation should also be included which will plot the data with the dropped gates/rays with appropriate documentation of this issue included. |
PR #179 performs the interpolation in antenna coordinates (range, elevation, and azimuth) which allows filtering of non-physical edge location (those below the horizon and with negative range) and how a flag to disable this if you want to use the older plotting method which drops the gates and ray. I'm planning on merging that PR and closing this one. If I'm missing something feel free to point it out and reorder this PR. |
As the docs for matpltolib's pcolor/pcolormesh note, pcolor will silently drop the outermost row and column of a 2D grid when passed X and Y whose dimensions exactly match the grid. pcolor needs to know where to put the corners of the grid cells, so the right way to do this is to pass X and Y with dimensions one larger than the grid itself.
The edges of the gates aren't available, so we have to approximate them by interpolation and extrapolation. Here I provide one version of doing so.
The included images result from running quick_plot_cfradial_rhi.py and quick_plot_cfradial_ppi.py with the changes in this pull request. Comparison with the baseline images in master shows an extra radial of data and an extra gate at range for each radial, and a half-delta shift in the position of the gates and rays.
I only dealt with the pcolormesh calls in RadarDisplay, so if there are others they should be looked at, too.