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). The points and radius can be specified with units. If none are provided, meters are assumed.

Parameters
  • points ((N, K) array-like) – N locations of the points in K dimensional space

  • radius (pint.Quantity or float) – Minimum radius allowed between points. If units are not provided, meters is assumed.

  • 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])

Examples using metpy.calc.reduce_point_density