mangadap.util.filter module

A set of functions used to filter arrays.

Revision history

26 Jan 2017: Original implementation by K. Westfall (KBW)
06 Apr 2017: Interpolate sigma vectors as well as the smoothed vectors in BoxcarFilter.
21 Dec 2017: Add weighting functionality to BoxcarFilter.


Copyright © 2019, SDSS-IV/MaNGA Pipeline Group

class mangadap.util.filter.BoxcarFilter(boxcar, lo=None, hi=None, niter=None, y=None, wgt=None, mask=None, local_sigma=None)[source]

Bases: object

_assign_par(boxcar, lo, hi, niter, local_sigma)[source]

Interpolate the smoothed image across the masked regions. Leading and trailing masked regions of each row are set to the first and last unmasked value, respectively.

interpolate both the smoothed data and the sigma

smooth(y, wgt=None, mask=None, boxcar=None, lo=None, hi=None, niter=None, local_sigma=None)[source]

Smooth a vector or array of vectors by a boxcar with specified rejection.

mangadap.util.filter.boxcar_smooth_vector(x, boxcar, mask=None, lo=None, hi=None, niter=None, return_mask=False)[source]
Boxcar smooth an input vector.
  • Ignores masked pixels.
  • Allows for iterative positive and negative outliers.
  • Can return the mask separately from the smoothed vector.
mangadap.util.filter.build_smoothing_mask(x, pix_buffer, default=None, mask_x=None)[source]

Construct a mask for the provided vector that masks the first and last pix_buffer pixels in the coordinate vector.

The mask is instantiated as fully unmasked, unless a default mask is provided.

To mask specified ranges in x, provide mask_x with a shape \(N_{\rm mask}\times 2\) where each mask is defined by the starting and ending value of x to exclude.

mangadap.util.filter.high_pass_filter(flux, dw=0, k=None, Dw=None)[source]

Pulled from FIREFLY’s hpf() function and edited on 17 Nov 2016.

Apply a high-pass filter to the input vector.

mangadap.util.filter.interpolate_masked_vector(y, quiet=True, extrap_with_median=False)[source]

Interpolate over the masked pixels in an input vector using linear interpolation.

  • y ( – Vector to interpolate.
  • quiet (bool, optional) – Suppress standard output (default is True).
  • extrap_with_median (bool, optional) – Instead of linear extrapolation, use the median of the interpolated vector. Defaults to linear extrapolation.

Returns the interpolated, unmasked vector.

Return type:


mangadap.util.filter.off_diagonal_identity(size, win, return_sparse=False)[source]

Construct a matrix with ones within a window along the diagonal.

  • size (int) – Size for the square matrix; i.e., \(N\) for the \(N\timesN\) matrix.
  • win (int) – Number of ones in each row along the diagonal.

ValueError – Raised if the window is larger than 2*size-1.

mangadap.util.filter.smooth_masked_vector(x, nsmooth)[source]

Smooth a masked vector by a box of size nsmooth.