Rainfall accumulation

I thought I posted here a few weeks ago, but couldn’t find a post from me when I went to look back for it. Apologies if I’ve missed it.

I have a problem I’m trying to help a colleague with and am comimg up short. He has two weeks’ worth of radar data from a site in Hawaii. From this data, he needs to know the total rainfall at a certain lat/lon within that two week period. I know Xarray is involved, but I’m still stuck on how to approach this.

Thanks,
David

Thanks for asking this question @davidmoranccm - I would start by checking out the Xradar documentation

This package will enable you to read in the data (what format is the dataset?)

Once you read in the data, you will either need to use one of the existing rainfall fields, or estimate the rainfall rate from reflectivity using some relationship.

If you are interested in using Py-ART for this, an example of calculating Quantitative Precipitation Estimation (QPE) from radar data was covered at the recent ERAD workshop

https://openradarscience.org/erad2022/notebooks/pyart/exercice1_swiss_thunderstorm.html

1 Like

Thanks! I will check these out!

OK, I feel stupid for asking, but I started installing Pyart and followed the instructions here: The Python ARM Radar Toolkit - Py-ART — Py-ART 1.14.1.post1 documentation. I grabbed a script off the Pyart website and when I ran it, I get:

Traceback (most recent call last):
File “C:\Users\David\Desktop\plot_nexrad_data_aws.py”, line 18, in
import pyart
ModuleNotFoundError: No module named ‘pyart’

Where could I have gone wrong?

Thanks!

There are no stupid questions! Did you activate your conda environment? What are you using to manage your environments?

I don’t think so; how do I do that? I’m using Anaconda.

I really like the description/videos from the NCAR Earth System Data Science site.

https://ncar.github.io/esds/faq/#conda-environments

I would follow those videos/commands. Once you activate your environment

conda activate my-environment

You will need to install Py-ART

conda install -c conda-forge arm_pyart

Then, you can run

python -m my_script.py

The conda cheatsheet might help here too.

I finally had some time to work on my problem. Here’s a script I modified and the error I got. I’m not sure how to proceed. Thanks for all of the help; I really want to figure this out.

from future import print_function
import numpy as np
import pyart
import pyproj

def find_x_y_displacement(radar, longitude, latitude):
“”" Return the x and y displacement (in meters) from a radar location. “”"
# longitude and latitude in degrees
lat_0 = radar.latitude[‘data’][0]
lon_0 = radar.longitude[‘data’][0]
proj = pyproj.Proj(proj=‘aeqd’, lon_0=lon_0, lat_0=lat_0)
return proj(longitude, latitude)

def find_nearest_gate(radar, longitude, latitude, altitude):
“”" Return the indices of the nearest gate to a given point. “”"
# longitude and latitude in degrees, altitude in meters
gate_x = radar.gate_x[‘data’]
gate_y = radar.gate_y[‘data’]
gate_z = radar.gate_z[‘data’]

x_disp, y_disp = find_x_y_displacement(radar, longitude, latitude)
distances = np.sqrt(
    (gate_x-x_disp)**2. + (gate_y-y_disp)**2. + (gate_z-altitude)**2.)
return np.unravel_index(distances.argmin(), distances.shape)

def interpolate_single_point(radar, longitude, latitude, altitude):
“”" Interpolate a single grid point at a given location. “”"
x_disp, y_disp = find_x_y_displacement(radar, longitude, latitude)
grid = pyart.map.grid_from_radars(
(radar,),
gridding_algo=‘map_gates_to_grid’,
grid_shape=(1, 1, 1),
grid_limits=((altitude, 0), (y_disp, 25000.0), (x_disp, 25000.0)),
fields=[‘reflectivity’])
return grid

read in the file

filename = ‘NWS_NEXRAD_NXL2DPBL_PHMO_20220626010000_20220626015959\PHMO20220626_010223_V06.ar2v’
radar = pyart.io.read_nexrad_archive(filename)

latitude = 21.3 # latitude (in degrees) to find reflectivity at or near
longitude = 157.8 # longitude (in degrees) to find reflectivity at or near
altitude = 1000 # altitude (in meters) to find reflectivity at or near

find nearest gate

ray, gate = find_nearest_gate(radar, longitude, latitude, altitude)
gate_latitude = radar.gate_latitude[‘data’][ray, gate]
gate_longitude = radar.gate_longitude[‘data’][ray, gate]
gate_altitude = radar.gate_altitude[‘data’][ray, gate]
gate_reflectivity = radar.fields[‘reflectivity’][‘data’][ray, gate]
print(“-----------------------”)
print(“Nearest gate:”)
print(“Latitude:”, gate_latitude)
print(“Longitude:”, gate_longitude)
print(“Altitude:”, gate_altitude)
print(“Reflectivity:”, gate_reflectivity)

interpolate around gate

grid = interpolate_single_point(radar, longitude, latitude, altitude)
pyart.core.get_point_longitude_latitude(grid)
pixel_latitude = grid.axes[‘latitude’][‘data’][0, 0]
pixel_longitude = grid.axes[‘longitude’][‘data’][0, 0]
pixel_altitude = grid.axes[‘z_disp’][‘data’][0]
pixel_reflectivity = grid.fields[‘reflectivity’][‘data’][0, 0]

print(“-----------------------”)
print(“Interpolated pixel:”)
print(“Latitude:”, pixel_latitude)
print(“Longitude:”, pixel_longitude)
print(“Altitude:”, pixel_altitude)
print(“Reflectivity:”, pixel_reflectivity)

Traceback (most recent call last):
File “…\test.py”, line 64, in
pyart.core.get_point_longitude_latitude(grid)
AttributeError: module ‘pyart.core’ has no attribute ‘get_point_longitude_latitude’

Which version of Py-ART are you running?

If I’m looking at it right, 1.14.1.

image001.png