- metpy.calc.reduce_point_density(points, radius, priority=None)#
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
priorityvalues (e.g. rainfall totals to ensure that stations with higher precipitation remain in the mask). The points and radius can be specified with units. If none are provided, meters are assumed.
Points with at least one non-finite (i.e. NaN or Inf) value are ignored and returned with a value of
False(meaning don’t keep).
points ((N, M) array-like) – N locations of the points in M dimensional space
pint.Quantityor float) – Minimum radius allowed between points. If units are not provided, meters is assumed.
priority ((N, M) array-like, optional) – If given, this should have the same shape as
points; these values will be used to control selection priority for points.
(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.
>>> 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])