djs_median

pydl.pydlutils.math.djs_median(array, dimension=None, width=None, boundary='none')[source]

Compute the median of an array.

Use a filtering box or collapse the image along one dimension.

Parameters:
arraynumpy.ndarray

input array

dimensionint, optional

Compute the median over this dimension. It is an error to specify both dimension and width.

widthint, optional

Width of the median window. In general, this should be an odd integer. It is an error to specify both dimension and width.

boundary{ ‘none’, ‘reflect’, ‘nearest’, ‘wrap’ }, optional

Boundary condition to impose. ‘none’ means no filtering is done within width/2 of the boundary. ‘reflect’ means reflect pixel values around the boundary. ‘nearest’ means use the values of the nearest boundary pixel. ‘wrap’ means wrap pixel values around the boundary. ‘nearest’ and ‘wrap’ are not implemented. If array is one-dimensional, and boundary is not ‘none’, then it is forced to be ‘reflect’.

Returns:
numpy.ndarray

The output. If neither dimension nor width are set, this is a scalar value, just the output of numpy.median(). If dimension is set, then the result simply numpy.median(array,dimension). If width is set, the result has the same shape as the input array.