mangadap.proc.spatialbinning module
Binning!
Copyright © 2019, SDSS-IV/MaNGA Pipeline Group
- class mangadap.proc.spatialbinning.GlobalBinning[source]
Bases:
SpatialBinningClass that performs the global binning.
- static bin_index(x, y, gpm=None, 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
SpatialBinningobject.- 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.
gpm (numpy.ndarray, optional) – Good value (pixel) mask used to select data that should be included in the bin. If None, all values are considered valid. If provided, masked values (gpm=False) are given a bin index of -1.
par (object, optional) – Not used.
- Returns:
An integer bin index for each spectrum.
- Return type:
- class mangadap.proc.spatialbinning.RadialBinning(par=None)[source]
Bases:
SpatialBinningClass 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
rsandreabove.- 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:
- Raises:
ValueError – Raised if
paris None.
- bin_index(x, y, gpm=None, 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.
gpm (numpy.ndarray, optional) – Good value (pixel) mask used to select data that should be included in the bin. If None, all values are considered valid. If provided, masked values (gpm=False) are given a bin index of -1.
par (
RadialBinningPar, optional) – Binning parameters. Cannot be None.
- Returns:
An integer bin index for each spectrum.
- Return type:
- Raises:
ValueError – Raised if the sizes of
xandydo not match or ifparis None.
- class mangadap.proc.spatialbinning.RadialBinningPar(center=[0.0, 0.0], pa=-1, ell=-1, radius_scale=-1, radii=[-1, -1, 10], log_step=False)[source]
Bases:
KeywordParSetClass with parameters used by the radial binning algorithm. See
mangadap.par.parset.ParSetfor attributes.The defined parameters are:
Key
Type
Options
Default
Description
centerndarray, 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.
paint, float
Sets the position angle, defined from N through E of the major axis of the isophotal ellipse used to define the elliptical bins. Set to <0 to indicate that the value should be filled by the metadata in the reduction assessment class; see
fill().ellint, float
Sets the ellipticity (1-b/a) of the isophotal ellipse use to define the elliptical bins. Set to <0 to indicate that the value should be filled by the metadata in the reduction assessment class; see
fill().radius_scaleint, 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. Set to <0 to indicate that the value should be filled by the metadata in the reduction assessment class; see
fill().radiindarray, 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_stepbool
A flag that the radial bins should be a geometric series.
- fill(rdxqa)[source]
Use the metadata in the reduction assessment results to fill out the binning parameters.
- 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. :param hdr: Header object to write to. :type hdr: astropy.io.fits.Header
- Returns:
Edited header object
- Return type:
- Raises:
TypeError – Raised if input is not an astropy.io.fits.Header object.
- class mangadap.proc.spatialbinning.SpatialBinning(bintype, par=None)[source]
Bases:
objectBase class for spatially binning data.
- class mangadap.proc.spatialbinning.SquareBinning(par=None)[source]
Bases:
SpatialBinningClass to perform binning of full cube in square apertures Length of aperture side is given in arcsec with binsz
- bin_index(x, y, gpm=None, 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.
gpm (numpy.ndarray, optional) – Good value (pixel) mask used to select data that should be included in the bin. If None, all values are considered valid. If provided, masked values (gpm=False) are given a bin index of -1.
par (
SquareBinningPar, optional) – Binning parameters. Cannot be None.
- Returns:
An integer bin index for each spectrum.
- Return type:
- Raises:
ValueError – Raised if the sizes of
xandydo not match or ifparis None.
- class mangadap.proc.spatialbinning.SquareBinningPar(binsz=2.0)[source]
Bases:
KeywordParSetClass with parameters used by the square binning algorithm. See
mangadap.par.parset.ParSetfor attributes.The defined parameters are:
Key
Type
Options
Default
Description
binszfloat
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:
- Raises:
TypeError – Raised if input is not an astropy.io.fits.Header object.
- class mangadap.proc.spatialbinning.VoronoiBinning(par=None)[source]
Bases:
SpatialBinningClass that wraps the contributed voronoi binning code.
- bin_index(x, y, gpm=None, 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.
gpm (numpy.ndarray, optional) – Good value (pixel) mask used to select data that should be included in the bin. If None, all values are considered valid. If provided, masked values (gpm=False) are given a bin index of -1.
par (
RadialBinningPar, optional) – Binning parameters. Cannot be None.
- Returns:
An integer bin index for each spectrum.
- Return type:
- Raises:
ValueError – Raised if the sizes of
xandydo not match, ifparis 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:
index (
int, numpy.ndarray) – Indices of the measurements in a single bin.signal (numpy.ndarray) – The signal measurements.
noise (numpy.ndarray) – The noise measurements.
- 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:
index (numpy.ndarray) – Indices of the measurements in a single bin.
signal (numpy.ndarray) – The signal measurements.
noise (numpy.ndarray) – The noise measurements.
- 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:
index (numpy.ndarray) – Indices of the measurements in a single bin.
signal (numpy.ndarray) – The signal measurements.
noise (numpy.ndarray) – The noise measurements.
- Returns:
The nominal signal-to-noise reached by summing the measurements selected by
index.- Return type:
float
- class mangadap.proc.spatialbinning.VoronoiBinningPar(target_snr=10.0, signal=None, noise=None, covar=None)[source]
Bases:
KeywordParSetClass with parameters used by the Voronoi binning algorithm.
See
mangadap.par.parset.ParSetfor attributes. See vorbin for the main algorithm.The defined parameters are:
Key
Type
Options
Default
Description
target_snrint, float
The target S/N for each bin.
signalndarray, list
The array of signal measurements for each on-sky position to bin. See
fill()to fill this based on the data in the reduction assessments object.noisendarray, list
The array of noise measurements for each on-sky position to bin. If not provided,
covarmust be provided and be a full covariance matrix. Seefill()to fill this based on the data in the reduction assessments object.covarfloat, 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. See
fill()to fill this based on the data in the reduction assessments object.- fill(rdxqa)[source]
Use the data in the reduction assessment results to fill out the binning parameters.
- 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:
- Raises:
TypeError – Raised if input is not an astropy.io.fits.Header object.