The Py-ART Radar object and indexing¶

[1]:
# The Py-ART radar object has functions and attributes that allow for a more
# in depth look of the data and the radar object.
[2]:
# Import needed modules
import numpy as np
import pyart

## 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

[3]:
# Load the radar file
radar = pyart.io.read("KATX20130717_195021_V06")
[4]:
# For a detailed print of the Py-ART radar object, use radar.info()
radar.info()
altitude:
        data: <ndarray of type: float64 and shape: (1,)>
        long_name: Altitude
        standard_name: Altitude
        units: meters
        positive: up
altitude_agl: None
antenna_transition: None
azimuth:
        data: <ndarray of type: float64 and shape: (7200,)>
        units: degrees
        standard_name: beam_azimuth_angle
        long_name: azimuth_angle_from_true_north
        axis: radial_azimuth_coordinate
        comment: Azimuth of antenna relative to true north
elevation:
        data: <ndarray of type: float32 and shape: (7200,)>
        units: degrees
        standard_name: beam_elevation_angle
        long_name: elevation_angle_from_horizontal_plane
        axis: radial_elevation_coordinate
        comment: Elevation of antenna relative to the horizontal plane
fields:
        differential_reflectivity:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: dB
                standard_name: log_differential_reflectivity_hv
                long_name: log_differential_reflectivity_hv
                valid_max: 7.9375
                valid_min: -7.875
                coordinates: elevation azimuth range
                _FillValue: -9999.0
        differential_phase:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: degrees
                standard_name: differential_phase_hv
                long_name: differential_phase_hv
                valid_max: 360.0
                valid_min: 0.0
                coordinates: elevation azimuth range
                _FillValue: -9999.0
        reflectivity:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: dBZ
                standard_name: equivalent_reflectivity_factor
                long_name: Reflectivity
                valid_max: 94.5
                valid_min: -32.0
                coordinates: elevation azimuth range
                _FillValue: -9999.0
        cross_correlation_ratio:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: ratio
                standard_name: cross_correlation_ratio_hv
                long_name: Cross correlation_ratio (RHOHV)
                valid_max: 1.0
                valid_min: 0.0
                coordinates: elevation azimuth range
                _FillValue: -9999.0
        spectrum_width:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: meters_per_second
                standard_name: doppler_spectrum_width
                long_name: Spectrum Width
                valid_max: 63.0
                valid_min: -63.5
                coordinates: elevation azimuth range
                _FillValue: -9999.0
        velocity:
                data: <ndarray of type: float32 and shape: (7200, 1832)>
                units: meters_per_second
                standard_name: radial_velocity_of_scatterers_away_from_instrument
                long_name: Mean doppler Velocity
                valid_max: 95.0
                valid_min: -95.0
                coordinates: elevation azimuth range
                _FillValue: -9999.0
fixed_angle:
        data: <ndarray of type: float32 and shape: (16,)>
        long_name: Target angle for sweep
        units: degrees
        standard_name: target_fixed_angle
instrument_parameters:
        unambiguous_range:
                data: <ndarray of type: float32 and shape: (7200,)>
                units: meters
                comments: Unambiguous range
                meta_group: instrument_parameters
                long_name: Unambiguous range
        nyquist_velocity:
                data: <ndarray of type: float32 and shape: (7200,)>
                units: meters_per_second
                comments: Unambiguous velocity
                meta_group: instrument_parameters
                long_name: Nyquist velocity
latitude:
        data: <ndarray of type: float64 and shape: (1,)>
        long_name: Latitude
        standard_name: Latitude
        units: degrees_north
longitude:
        data: <ndarray of type: float64 and shape: (1,)>
        long_name: Longitude
        standard_name: Longitude
        units: degrees_east
nsweeps: 16
ngates: 1832
nrays: 7200
radar_calibration: None
range:
        data: <ndarray of type: float32 and shape: (1832,)>
        units: meters
        standard_name: projection_range_coordinate
        long_name: range_to_measurement_volume
        axis: radial_range_coordinate
        spacing_is_constant: true
        comment: Coordinate variable for range. Range to center of each bin.
        meters_to_center_of_first_gate: 2125.0
        meters_between_gates: 250.0
scan_rate: None
scan_type: ppi
sweep_end_ray_index:
        data: <ndarray of type: int32 and shape: (16,)>
        long_name: Index of last ray in sweep, 0-based
        units: count
sweep_mode:
        data: <ndarray of type: |S20 and shape: (16,)>
        units: unitless
        standard_name: sweep_mode
        long_name: Sweep mode
        comment: Options are: "sector", "coplane", "rhi", "vertical_pointing", "idle", "azimuth_surveillance", "elevation_surveillance", "sunscan", "pointing", "manual_ppi", "manual_rhi"
sweep_number:
        data: <ndarray of type: int32 and shape: (16,)>
        units: count
        standard_name: sweep_number
        long_name: Sweep number
sweep_start_ray_index:
        data: <ndarray of type: int32 and shape: (16,)>
        long_name: Index of first ray in sweep, 0-based
        units: count
target_scan_rate: None
time:
        data: <ndarray of type: float64 and shape: (7200,)>
        units: seconds since 2013-07-17T19:50:21Z
        standard_name: time
        long_name: time_in_seconds_since_volume_start
        calendar: gregorian
        comment: Coordinate variable for time. Time at the center of each ray, in fractional seconds since the global variable time_coverage_start
