mangadap.util.filter module¶
A set of functions used to filter arrays.
 License:
 Copyright (c) 2017, SDSSIV/MaNGA Pipeline Group
 Licensed under BSD 3clause license  see LICENSE.rst
 Source location:
 $MANGADAP_DIR/python/mangadap/util/filter.py
 Imports and python version compliance:
from __future__ import division from __future__ import print_function from __future__ import absolute_import from __future__ import unicode_literals import sys if sys.version > '3': long = int import numpy
 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 toBoxcarFilter
.

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

_interpolate
()[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

mask
¶


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 highpass 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.
Parameters:  y (numpy.ma.MaskedArray) – 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: Returns the interpolated, unmasked vector.
Return type: numpy.ndarray

mangadap.util.filter.
off_diagonal_identity
(size, win, return_sparse=False)[source]¶ Construct a matrix with ones within a window along the diagonal.
Parameters:  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.
Raises: ValueError
– Raised if the window is larger than 2*size1.