Will H
unread,Dec 5, 2024, 3:22:31 PM12/5/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wrfpython-talk
Has anyone ever come up with a way to calculate visibility?
I have a python calculation I stumbled upon but I'm not sure if it is valid:
# Extract necessary variables with their respective units
q_rain = wrf.getvar(wrf_file, "QRAIN")[0,:,:] # Mixing ratio for rain (kg/kg)
q_snow = wrf.getvar(wrf_file, "QSNOW")[0,:,:] # Mixing ratio for snow (kg/kg)
q_graupel = wrf.getvar(wrf_file, "QGRAUP")[0,:,:] # Mixing ratio for graupel (kg/kg)
pressure = wrf.getvar(wrf_file, "PSFC") # Surface pressure (Pa)
temperature = wrf.getvar(wrf_file, "T2") # 2-meter temperature (K)
R = 287.05 # Specific gas constant for dry air, J/(kg·K)
# Calculate air density (kg/m³)
rho = pressure / (R * temperature)
# Constants for extinction coefficients calculation
visfactor = 3.912 # Extinction coefficient to visibility conversion factor (dimensionless)
# Calculate mass concentration from mixing ratios and density (convert to g/m³)
br = 1.1 * (1000 * rho * (q_rain + q_graupel))**0.75 # Rain and graupel extinction coefficient (m⁻¹)
bs = 10.36 * (1000 * rho * q_snow)**0.78 # Snow extinction coefficient (m⁻¹)
# Calculate extinction coefficient (m⁻¹) and visibility (m)
hydro_ext_coeff = (br + bs) / 1000 # Total hydrometeor extinction coefficient (m⁻¹)
vis_hydro = np.where(hydro_ext_coeff > 0, visfactor / hydro_ext_coeff, 999999.0) # Visibility in meters
vis_hydro_miles = vis_hydro * 0.000621371 # Convert visibility to miles