mangadap.proc.spatialbinning module

Binning!

License:
Copyright (c) 2015, SDSS-IV/MaNGA Pipeline Group
Licensed under BSD 3-clause license - see LICENSE.rst
Source location:
$MANGADAP_DIR/python/mangadap/proc/spatialbins.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
from scipy import sparse
from astropy.io import fits

from vorbin.voronoi_2d_binning import voronoi_2d_binning

from ..par.parset import ParSet
from ..util.geometry import SemiMajorAxisCoo
from ..util.covariance import Covariance
Class usage examples:
Add examples
Revision history:
01 Apr 2016: Implementation begun by K. Westfall (KBW)
22 May 2018: (KBW) Import vorbin package version of voronoi_2d_binning
class mangadap.proc.spatialbinning.GlobalBinning[source]

Bases: mangadap.proc.spatialbinning.SpatialBinning

Class that performs the global binning.

static bin_index(x, y, par=None)[source]
class mangadap.proc.spatialbinning.RadialBinning(par=None)[source]

Bases: mangadap.proc.spatialbinning.SpatialBinning

Class that performs the radial binning.

_r_start_step(r)[source]

Bin starting radii are:

rs = self.par['radii'][0]
re = self.par['radii'][1]
nr = int(self.par['radii'][2])
starting_radii = numpy.logspace(numpy.log10(rs), numpy.log10(re), num=nr,
                                endpoint=False) if self.par['log_step'] else                              numpy.linspace(rs, re, num=nr, endpoint=False)

For ending radii, just swap rs and re above

bin_area()[source]

Return the nominal area for each elliptical bin.

bin_index(x, y, par=None)[source]

Bin the data and return the indices of the bins.

class mangadap.proc.spatialbinning.RadialBinningPar(center, pa, ell, radius_scale, radii, log_step)[source]

Bases: mangadap.par.parset.ParSet

Class with parameters used by the radial binning algorithm. See mangadap.par.parset.ParSet for attributes.

Parameters:
  • center (numpy.ndarray or list) – A two-element array defining the center to use in the definition of the elliptical bins. This is defined as a sky-right offset in arcseconds from the nominal center of the object (OBJRA,OBJDEC).
  • pa (float) – Sets the position angle, defined from N through E of the major axis of the isophotal ellipse used to define the elliptical bins.
  • ell (float) – Sets the ellipticity (1-b/a) of the isophotal ellipse use to define the elliptical bins.
  • radius_scale (float) – Defines a scale factor to use when defining the radial bins. For example, you might want to scale to the a certain number of effective radii or physical scale in kpc. For no scale, use 1.0.
  • radii (numpy.ndarray or list) – A three-element array defining the starting and ending radius for the bin edges and the number of bins to create. If the starting radius is -1, the inner-most radius is set to 0 when not using log bins or 0.1 arcsec when using logarithmically spaced bins. If the ending radius is -1, the outer-most radius is set by the spaxel at the largest radius.
  • log_step (bool) – A flag that the radial bins should be a geometric series.
fromheader(hdr)[source]

Copy the information from the header.

hdr (astropy.io.fits.Header): Header object to write to.

toheader(hdr)[source]

Copy some of the parameters to a header.

Parameters:hdr (astropy.io.fits.Header) – Header object to write to.
Returns:Edited header object
Return type:astropy.io.fits.Header
Raises:TypeError – Raised if input is not an astropy.io.fits.Header object.
class mangadap.proc.spatialbinning.SpatialBinning(bintype, par=None)[source]

Bases: object

Base class for spatially binning data.

class mangadap.proc.spatialbinning.SquareBinning(par=None)[source]

Bases: mangadap.proc.spatialbinning.SpatialBinning

Class to perform binning of full cube in square apertures Length of aperture side is given in arcsec with binsz

bin_index(x, y, par=None)[source]

Bin the data and return the indices of the bins.

class mangadap.proc.spatialbinning.SquareBinningPar(binsz)[source]

Bases: mangadap.par.parset.ParSet

Class with parameters used by the square binning algorithm. See mangadap.par.parset.ParSet for attributes.

Parameters:binsz (float) – Sets desired bin size in arcsec
fromheader(hdr)[source]

Copy the information from the header.

hdr (astropy.io.fits.Header): Header object to write to.

toheader(hdr)[source]

Copy some of the parameters to a header.

Parameters:hdr (astropy.io.fits.Header) – Header object to write to.
Returns:Edited header object
Return type:astropy.io.fits.Header
Raises:TypeError – Raised if input is not an astropy.io.fits.Header object.
class mangadap.proc.spatialbinning.VoronoiBinning(par=None)[source]

Bases: mangadap.proc.spatialbinning.SpatialBinning

Class that wraps the contributed voronoi binning code.

bin_index(x, y, par=None)[source]
sn_calculation_calibrate_noise(index, signal, noise)[source]

Calculate the S/N using a calibration of the S/N following:

\[N_{\rm calib} = N_{\rm nominal} (1 + \alpha\ \log N_{\rm bin})\]

where \(N_{\rm bin}\) is the number of binned spaxels and \(\alpha\) is an empirically derived constant used to adjust the noise for the affects of covariance.

sn_calculation_covariance_matrix(index, signal, noise)[source]

Calculate the S/N using a full covariance matrix.

sn_calculation_no_covariance(index, signal, noise)[source]

S/N calculation built to match the requirements of mangadap.contrib.voronoi_2d_binning().

This calculation is identical to the one provided directly by the code.

class mangadap.proc.spatialbinning.VoronoiBinningPar(target_snr, signal, noise, covar)[source]

Bases: mangadap.par.parset.ParSet

Class with parameters used by the Voronoi binning algorithm. See mangadap.par.parset.ParSet for attributes.

Parameters:
  • key (str) – Keyword to distinguish the assessment method.
  • target_snr (float) – The target S/N for each bin.
  • signal (array-like) – The array of signal measurements for each on-sky position to bin.
  • noise (array-like) – The array of noise measurements for each on-sky position to bin. If not provided, covar must be provided and be a full covariance matrix.
  • (float, numpy.ndarray, (covar) –

    mangadap.util.Covariance, scipy.sparse.spmatrix): Covariance matrix or calibration normalization. For the latter, the value is used to renormalize the noise according to the following equation:

    where \(N_{\rm bin}\) is the number of binned spaxels and \(\alpha\) is the value provided. See mangadap.contrib.voronoi_2d_binning._sn_func().

fromheader(hdr)[source]

Copy the information from the header.

hdr (astropy.io.fits.Header): Header object to write to.

toheader(hdr)[source]

Copy some of the parameters to a header.

Parameters:hdr (astropy.io.fits.Header) – Header object to write to.
Returns:Edited header object
Return type:astropy.io.fits.Header
Raises:TypeError – Raised if input is not an astropy.io.fits.Header object.