mangadap.proc.spatialbinning module

Binning!

Revision history

01 Apr 2016: Implementation begun by K. Westfall (KBW)
22 May 2018: (KBW) Import vorbin package version of voronoi_2d_binning

License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


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]

Bin the data and return the indices of the bins.

The calling sequence is just needed to match the expectation for a SpatialBinning object.

Parameters
  • x (numpy.ndarray) – Fiducial on-sky X position of each spectrum. X increases with RA. Only used to set the size of the returned array.

  • y (numpy.ndarray) – Not used.

  • par (object, optional) – Not used.

Returns

An integer bin index for each spectrum.

Return type

numpy.ndarray

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.

Parameters

r (numpy.ndarray) – Fiducial radius of each spectrum.

bin_area()[source]

Return the nominal area for each elliptical bin.

Returns

Array with the analytic on-sky area of each elliptical bin in square arcsec given its radial limits.

Return type

numpy.ndarray

Raises

ValueError – Raised if par is None.

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

Bin the data and return the indices of the bins.

Parameters
  • x (numpy.ndarray) – Fiducial on-sky X position of each spectrum. X increases with RA.

  • y (numpy.ndarray) – Fiducial on-sky Y position of each spectrum. Y increases with DEC.

  • par (RadialBinningPar, optional) – Binning parameters. Cannot be None.

Returns

An integer bin index for each spectrum.

Return type

numpy.ndarray

Raises

ValueError – Raised if the sizes of x and y do not match or if par is None.

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

Bases: mangadap.par.parset.KeywordParSet

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

The defined parameters are:

Key

Type

Options

Default

Description

center

ndarray, 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.

pa

int, 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

int, float

Sets the ellipticity (1-b/a) of the isophotal ellipse use to define the elliptical bins.

radius_scale

int, 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

ndarray, 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.

Parameters

hdr (astropy.io.fits.Header) – Header object to read from.

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.

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

Undefined in base class. Just provides expected calling sequence.

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.

Parameters
  • x (numpy.ndarray) – Fiducial on-sky X position of each spectrum. X increases with RA.

  • y (numpy.ndarray) – Fiducial on-sky Y position of each spectrum. Y increases with DEC.

  • par (SquareBinningPar, optional) – Binning parameters. Cannot be None.

Returns

An integer bin index for each spectrum.

Return type

numpy.ndarray

Raises

ValueError – Raised if the sizes of x and y do not match or if par is None.

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

Bases: mangadap.par.parset.KeywordParSet

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

The defined parameters are:

Key

Type

Options

Default

Description

binsz

float

Desired bin size in arcsec

fromheader(hdr)[source]

Copy the information from the header.

Parameters

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]

Bin the data and return the indices of the bins.

Parameters
  • x (numpy.ndarray) – Fiducial on-sky X position of each spectrum. X increases with RA.

  • y (numpy.ndarray) – Fiducial on-sky Y position of each spectrum. Y increases with DEC.

  • par (RadialBinningPar, optional) – Binning parameters. Cannot be None.

Returns

An integer bin index for each spectrum.

Return type

numpy.ndarray

Raises

ValueError – Raised if the sizes of x and y do not match, if par is None, if various checks of the signal, noise, or covariance elements are incorrectly matched.

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.

The calibration constant, \(\alpha\), is kept internally using covar.

Parameters
Returns

The nominal signal-to-noise reached by summing the measurements selected by index, after applying the covariance calibration.

Return type

float

sn_calculation_covariance_matrix(index, signal, noise)[source]

Calculate the S/N using a full covariance matrix.

The method uses the internal covar.

Parameters
Returns

The nominal signal-to-noise reached by summing the measurements selected by index, including any covariance.

Return type

float

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.

Parameters
Returns

The nominal signal-to-noise reached by summing the measurements selected by index.

Return type

float

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

Bases: mangadap.par.parset.KeywordParSet

Class with parameters used by the Voronoi binning algorithm.

See mangadap.par.parset.ParSet for attributes. See vorbin for the main algorithm.

The defined parameters are:

Key

Type

Options

Default

Description

target_snr

int, float

The target S/N for each bin.

signal

ndarray, list

The array of signal measurements for each on-sky position to bin.

noise

ndarray, list

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.

covar

float, ndarray, Covariance, spmatrix

Covariance matrix or calibration normalization. For the latter, the value is used to renormalize using \(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 the value provided.

fromheader(hdr)[source]

Copy the information from the header.

Parameters

hdr (astropy.io.fits.Header) – Header object to read from.

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.