Skip to article frontmatterSkip to article content

Coldpool and Downdraft Analysis for ARM Summer School 2025

Packages used: ARM ACT, metpy
Contributers:
Angel Chui (time series code) with support of Scott Giangrande, Max Grover, Scott Collis, and Joe O’Brien
Scott Giangrande (QVP) using code from Mindy Deng.
Scott Collis (QVP gatefilter)

import act
import pyart
import metpy
from metpy.units import units
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
import matplotlib.colors as colors

from netCDF4 import Dataset
import glob
import datetime
import pandas as pd
import matplotlib.dates as mdates
import os
import math
import calendar

## You are using the Python ARM Radar Toolkit (Py-ART), an open source
## library for working with weather radar data. Py-ART is partly
## supported by the U.S. Department of Energy as part of the Atmospheric
## Radiation Measurement (ARM) Climate Research Facility, an Office of
## Science user facility.
##
## If you use this software to prepare a publication, please cite:
##
##     JJ Helmus and SM Collis, JORS 2016, doi: 10.5334/jors.119

ERROR 1: PROJ: proj_create_from_database: Open of /opt/conda/share/proj failed

May 10 - Time Series

pull kazr2 general mode data.

Can use ACT for this because KAZR (RHI type) radar is not super huge file. The cone type ones (like SACR) are very large files and so would prefer to just pull individual files for those.

# Set your username and token here!
username = 'username'
token = 'token'

# Set the datastream and start/enddates
datastream = 'bnfkazr2cfrgeM1.a1'
startdate = '2025-05-10T03:00:00'
enddate = '2025-05-10T18:00:00' #notice can give date and time or leave it blank (like with start date)

# Use ACT to easily download the data.  Watch for the data citation!  Show some support
# for ARM's instrument experts and cite their data if you use it in a publication
result_kazr2 = act.discovery.download_arm_data(username, token, datastream, startdate, enddate)
ds_kazr2 = act.io.read_arm_netcdf(result_kazr2)
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.155959.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.045959.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.070001.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.080001.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.090001.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.030000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.130000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.150000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.060002.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.100001.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.120000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.170002.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.110000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.140000.nc
[DOWNLOADING] bnfkazr2cfrgeM1.a1.20250510.035959.nc

If you use these data to prepare a publication, please cite:

Lindenmaier, I., Matthews, A., Wendler, T., Melo  de Castro, V., Deng, M.,
Rocque, M., & Feng, Y.-C. Ka ARM Zenith Radar (KAZR2CFRGE), 2025-05-10 to
2025-05-10, Bankhead National Forest, AL, USA; Long-term Mobile Facility (BNF),
Bankhead National Forest, AL, AMF3 (Main Site) (M1). Atmospheric Radiation
Measurement (ARM) User Facility. https://doi.org/10.5439/1891991

pull MET data

in order to calculate theta-e using metpy

# pull in met data using ACT
# Set your username and token here!
username = 'username'
token = 'token'

# Set the datastream and start/enddates
datastream = 'bnfmetM1.b1'
startdate = '2025-05-10'
enddate = '2025-05-10T23:59:59' #notice can give date and time or leave it blank (like with start date)

# Use ACT to easily download the data.  Watch for the data citation!  Show some support
# for ARM's instrument experts and cite their data if you use it in a publication
result_met = act.discovery.download_arm_data(username, token, datastream, startdate, enddate)
ds_met = act.io.read_arm_netcdf(result_met)
ds_met
Loading...

pull Radar Wind Profiler (rwp)

for wind average

# pull in met data using ACT
# Set your username and token here!
username = 'username'
token = 'token'

# Set the datastream and start/enddates
datastream = 'bnf915rwpwindavgM1.a1'
startdate = '2025-05-10'
enddate = '2025-05-10T23:59:59' #notice can give date and time or leave it blank (like with start date)

# Use ACT to easily download the data.  Watch for the data citation!  Show some support
# for ARM's instrument experts and cite their data if you use it in a publication
result_rwp = act.discovery.download_arm_data(username, token, datastream, startdate, enddate)
ds_rwp = act.io.read_arm_netcdf(result_rwp)
ds_rwp
Loading...

calculate theta-e

a good indicator of cold pool

# two ways to calculate theta-e: 1) pull maws data dewpoint temp and combine time or 2) calculate dewpoint temp from RH in the met data
# method 2) is better because method 1) will cause loss of resolution

