Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

deeplycloudy
Copy link
Contributor

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.

example_cfradial_ppi
example_cfradial_rhi

I only dealt with the pcolormesh calls in RadarDisplay, so if there are others they should be looked at, too.

@deeplycloudy deeplycloudy changed the title BUG: use of pcolormesh silently drops and misallocates gates BUG: use of pcolormesh silently drops and mis-locates gates Jul 24, 2014
@deeplycloudy deeplycloudy changed the title BUG: use of pcolormesh silently drops and mis-locates gates BUG: use of pcolormesh silently drops rays and mis-locates gates Jul 24, 2014
@scollis
Copy link
Member

scollis commented Jul 24, 2014

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!

@deeplycloudy
Copy link
Contributor Author

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 .

@jjhelmus
Copy link
Contributor

@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.

@jjhelmus
Copy link
Contributor

jjhelmus commented Aug 1, 2014

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.
The solution to the azimuth periodicity problem was to treat the angles complex numbers, which removes the discontinuity between 0 and 360 degrees.

The results are quite nice:
example_cfradial_ppi

example_cfradial_rhi

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants