when iam plotting this
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import glob
import pyart
import numpy.ma as ma
import wradlib as wrl
grid_files = glob.glob(“D:\radar_data\radinout\gridded_20_jun_2022\gridded_20_jun_2022grid_ZDR_*nc”)
total_rain_rate = np.zeros((len(grid_files), 250, 250))
for i, file in enumerate(grid_files):
grid_data = pyart.io.read_grid(file)
feature_detection=pyart.feature_detection(grid_data,xg_files[‘lon’].values, xg_files[‘lat’].values,field=“REF”,always_core_thres=40,bkg_rad_km=20,use_cosine=True,max_diff=5,zero_diff_cos_val=55,weak_echo_thres=10,max_rad_km=2,)
ref_data = grid_data.fields['REF']['data']
ref_values_greater_than_40 = ma.masked_less(ref_data, 40) # Filter reflectivity >= 40 dBZ
grid_data.fields['REF']['data'] = ref_values_greater_than_40
grid_data.fields['REF']['long_name'] = 'Reflectivity'
grid_data.fields['REF']['units'] = 'dBZ'
xg_files = grid_data.to_xarray()
Z = wrl.trafo.idecibel(xg_files.REF[0, 0, :, :].values)
rain_rate = wrl.zr.z_to_r(Z, a=200, b=1.5)
total_rain_rate[i, :, :] = rain_rate
missing_mask = np.isnan(total_rain_rate)
valid_data = np.ma.masked_array(total_rain_rate, mask=missing_mask)
daily_aggregated_rain = np.sum(valid_data, axis=0)
Apply limit to rainfall values
masked_rainfall = np.ma.masked_where((daily_aggregated_rain < 0) | (daily_aggregated_rain > 120), daily_aggregated_rain)
Define the Plate Carree projection
proj = ccrs.PlateCarree()
Create the axes instance
plt.figure(figsize=(10, 8))
ax = plt.axes(projection=proj)
Plot the contourf
im = ax.contourf(xg_files[‘lon’].values, xg_files[‘lat’].values, masked_rainfall, levels=np.linspace(10, 120, 10),cmap=‘jet’, origin=“lower”)
Add colorbar
cbar = plt.colorbar(im, ax=ax, label=‘Accumulated Rainfall (mm)’, ticks=np.arange(10, 120, 10))
Add gridlines
gl = ax.gridlines(crs=proj, draw_labels=True, color=‘none’)
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
Add basemap
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS, linewidth=1)
ax.add_feature(cfeature.STATES, linewidth=1)
Plot the marker
plt.plot(75.8175, 26.8207, marker=“x”, color=“black”, markersize=15, markeredgewidth=2)
Set labels and title
plt.title(‘Accumulated Rainfall (mm)/IMD JPR/20-6-2022 (mm)’)
Show the plot
plt.show()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 17
** 15 for i, file in enumerate(grid_files):**
** 16 grid_data = pyart.io.read_grid(file)**
—> 17 feature_detection=pyart.feature_detection(grid_data,xg_files[‘lon’].values, xg_files[‘lat’].values,field=“REF”,always_core_thres=40,bkg_rad_km=20,use_cosine=True,max_diff=5,zero_diff_cos_val=55,weak_echo_thres=10,max_rad_km=2,)
** 19 ref_data = grid_data.fields[‘REF’][‘data’]**
** 20 ref_values_greater_than_40 = ma.masked_less(ref_data, 40) # Filter reflectivity >= 40 dBZ**
AttributeError: module ‘pyart’ has no attribute ‘feature_detection’