# 1) to calculate theta-e, need met and maws data but by looking at the time from above you can see the time is slightly off, both are 1 min but maws if at 4 sec into the minute
# ds_combined = xr.merge([ds_met.resample(time='1min').nearest(), ds_maws.resample(time='1min').nearest()], compat='override')
# thetae = metpy.calc.equivalent_potential_temperature(ds_combined.atmos_pressure, ds_combined.temp_mean, ds_combined.atmospheric_dew_point)

# 2) 
dewpt_temp = metpy.calc.dewpoint_from_relative_humidity(ds_met.temp_mean, ds_met.rh_mean)
thetaeK = metpy.calc.equivalent_potential_temperature(ds_met.atmos_pressure, ds_met.temp_mean, dewpt_temp)
thetaeC = thetaeK - 273.15*units.kelvin

## calculating theta-e already sliced to the time frame we want
# dewpt_temp = metpy.calc.dewpoint_from_relative_humidity(ds_met.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00")).temp_mean, ds_met.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00")).rh_mean)
# thetaeK = metpy.calc.equivalent_potential_temperature(ds_met.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00")).atmos_pressure, ds_met.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00")).temp_mean, dewpt_temp)
# thetaeC = thetaeK - 273.15*units.kelvin

Quasi Vertical Profile

code modified by Scott Giangrande, original code by Mindy Deng

def find_nearest(array, value):
    array = np.asarray(array)
    idx = (np.abs(array - value)).argmin()
    return idx, array[idx]
def calculate_elevation_angle_array(height: np.ndarray, range_: np.ndarray) -> np.ndarray:
    """Returns an array of elevation angles in degrees."""
    return np.degrees(np.arctan2(height, range_))

To make a CVP need to gatefilter certain azimuths

##Get Azimuths
#azmth = csapr.azimuth['data']

#Make this into the same shape as our radar field data
#azmth_square = np.repeat(np.expand_dims(azmth, 1), len(csapr.range['data']), axis=1)

#add the field
#csapr.add_field_like('reflectivity', 'azsq', azmth_square)

#Make a gate filter
#mygf = gatefilter = pyart.correct.GateFilter(csapr)

#filter on aziumth, 10 to 20 degrees
#mygf.exclude_outside('azsq', 10,20) 

#See what we got
#myd = pyart.graph.RadarDisplay(csapr)
#myd.plot_ppi('reflectivity', gatefilter = mygf)

Plot QVP, RHI, MET together

QVP calculation

## QVP part

# def plot_qvp_3variables(qvp_dbzs, qvp_zdrs,qvp_rhos,dtimes, hgt,el, case,htop,qvp_dir):
def plot_qvp_5variables(qvp_dbzs, qvp_vels, qvp_wths, qvp_zdrs,qvp_rhos,dtimes, hgt,el, case,htop,qvp_dir):
    
    # # Ensure dtimes is np.array of datetime
    # if isinstance(dtimes, list):
    #     dtimes = np.array(dtimes)
    
    # # Fix dimensions for pcolormesh
    # if dtimes.ndim == 1:
    #     dtimes = np.tile(dtimes, (new_dbzs.shape[0], 1))
    
    # # Check datetime format
    # assert np.issubdtype(dtimes.dtype, np.datetime64) or isinstance(dtimes[0, 0], datetime.datetime)
    
    # # Ensure start_time and end_time are datetime
    # if isinstance(start_time, str):
    #     start_time = datetime.datetime.fromisoformat(start_time)
    # if isinstance(end_time, str):
    #     end_time = datetime.datetime.fromisoformat(end_time)
    
    # Transpose and convert to arrays
    new_dbzs = np.array(qvp_dbzs).T
    new_zdrs = np.array(qvp_zdrs).T
    new_rhos = np.array(qvp_rhos).T
    new_vels = np.array(qvp_vels).T
    new_wths = np.array(qvp_wths).T
    
    # Apply RhoHV mask
    mask = new_rhos < 0.2
    new_dbzs[mask] = np.nan
    new_zdrs[mask] = np.nan
    new_rhos[mask] = np.nan
    new_vels[mask] = np.nan
    new_wths[mask] = np.nan
    
    # Setup plot
    ytop = htop
    fig, axes = plt.subplots(5, 1, sharex=True, figsize=(10,8))
    fig.subplots_adjust(hspace=0.3)
    
    # Plot Reflectivity
    #pcm = axes[0].pcolormesh(dtimes, hgt / 1e3, new_dbzs, vmin=-40, vmax=40, cmap='HomeyerRainbow')
    pcm = axes[0].pcolormesh(dtimes, hgt / 1e3, new_dbzs, vmin=-40, vmax=40, cmap='ChaseSpectral')
    fig.colorbar(pcm, ax=axes[0], label='[dBZ]')
    axes[0].set_ylim(0, ytop)
    axes[0].set_title('Reflectivity')
    axes[0].set_ylabel('height [km]')
    
    # Plot Velocity
    pcm = axes[1].pcolormesh(dtimes, hgt / 1e3, new_vels, vmin=-5, vmax=5, cmap='Spectral_r')
    fig.colorbar(pcm, ax=axes[1], label='[m/s]')
    axes[1].set_ylim(0, ytop)
    axes[1].set_title('Vd')
    axes[1].set_ylabel('height [km]')
    
    # Plot Width
    pcm = axes[2].pcolormesh(dtimes, hgt / 1e3, new_wths, vmin=0, vmax=3, cmap='Spectral_r')
    fig.colorbar(pcm, ax=axes[2], label='[m/s]')
    axes[2].set_ylim(0, ytop)
    axes[2].set_title('Width')
    axes[2].set_ylabel('height [km]')
    
    # Plot ZDR
    #pcm = axes[3].pcolormesh(dtimes, hgt / 1e3, new_zdrs, vmin=-2, vmax=4, cmap='Spectral_r')
    pcm = axes[3].pcolormesh(dtimes, hgt / 1e3, new_zdrs, vmin=-2, vmax=4, cmap='ChaseSpectral')
    fig.colorbar(pcm, ax=axes[3], label='[dB]')
    axes[3].set_ylim(0, ytop)
    axes[3].set_title('ZDR')
    axes[3].set_ylabel('height [km]')
    
    # Plot RhoHV
    pcm = axes[4].pcolormesh(dtimes, hgt / 1e3, new_rhos, vmin=0, vmax=1, cmap='Spectral_r')
    fig.colorbar(pcm, ax=axes[4])
    axes[4].set_ylim(0, ytop)
    axes[4].set_title('RhoHV')
    axes[4].set_ylabel('height [km]')
    axes[4].set_xlabel('Time [UTC] on ' + str(case))
    # axes[2].set_xlim([start_time, end_time])
    axes[4].xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
    
    # axes[4].set_xlim([dtimes.min(), dtimes.max()])
    # axes[4].xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
    # Add main title
    plt.suptitle(f'BNF XSACR QVPs at {el} deg and 40deg sector for {case}')
   
    # Optional save
     
    #save_gif = qvp_dir + f'bnf_xsacr_qvp_{el}deg_{case}.png'
    #save_gif = qvp_dir + f'bnf_xsacr_qvp_{el}deg_{case}htop_{htop}.png'
    #plt.savefig(save_gif , dpi=400, bbox_inches="tight")
    plt.show()

qvp_dir =  '/data/home/mdeng/data/bnf/qvp/xsacr/' 
#os.makedirs(qvp_dir, exist_ok=True)

#dir = '/data/datastream/bnf/bnfxsacrcfrS4.a1/'
#afile =  dir + 'bnfxsacrcfrS4.a1.20250514.225456.nc'

dir = "data/project/ARM_Summer_School_2025/radar/xsacr/*" 
#afile =  dir + 'bnfxsacrcfrS4.a1.202505.225456.nc'


#el = 9
el = 16

#azimuth range for a CVP
az1 = 200
az2 = 240

yr = "2025"
month = '05'
day = '10'
date_join = f"{yr}-{month}-{day}"
case = yr + month + day

files = sorted(glob.glob('/data/project/ARM_Summer_School_2025/radar/xsacr/bnfxsacrcfrS4.a1.'+case+'*'))
#files = sorted(glob.glob('/data/datastream/bnf/bnfkasacrcfrS4.a1/bnfkasacrcfrS4.a1.'+case+'*'))

nfiles = len(files)

qvp_dbzs = []
qvp_zdrs = []
qvp_rhos = []
qvp_vels = []
qvp_wths = []
dtimes = []



for file in files:
    rad = pyart.io.read(file)
    #print(file)

    
    if rad.scan_type == 'ppi':
       

        #find azimuths for XSACR file
        azmth = rad.azimuth['data']
        
        #Make this into the same shape as our radar field data
        azmth_square = np.repeat(np.expand_dims(azmth, 1), len(rad.range['data']), axis=1)
        rad.add_field_like('reflectivity', 'azsq', azmth_square)
 
        # #Make a gate filter
        mygf = gatefilter = pyart.correct.GateFilter(rad)
        
        #filter on aziumth, az1 to az2 degrees
        mygf.exclude_outside('azsq', az1,az2) 


        
        #qvp = pyart.retrieve.quasi_vertical_profile(rad, desired_angle=el)
        qvp = pyart.retrieve.quasi_vertical_profile(rad, desired_angle=el, gatefilter= mygf)
        rng = qvp['range']
        hgt = qvp['height']

        angle = calculate_elevation_angle_array(hgt, rng)
        angle_mean = np.mean(angle)
        d_angle  = np.abs(angle_mean - el)
        if  d_angle  < 1:
          
            qdbz = qvp['reflectivity']
            # qdbz = qvp['attenuation_corrected_reflectivity_h'] # for csapr
            qvel = qvp['mean_doppler_velocity']
            qwth = qvp['spectral_width']
            
            qzdr = qvp['differential_reflectivity']
            qrho = qvp['copol_correlation_coeff']

            rng0 = qvp['range']
            hgt0 = qvp['height']
        
            qvp_dbzs.append(qdbz)
            qvp_zdrs.append(qzdr)
            qvp_rhos.append(qrho)
            qvp_vels.append(qvel)
            qvp_wths.append(qwth)
    
            #date = os.path.basename(files[i])[18:-3]
            date = os.path.basename(file)[18:-3]
            dto = datetime.datetime.strptime(date, '%Y%m%d.%H%M%S')
            dtimes.append(dto)
            
            #print ('done with ' + file)


rng_corr = rng*np.tan(np.deg2rad(el))

