Data Quality - imshow vs. pcolormesh

Hey y’all, Max sent me here to open a discussion on imshow vs. pcolormesh when plotting data. While imshow is the default for its speed, some purists like me get bothered by the way it smooths/blurs the data (image attached; I had to get creative since I got a “new posters can only send one image” warning)

After reading the docs, I figured setting Raster = True instead of False would fix this for me, but it had no effect on the image. So, Max showed me that extracting the data (radar.get_field() and radar.get_gate_lat_lon_alt()) and plotting it manually via pcolormesh would best preserve the data. I personally gave up after struggling with the data being transposed.

So now I figure a simple kwarg for plotting in pcolormesh (or an example on how to plot in pcolormesh) would help folks like me who just want their data to look as realistic as possible.

I am hooked on this package and what I can do with it, and I appreciate y’all’s time in advance!

Hi @nixoncameronj,

I’m assuming you are using Py-ART, but to know the exact plot function you are using would be great. Maybe you can create a little example script which shows the behaviour you are experiencing?

When it comes to imshow there are several possible interpolation schemes. They are nicely explained here Interpolations for imshow — Matplotlib 3.6.2 documentation.

Pretty cool to see that a topic that I brought up on Twitter made it here. I have always wondered since I first saw this interpolated style if it actually improves the quality of the data overall? It generally looks like it pulls more out of the legacy 1km and 1° azimuth resolution.

@nixoncameronj - I dug into the code for the RadarMapDisplay’s plot_ppi_map function, and it uses pcolormesh here, which should handle the gate shape/interpolation properly.

I suspect this has more to do with the colorbar and how colors are handled in GRLevel2 vs. Python.

@nixoncameronj if you are interested in using a discrete colormap (like some other visualization tools), you can use the following:

import pyart
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

# Read in a sample radar
radar = pyart.io.read(pyart.testing.CFRADIAL_PPI_FILE)

# Grab a colorbar from Py-ART
cmap = pyart.graph.cm_colorblind.HomeyerRainbow

# Set your minimum, maximum, and interval for your bins
bounds = np.arange(-10, 75, 5)

# Configure the normalization for matplotlib
norm = mpl.colors.BoundaryNorm(bounds, cmap.N, extend='both')

# Setup the radar map display
graph = pyart.graph.RadarMapDisplay(radar)

# Plot the reflectivity field
graph.plot_ppi_map('reflectivity_horizontal', cmap=cmap, norm=norm)