reduce_point_density¶
-
metpy.calc.
reduce_point_density
(points, radius, priority=None)[source]¶ Return a mask to reduce the density of points in irregularly-spaced data.
This function is used to down-sample a collection of scattered points (e.g. surface data), returning a mask that can be used to select the points from one or more arrays (e.g. arrays of temperature and dew point). The points selected can be controlled by providing an array of
priority
values (e.g. rainfall totals to ensure that stations with higher precipitation remain in the mask).- Parameters
points ((N, K) array-like) – N locations of the points in K dimensional space
radius (float) – minimum radius allowed between points
priority ((N, K) array-like, optional) – If given, this should have the same shape as
points
; these values will be used to control selection priority for points.
- Returns
(N,) array-like of boolean values indicating whether points should be kept. This
can be used directly to index numpy arrays to return only the desired points.
Examples
>>> metpy.calc.reduce_point_density(np.array([1, 2, 3]), 1.) array([ True, False, True]) >>> metpy.calc.reduce_point_density(np.array([1, 2, 3]), 1., ... priority=np.array([0.1, 0.9, 0.3])) array([False, True, False])