metadata:
        Conventions: CF/Radial instrument_parameters
        version: 1.3
        title:
        institution:
        references:
        source:
        history:
        comment:
        instrument_name: KATX
        original_container: NEXRAD Level II
        vcp_pattern: 11
[5]:
# Let's view the elevation parameter. Py-ART stores all fields as 2D masked arrays
# of dimensions (number of rays) x (number of gates). Therefore, as the elevation can change with
# each ray, the data in the elevation array is a 1D array of dimension (number of rays)
radar.elevation
[5]:
{'units': 'degrees',
 'standard_name': 'beam_elevation_angle',
 'long_name': 'elevation_angle_from_horizontal_plane',
 'axis': 'radial_elevation_coordinate',
 'comment': 'Elevation of antenna relative to the horizontal plane',
 'data': array([ 0.7470703,  0.7196045,  0.6893921, ..., 19.511719 , 19.511719 ,
        19.511719 ], dtype=float32)}
[6]:
# If we just want the elevations of one sweep, we can use the get_slice() function
# of the Radar object to just get the elevations from one slice.
sweep_1 = radar.get_slice(1)
print(radar.elevation['data'][sweep_1])
[0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375
 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375]
[7]:
# All of the radar fields are stored in a dictionary called radar.fields. This dictionary
# contains entries that correspond to the field names in the file.
radar.fields['reflectivity']
[7]:
{'units': 'dBZ',
 'standard_name': 'equivalent_reflectivity_factor',
 'long_name': 'Reflectivity',
 'valid_max': 94.5,
 'valid_min': -32.0,
 'coordinates': 'elevation azimuth range',
 '_FillValue': -9999.0,
 'data': masked_array(
   data=[[10.5, 7.5, --, ..., --, --, --],
         [--, --, --, ..., --, --, --],
         [9.5, --, --, ..., --, --, --],
         ...,
         [-10.5, -15.0, -9.5, ..., --, --, --],
         [-14.0, -13.5, -13.5, ..., --, --, --],
         [-11.0, -15.0, 0.5, ..., --, --, --]],
   mask=[[False, False,  True, ...,  True,  True,  True],
         [ True,  True,  True, ...,  True,  True,  True],
         [False,  True,  True, ...,  True,  True,  True],
         ...,
         [False, False, False, ...,  True,  True,  True],
         [False, False, False, ...,  True,  True,  True],
         [False, False, False, ...,  True,  True,  True]],
   fill_value=1e+20,
   dtype=float32)}
[8]:
# This shows entries such as the data itself, coordinates, long name, and units. You can
# access the array with the reflectivity data itself using radar.fields['reflectivity']['data'].
# This is stored as a 2D masked array with dimensions (number of rays) x (number of gates)
radar.fields['reflectivity']['data']
[8]:
masked_array(
  data=[[10.5, 7.5, --, ..., --, --, --],
        [--, --, --, ..., --, --, --],
        [9.5, --, --, ..., --, --, --],
        ...,
        [-10.5, -15.0, -9.5, ..., --, --, --],
        [-14.0, -13.5, -13.5, ..., --, --, --],
        [-11.0, -15.0, 0.5, ..., --, --, --]],
  mask=[[False, False,  True, ...,  True,  True,  True],
        [ True,  True,  True, ...,  True,  True,  True],
        [False,  True,  True, ...,  True,  True,  True],
        ...,
        [False, False, False, ...,  True,  True,  True],
        [False, False, False, ...,  True,  True,  True],
        [False, False, False, ...,  True,  True,  True]],
  fill_value=1e+20,
  dtype=float32)
[9]:
# If you just want the data from one slice, you can get the indicies for the
# slice using radar.get_slice()
slice_indices = radar.get_slice(0)
print(radar.fields['reflectivity']['data'][slice_indices])
[[10.5 7.5 -- ... -- -- --]
 [-- -- -- ... -- -- --]
 [9.5 -- -- ... -- -- --]
 ...
 [-- 6.0 11.0 ... -- -- --]
 [-- -- -- ... -- -- --]
 [-- -- -- ... -- -- --]]
[10]:
# You can also iterate over each slice by using radar.iter_slice() This example
# returns the mean reflectivity of each sweep.
reflectivity = [radar.fields['reflectivity']['data'][x].mean() for x in radar.iter_slice()]
print(reflectivity)
[-2.9066728410400056, -3.478547577741713, -6.587792083929423, -6.871031288639269, -10.971692217963673, -11.830616390843327, -12.108188248095756, -12.483419908190385, -12.88976917057903, -11.852766685681688, -12.410455582269897, -12.66444787446138, -12.997862391449566, -13.172098402018502, -13.489752513534416, -13.712565619531706]
[11]:
# You can also view the important radar instrument parameters. One commonly used parameter
# is the nyquist velocity, which is the maximum magnitude of the velocity the radar is
# capable of recording before a phenomena known as aliasing occurs.
radar.instrument_parameters['nyquist_velocity']['data']
[11]:
array([ 8.81,  8.81,  8.81, ..., 32.33, 32.33, 32.33], dtype=float32)