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’