Skip to content

Instantly share code, notes, and snippets.

@deeplycloudy
Created December 7, 2018 21:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeplycloudy/d5d4f137dd7496434e09f1fbc2122b0f to your computer and use it in GitHub Desktop.
Save deeplycloudy/d5d4f137dd7496434e09f1fbc2122b0f to your computer and use it in GitHub Desktop.
Eliminate duplicate elevation angles in a pyart radar object (e.g., 88D SAILS)
def get_vcp(radar):
""" Return a list of elevation angles representative of each sweep.
These are the median of the elevation angles in each sweep, which are
more likely to be identical than the mean due to change of elevation angle
at the beginning and end of each sweep.
"""
vcp = [np.median(el_this_sweep) for el_this_sweep in radar.iter_elevation()]
return np.asarray(vcp, dtype=radar.elevation['data'].dtype)
def unique_sweeps_by_elevation_angle(radar, tol=0.05):
""" Returns the sweep indices that correspond to unique
elevation angles, for use in extract_sweeps.
The default is a tolerance of 0.05 deg.
"""
vcp = get_vcp(radar)
close_enough = (vcp/tol).astype('int32')
unq_el, unq_el_idx = np.unique(close_enough, return_index=True)
return unq_el_idx
unq_swp = unique_sweeps_by_elevation_angle(radar)
radar_subset = radar.extract_sweeps(unq_swp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment