Problem when plotting altitude vs reflectivity from imd type b radar data

when iam trying to plot ALTITUDE VS REFLECTIVITY USING THE CODE BELOW :


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

# Assuming grid_files is defined as in your code
grid_files = glob.glob("D:\\radar_data\\radinout\\gridded_zdr_june20_rm_clutter\\gridded*nc")

# Initialize lists to store data
altitude_list = []
reflectivity_list = []

# Iterate through each file
for i, file in enumerate(grid_files):
 # Read grid data
 grid_data = pyart.io.read_grid(file)
 
 # Extracting reflectivity data
 reflectivity = grid_data.fields['REF']['data']
 
 # Append reflectivity data to the list
 reflectivity_list.append(reflectivity)
 
 # Extracting altitude data
 altitude = grid_data.point_altitude['data']
 
 # Append altitude data to the list
 altitude_list.append(altitude)

# Convert lists to arrays
reflectivity_array = np.ma.concatenate(reflectivity_list, axis=1)
altitude_array = np.ma.concatenate(altitude_list, axis=1)

# Plotting line plot
plt.figure(figsize=(10, 6))
for i in range(reflectivity_array.shape[1]):
 plt.plot(altitude_array[:, i], reflectivity_array[:, i])

plt.xlabel('Altitude (m)')
plt.ylabel('Reflectivity (dBZ)')
plt.title('Reflectivity vs Altitude')
plt.show()
#label=f'File {i+1}'

the loop is not ending running continuously and not getting any output.

@ankithva

Can you please explain what your code should do? Can you please explain what ALTITUDE vs REFLECTIVITY should show? It seems it should be some line plot, but maybe you have some example image what you expect.

Anyway, a bit more explanation what you are trying to achieve is really helpful to get meaningful answers and to keep barriers low for people who might answer. The less time is needed to get involved with the actual problem the better.

Best,
Kai


This is the example image

@ankithva Similar to the other issue - without more information, we cannot help. If we continue to see these non-descriptive posts, we may need to start to filter them on the forum. Please use this forum to ask questions about radar science or the associated toolkits - this is not a space to request workflows based on a general description.

If we continue to see posts without a clear question, we will start filtering, as this puts a strain on the moderators of the forum.

2 Likes