ARM-DOE / pyart

The Python-ARM Radar Toolkit. A data model driven interactive toolkit for working with weather radar data.
https://arm-doe.github.io/pyart/
Other
516 stars 268 forks source link

inadequate RHOHV values in the radar file #1592

Closed MohitDahliya closed 5 months ago

MohitDahliya commented 5 months ago

Description

I want to add the Hydrometeor Classification Field into my radar object and I have which does that by considering the Z, ZDR, RHOHV & KDP fileds. The problem is that the RHOHV filed in my radar file is incorrect. maybe when they made the file at the source, they made a mistake. Due to wrong RHOHV values, hydrometeor classification field is not coming out correct. How can I overcome this issue?

What I Did

Initialize lists to store heights and Z values for each profile

all_heights = [] all_HCA_values = [] all_times = [] # Added to store time information

Iterate over each file and apply the QVP code

for file in files: file_path = os.path.join(directory_path, file)

# Read radar data
radar = pyart.io.read(file_path)

# Extract desired angle
desired_angle = radar.fixed_angle['data']

# Interpolate the sounding to the radar heights
radar_T, radar_z = interpolate_sounding_to_radar(sounding, radar)

wh0 = np.where(np.isclose(np.abs(sounding['temp']),0.0,atol=1.0))
expected_ML = np.array(sounding['height'])[wh0[0]][0]/1000.

rband = 'C'                
scan_type = radar.scan_type 
use_temp = True             
verbose = False             
minRH = 0.5                 

rheights = radar_z/1000.    

return_scores = False   

dz = np.ma.masked_array(
radar.fields['Z']['data'],
mask=np.logical_or(
    radar.fields['Z']['data'] < 5,
    radar.fields['Z']['data'] > 65
  )
)
dr = np.ma.masked_array(
radar.fields['ZDR']['data'],
mask=np.logical_or(
    radar.fields['ZDR']['data'] < -4,
    radar.fields['ZDR']['data'] > 6
  )
)
kd = np.ma.masked_array(radar.fields['KDP']['data'])
rh = np.ma.masked_array(
radar.fields['RHOHV']['data'],
mask=(radar.fields['RHOHV']['data'] > 0.8)
)

hcasummer = csu_fhc.csu_fhc_summer(dz=dz, zdr=dr, rho=rh, kdp=kd, use_temp=True,T=radar_T, band=rband,
                            verbose=False,use_trap=False,method='hybrid')

radar = add_field_to_radar_object(hcasummer, radar,field_name='HCA',dz_field='Z')

# Create quasi-vertical profile
profile = pyart.retrieve.quasi_vertical_profile(radar, desired_angle=desired_angle, fields='HCA')

all_heights.append(profile['height'])
all_HCA_values.append(profile['HCA'])

# Extract time information (assuming 'start_time' is present in radar.metadata)
time_info = radar.metadata.get('start_time', None)

if time_info is not None:
    # Convert the time to a datetime object if needed
    # Adjust the format to include milliseconds
    time_obj = pd.to_datetime(time_info, format='%Y-%m-%d %H:%M:%S.%f')

    # Append time, heights, and Z values to the lists
    all_times.append(time_obj)

Convert the lists to numpy arrays for plotting

heights_array1 = np.vstack(all_heights) HCA_values_array = np.vstack(all_HCA_values)

Choose a specific height from heights_array

selected_heights1 = heights_array1[0,: ]

Convert the time list to a NumPy array and then to matplotlib date format

times_array = date2num(np.array(all_times))

mgrover1 commented 5 months ago

@MohitDahliya - without the data file mentioned here, I am not sure what we can do to help. You can use gatefilter to quality control your data, to see if that improves the analysis https://arm-doe.github.io/pyart/notebooks/masking_data_with_gatefilters.html

But beyond that, we cannot make any specific recommendations