# Define the time limits 
start_time = np.datetime64(date_join+"T03:00:00")
end_time = np.datetime64(date_join+"T18:00:00")
[1.4996567 2.4884412 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 13.399661 12.997025 16.996109]
16.990616
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.996109 ]
16.996109
[1.4996567 2.4994278 3.4937057 4.49897  ]
4.493477
[ 6.9929047  9.992218  12.997025  16.996109 ]
16.991806
[1.4886702 2.4995184 3.4937057 4.49897  ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4939346 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.4948554 4.493477 ]
4.493477
[ 6.9929047  9.992218  12.997025  16.990616 ]
16.996109
[1.4886702 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.994118 ]
16.996109
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990122]
16.996109
[1.4941634 2.4950006 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[6.9874115 0.9997711]
0.9997711
[2.4994278 3.504692  4.493477 ]
4.5061398
[ 6.998398  9.997711 12.997025 16.990616]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.993206
[2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.990616 ]
16.993895
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.4984298 4.493477 ]
4.493477
[ 6.998398  9.997711 13.414885 12.997025 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 13.381525 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4980052 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4932375 3.499199  4.493477 ]
4.493477
[ 6.998398   9.997711  13.3903675 12.997025  16.996109 ]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.992218  12.997025  16.990616 ]
16.996109
[1.4941634 2.4994278 3.4937057 4.49897  ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4978614 3.4967759 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.991354
[1.4886702 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 13.389459 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.490163 3.504692 4.493477]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.49897  ]
4.493477
[ 6.998398  9.997711 13.382345 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4939346 3.496489  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.504921 3.504692 4.493477]
4.493477
[ 6.9956    9.997711 12.997025 16.990616]
16.996109
[2.4994278 3.4987152 4.493477 ]
4.493477
[ 6.9929047  9.992218  12.997025  16.996109 ]
16.996109
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.9951015  9.997711  13.391639  12.997025  16.996109 ]
16.996109
[1.4941634 2.4960139 3.4979146 4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4886702 2.4939346 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.992292 16.996109]
16.996239
[1.4941634 2.4994278 3.495923  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4947093 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4996567 2.4884412 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4964032 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.4972003 4.493477 ]
4.493477
[ 6.998398  9.997711 13.380668 12.997025 16.996109]
16.996109
[1.4996567 2.4930618 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.499195 3.504692 4.493477]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.5024166 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 13.406672 12.997025 16.996109]
16.996109
[2.5045276 3.499199  4.493477 ]
4.493477
[ 6.9932833  9.997711  12.997025  16.990616 ]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.98576
[1.4941634 2.4994278 3.4973812 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4884412 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.4951684 4.493477 ]
4.493477
[ 6.998398  9.997711 12.991863 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4939346 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4916443 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.990616 ]
16.996109
[1.4886702 2.4994278 3.4975448 4.49897  ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.4962301 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.5042741 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.497285  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.990616 ]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.995232]
16.996109
[1.4941634 2.4994278 3.4937057 4.49897  ]
4.493477
[ 6.998398  9.997711 13.385557 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.991869 ]
16.996109
[1.4996567 2.4994278 3.5037217 4.4931083]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.995071 ]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.9919
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.99293
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4937057 4.49897  ]
4.493477
[ 6.998398  9.997711 13.388102 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.5028913 4.504463  0.9997711]
0.9997711
[2.4994278 3.4937057 4.493477 ]
4.504463
[ 6.998398  9.997711 12.997025 16.990616]
16.996109
[1.4941634 2.4939346 3.504692  4.493477 ]
4.49897
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.994757
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.992218  12.997025  16.995884 ]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.990559
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.997225  9.992218 12.997025 16.990616]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.994709
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.5005264 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.9944  ]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 13.391405 12.997025 16.996109]
16.99471
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4959404 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.995707 16.990616]
16.996454
[2.4994278 3.5038729 4.493477 ]
4.493477
[ 6.997249  9.992218 12.997025 16.992193]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4994278 3.5043566 4.4936943]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9941607  9.992218  12.997025  16.990616 ]
16.996109
[2.4939346 3.5030837 4.493477 ]
4.493477
[ 6.998398  9.992218 12.997025 16.992443]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.996109
[1.4941634 2.4994278 3.5003133 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.994404
[1.4886702 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9972544  9.992218  12.997025  16.990616 ]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990978]
16.996109
[1.4886702 2.4994278 3.504191  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398   9.997711  13.4127445 12.991531  16.996109 ]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 13.385183 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.4985616 4.493477 ]
4.493477
[ 6.998398  9.997711 13.39     12.997025 16.996109]
16.996109
[2.4978158 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.9942927  9.997711  12.997025  16.990616 ]
16.996109
[1.4941634 2.4994278 3.499104  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.992704
[1.4886702 2.4994278 3.5010796 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.995121
[1.4996567 2.5030854 3.499199  4.49897  ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.993357
[1.4941634 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.9918  ]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.990616
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4939346 3.504692  4.49449  ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4996567 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4939346 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.5008304 4.49897  ]
4.49897
[ 6.998398   9.997711  12.9962015 16.992403 ]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.500575  4.493477 ]
4.493477
[ 6.998398  9.997711 13.389138 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4916481 2.4994278 3.5014722 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4996443 3.5006905 4.49897  ]
4.49897
[ 6.998398  9.997711 12.997025 16.990616]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.992218 12.997025 16.990616]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[6.9874115 0.9997711]
0.9997711
[2.504921  3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.991888]
16.996109
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.997709  9.997711 12.991531 16.996109]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.4994278 3.5030675 4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[2.4994278 3.5002973 4.493477 ]
4.493477
[ 6.9945493  9.988707  12.99587   16.99381  ]
16.996109
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 13.391599 12.991531 16.996109]
16.996109
[1.4887204 2.4994278 3.504692  4.493523 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4941634 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 13.384739 12.991531 16.993145]
16.991007
[1.4941634 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.990616
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.491991 ]
4.493477
[ 6.998398  9.997711 12.997025 16.995358]
16.996109
[1.4886702 2.4994278 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.995974
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.996109
[1.4886702 2.4994278 3.499199  4.493477 ]
4.493477
[ 6.998398  9.997461 12.997025 16.996109]
16.993555
[1.4996567 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 13.39253  12.997025 16.996109]
16.996109
[1.4941634 2.4939346 3.4937057 4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 17.000694]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.996109 ]
16.996109
[2.494398  3.504692  4.4879837]
4.493477
[ 6.998398  9.997711 13.397216 12.997025 16.990616]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.49897  ]
4.49897
[ 6.9929047  9.997711  12.991531  16.996109 ]
16.996109
[2.4994278 3.499199  4.4934063]
4.493477
[ 6.998398  9.997711 13.386089 12.991531 16.996109]
16.996109
[2.4994278 3.504692  4.491533 ]
4.493477
[ 6.998398  9.997711 13.412965 12.991531 16.990616]
16.996109
[2.504921 3.504692 4.493477]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.50274   4.493477 ]
4.493477
[ 6.9929047  9.997711  12.991531  16.996109 ]
16.996109
[2.4939346 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.991531  16.996109 ]
16.996109
[2.4998555 3.5033114 4.491474 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4939346 3.504692  4.4910207]
4.493477
[ 6.998398  9.997711 13.374861 12.997025 16.996109]
16.996109
[2.4994278 3.499199  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.991531  16.996109 ]
16.996109
[2.4994278 3.499199  4.49897  ]
4.49897
[ 6.9973364  9.997711  12.9956455 16.990616 ]
16.996109
[1.4886702 2.4970424 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.997711  12.991531  16.990616 ]
16.990616
[1.4924439 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4886702 2.4994278 3.5036151 4.493477 ]
4.493477
[ 6.9929047  9.997711  12.997025  16.996109 ]
16.996109
[1.4941634 2.4994278 3.504692  4.4929338]
4.4879837
[ 6.998398  9.997325 12.997025 16.990616]
16.996109
[1.4886702 2.504921  3.5000856 4.493477 ]
4.493477
[ 6.998398  9.997711 13.392853 12.997025 16.996109]
16.996109
[2.4994278 3.5026681 4.493078 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.504921  3.5027192 4.4879837]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.5005472 4.49897  ]
4.49897
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.9929047  9.992218  12.991531  16.990616 ]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.996109
[2.4994278 3.504692  4.49897  ]
4.49897
[ 6.998398  9.997711 12.997025 16.992266]
16.996109
[1.4886702 2.4994278 3.5028405 4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.996109
[1.4886702 2.5024483 3.504692  4.4910913]
4.493477
[ 6.998398  9.997711 12.997025 16.996109]
16.996109
[1.4941634 2.5025089 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.997025 16.990616]
16.99205
[1.4906286 2.4994278 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.990616]
16.994165
[1.4941634 2.5045285 3.504692  4.493477 ]
4.493477
[ 6.998398  9.997711 12.991531 16.996109]
16.995588
[2.4994278 3.501567  4.4894013]
4.493477

plot RHI and MET on top of the QVP plots

# Create a plotting display object with 3 plots
combined = act.plotting.TimeSeriesDisplay({'KAZR2': ds_kazr2.sel(time=slice("2025-05-10T03:00:00","2025-05-10T18:00:00")), 'MET': ds_met.sel(time=slice("2025-05-10T03:00:00","2025-05-10T18:00:00")), 'MET' : ds_met.sel(time=slice("2025-05-10T03:00:00","2025-05-10T18:00:00"))}, figsize=(10,8), subplot_shape=(3,))
plt.subplots_adjust(hspace=0.4)

# top (first) subplot (index of 0)
combined.plot('reflectivity', dsname='KAZR2', subplot_index=(0,))

# middle (second) subplot (index of 1)
# Plot up the MET temperature and theta-e (calculated from met mean temp and RH)
combined.plot('temp_mean', dsname='MET', subplot_index=(1,))
ax2 = combined.axes[1].twinx() #copies the x axis onto both plots
ax2.plot(ds_met.time, thetaeC, color='orange')
ax2.set_ylabel('Theta-E (degC)', color='orange')

# bottom (third) subplot (index of 2)
# plot MET wind data time series
combined.plot('wspd_arith_mean', dsname='MET', subplot_index=(2,))


# Plot up a day/night background
combined.day_night_background(dsname='MET', subplot_index=(1,))
combined.day_night_background(dsname='MET', subplot_index=(2,))

# save figure
plt.savefig('/data/home/abchui/bnf-deep-convection/notebooks/plots/RHI_MET.png', dpi=400, bbox_inches="tight")

## QVP plots =================================
# plot with max height 2 km
htop = 2
plot_qvp_5variables(qvp_dbzs, qvp_vels, qvp_wths, qvp_zdrs,qvp_rhos,dtimes, hgt,el, case,htop,qvp_dir)
# plot_qvp_3variables(qvp_dbzs,qvp_zdrs,qvp_rhos,dtimes, hgt0,el, case,htop, qvp_dir)

# plot with max height 10 km
htop = 10
plot_qvp_5variables(qvp_dbzs, qvp_vels, qvp_wths, qvp_zdrs,qvp_rhos,dtimes, hgt,el, case,htop,qvp_dir)
# plot_qvp_3variables(qvp_dbzs,qvp_zdrs,qvp_rhos,dtimes, hgt0,el, case,htop, qvp_dir)


plt.show()

<Figure size 1000x800 with 5 Axes><Figure size 1000x800 with 10 Axes><Figure size 1000x800 with 10 Axes>
def plot_qvp_3variables(qvp_dbzs, qvp_zdrs, qvp_rhos, dtimes, hgt, htop, axes, row_offset):
    new_dbzs = np.array(qvp_dbzs).T
    new_zdrs = np.array(qvp_zdrs).T
    new_rhos = np.array(qvp_rhos).T

    # Apply masking
    mask = new_rhos < 0.2
    new_dbzs[mask] = np.nan
    new_zdrs[mask] = np.nan
    new_rhos[mask] = np.nan

    labels = ['Reflectivity [dBZ]', 'ZDR [dB]', 'RhoHV']
    cmaps = ['ChaseSpectral', 'ChaseSpectral', 'Spectral_r']
    data = [new_dbzs, new_zdrs, new_rhos]
    vmin = [-40, -2, 0]
    vmax = [40, 4, 1]

    for i in range(3):
        ax = axes[row_offset + i]
        pcm = ax.pcolormesh(dtimes, hgt / 1e3, data[i], vmin=vmin[i], vmax=vmax[i], cmap=cmaps[i])
        plt.colorbar(pcm, ax=ax, label=labels[i])
        ax.set_ylim(0, htop)
        ax.set_ylabel("Height [km]")
        ax.set_title(f"{labels[i]} (max height {htop} km)")
        ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
        ax.set_xlabel('Time [UTC]')
fig, axes = plt.subplots(6, 1, figsize=(12, 14), sharex=True)
fig.subplots_adjust(hspace=0.6)

# --- ACT PLOTS ---
ds_kazr2_sel = ds_kazr2.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00"))
ds_met_sel = ds_met.sel(time=slice("2025-05-10T03:00:00", "2025-05-10T18:00:00"))

axes[0].plot(ds_kazr2_sel.time, ds_kazr2_sel['reflectivity'], color='purple')
axes[0].set_ylabel('Reflectivity (dBZ)')
axes[0].set_title('KAZR2 Reflectivity')

axes[1].plot(ds_met_sel.time, ds_met_sel['temp_mean'], label='Temp (°C)', color='blue')
ax1b = axes[1].twinx()
ax1b.plot(ds_met_sel.time, thetaeC, label='Theta-E (°C)', color='orange')
axes[1].set_ylabel('Temp (°C)')
ax1b.set_ylabel('Theta-E (°C)', color='orange')
ax1b.tick_params(axis='y', labelcolor='orange')
axes[1].set_title('Temperature and Theta-E')

axes[2].plot(ds_met_sel.time, ds_met_sel['wspd_arith_mean'], color='green')
axes[2].set_ylabel('Wind Speed (m/s)')
axes[2].set_title('MET Wind Speed')

for i in range(3):
    axes[i].xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
    axes[i].tick_params(labelbottom=True)
    axes[i].set_xlabel('Time [UTC]')

# --- QVP (htop = 2 km) ---
plot_qvp_3variables(qvp_dbzs, qvp_zdrs, qvp_rhos, dtimes, hgt0, htop=2, axes=axes, row_offset=3)

fig.suptitle(f"BNF Time Series + QVP (2 km max height) @ {el}° on {case}", fontsize=16, y=0.995)
plt.tight_layout(rect=[0, 0, 1, 0.98])
# plt.savefig(f"{qvp_dir}/bnf_combined_qvp2km_timeseries_{el}deg_{case}.png", dpi=300, bbox_inches="tight")
plt.show()
<Figure size 1200x1400 with 10 Axes>
fig, axes = plt.subplots(3, 1, figsize=(10, 8), sharex=True)
fig.subplots_adjust(hspace=0.4)

plot_qvp_3variables(qvp_dbzs, qvp_zdrs, qvp_rhos, dtimes, hgt0, htop=10, axes=axes, row_offset=0)

fig.suptitle(f"BNF XSACR QVPs @ {el}° — Max Height 10 km on {case}", fontsize=16, y=0.98)
plt.tight_layout(rect=[0, 0, 1, 0.96])
# plt.savefig(f"{qvp_dir}/bnf_qvp10km_{el}deg_{case}.png", dpi=300, bbox_inches="tight")
plt.show()
<Figure size 1000x800 with 6 Axes>