Can't plot reflectivity values >=40dbz with appropriate ticks and cmaps

indeed to extract “REF” values >=40dbz and need to plot it :

import pyart
import numpy as np
import glob
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER

Assuming grid_files is defined as in your code

grid_files = glob.glob(“D:\radar_data\radinout\gridded_20_jun_2022\gridded_20_jun_2022grid_ZDR_*nc”)

Define the projection you want to use

projection = ccrs.PlateCarree()

for i, file in enumerate(grid_files):
grid_data = pyart.io.read_grid(file)
ref_data = grid_data.fields[‘REF’][‘data’]

ref_values_less_mask40 = np.where(ref_data >= 40, ref_data, np.nan)


 grid_data.fields['REF']['data'] = ref_values_less_mask40 
 grid_data.fields['REF']['long_name'] = 'Filtered Reflectivity'
 grid_data.fields['REF']['units'] = 'dBZ'


 fig = plt.figure(figsize=[8, 8])
 ax = plt.subplot(111, projection=projection)

 grid_display = pyart.graph.GridMapDisplay(grid_data)
 grid_display.plot_grid("REF", level=1,vmin=40,vmax=100, projection=projection, ax=ax, ticks=np.arange(40, 101, 2))

BUT I’M GETTING PLOTS LIKE THIS ,IS IT BECAUSE OF THE PROBLEM OF MY CODE OR DATA(SHOWING 100Dbz MOST OF THE MAP)?AND ALSO I NEED TO SEE THE “REF” >=40 VARIATION WITH SUITABLE TICKS AND COLOURMAP.




Which radar is this from? I suspect it is data quality issue…

Data taken from IMD JAIPUR,INDIA

What’s the “no data” or “no rain” value in your files? For example some IRIS files have the no data set for something like 65000 (large positive value). Such case would satisfy your equation greater or equal than 40 and you limit the vmax of plot to 100, so everything above 100 is max color (yellow in your case).

You can check for this in multiple ways, for example:

ref_data0 = np.where(ref_data <= 1000, ref_data, np.nan) # The 1000 is arbitrary, change how you like
ref_values_less_mask40 = np.where(ref_data0 >= 40, ref_data0, np.nan)

Or single line:
ref_values_less_mask40 = np.where(np.logical_and(ref_data >= 40, ref_data <= 1000), ref_data, np.nan) # Again, 1000 is arbitrary

Or exclude the nodata value with np.where(), if this is the case here.

Or just show the output of print(ref_data). Might give some clues.

2 Likes