mangadap.proc.reductionassessments module

Class that performs a number of assessments of a DRP file needed for handling of the data by the DAP. These assessments need only be done once per DRP data file.

Revision history

24 Mar 2016: Implementation begun by K. Westfall (KBW)
11 May 2016: (KBW) Switch to using pydl.goddard.astro.airtovac instead of internal function
19 May 2016: (KBW) Added loggers and quiet keyword arguments to ReductionAssessment, removed verbose
23 Feb 2017: (KBW) Use DAPFitsUtil read and write functions.
27 Feb 2017: (KBW) Use DefaultConfig.
17 May 2017: (KBW) Added ability to use a response function for the flux statistics.
23 Feb 2020: (KBW) Now uses DataCube instead of DRPFits

License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


class mangadap.proc.reductionassessments.ReductionAssessment(method_key, cube, pa=None, ell=None, method_list=None, dapver=None, analysis_path=None, directory_path=None, output_file=None, hardcopy=True, symlink_dir=None, clobber=False, checksum=False, loggers=None, quiet=False)[source]

Bases: object

Perform basic assessments of the datacube.

These assessments are needed for handling of the data by the DAP and only to be done once per datacube.

See compute() for the provided data.

Parameters
  • method_key (str) – Keyword selecting the assessment method to use.

  • cube (mangadap.datacube.datacube.DataCube) – Datacube to analyze.

  • pa (float, optional) – On-sky position angle of the major axis used to calculate elliptical, semi-major-axis coordinates, defined as the angle from North through East and denoted \(\phi_0\).

  • ell (float, optional) – Ellipticity defined as \(\varepsilon=1-b/a\), based on the semi-minor to semi-major axis ratio (\(b/a\)) of the isophotal ellipse used to calculate elliptical, semi-major-axis coordinates.

  • method_list (list, optional) – List of ReductionAssessmentDef objects that define the parameters required to perform the assessments of the DRP file. The method_key must select one of these objects. Default is to construct the list using available_reduction_assessments().

  • dapver (str, optional) – DAP version, which is used to define the default DAP analysis path. (This does not define the version of the code to use.) Default is defined by mangadap.config.defaults.dap_version()

  • analysis_path (str, optional) – The path to the top-level directory for the DAP output files for a given DRP and DAP version. Default is defined by mangadap.config.defaults.dap_analysis_path().

  • directory_path (str, optional) – The exact path for the output file. Default is defined by mangadap.config.defaults.dap_common_path().

  • output_file (str, optional) – The name of the file for the computed assessments. The full path of the output file will be directory_path/output_file. Default is defined by mangadap.config.defaults.dap_file_name().

  • hardcopy (bool, optional) – Flag to write the data to a fits file.

  • symlink_dir (str, optional) – Create a symlink to the file in this directory.

  • clobber (bool, optional) – If the output file already exists, this will force the assessments to be redone and the output file to be overwritten.

  • checksum (bool, optional) – Compare the checksum when reading the data.

  • loggers (list, optional) – List of logging.Logger objects to log progress; ignored if quiet=True. Logging is done using mangadap.util.log.log_output(). Default is no logging.

  • quiet (bool, optional) – Suppress terminal and logging output.

method

Parameters defining the method to use for the reduction assessments.

Type

ReductionAssessmentDef

cube

Datacube to analyze.

Type

mangadap.datacube.datacube.DataCube

pa

On-sky position angle of the major axis used to calculate elliptical, semi-major-axis coordinates, defined as the angle from North through East and denoted \(\phi_0\).

Type

float

ell

Ellipticity defined as \(\varepsilon=1-b/a\), based on the semi-minor to semi-major axis ratio (\(b/a\)) of the isophotal ellipse used to calculate elliptical, semi-major-axis coordinates.

Type

float

directory_path

The exact path for the output file.

Type

str

output_file

The name of the file for the computed assessments. The full path of the output file will be directory_path/output_file.

Type

str

hardcopy

Flag to write the data to a fits file.

Type

bool

Create a symlink to the file in this directory.

Type

str

hdu

HDUList with the data, with columns as described above.

Type

astropy.io.fits.HDUList

correlation

If requested, provides the spatial correlation matrix for the flux at a fiducial wavelength in the datacube. See covar_wave and covar_channel.

Type

mangadap.util.covariance.Covariance

covar_wave

The wavelength in angstroms at which the correlation matrix (correlation) was calculated, if available. Can be None if the covariance matrix is pulled directly from cube.

Type

float

covar_channel

The wavelength channel at which the correlation matrix (correlation) was calculated, if available. Can be None if the covariance matrix is pulled directly from cube.

Type

int

loggers

List of logging.Logger objects to log progress; ignored if quiet=True. Logging is done using mangadap.util.log.log_output().

Type

list

quiet

Suppress terminal and logging output.

Type

bool

_define_method(method_key, method_list=None)[source]

Select the assessment method from the provided list.

Used to set method; see mangadap.proc.util.select_proc_method().

Parameters
_initialize_primary_header(hdr=None)[source]

Constuct the primary header for the reference file.

Parameters

hdr (astropy.io.fits.Header, optional) – Input base header for added keywords. If None, uses the cube header (if there is one) and then cleans the header using mangadap.util.fitsutil.DAPFitsUtil.clean_dap_primary_header().

Returns

Initialized header object.

Return type

astropy.io.fits.Header

_per_spectrum_dtype()[source]

Construct the record array data type for the output fits extension.

_set_paths(directory_path, dapver, analysis_path, output_file)[source]

Set the I/O paths.

Used to set directory_path and output_file. If not provided, the defaults are set using, respectively, mangadap.config.defaults.dap_common_path() and mangadap.config.defaults.dap_file_name().

Parameters
  • directory_path (str) – The exact path to the DAP reduction assessments file. See directory_path.

  • dapver (str) – DAP version.

  • analysis_path (str) – The path to the top-level directory containing the DAP output files for a given DRP and DAP version.

  • output_file (str) – The name of the file with the reduction assessments. See compute().

compute(cube, pa=None, ell=None, dapver=None, analysis_path=None, directory_path=None, output_file=None, hardcopy=True, symlink_dir=None, clobber=False, loggers=None, quiet=False)[source]

Compute and output the main data products. The list of HDUs are:

  • PRIMARY : Empty apart from the header information.

  • SPECTRUM : Extension with the main, per-spectrum measurements; see below.

  • CORREL : The correlation matrix between the SIGNAL measurements provided in the SPECTRUM extension. The format of this extension is identical to the nominal output of the mangadap.util.covariance.Covariance object; see mangadap.util.covariance.Covariance.write().

The SPECTRUM extension contains the following columns:

  • SPAT_INDX: Vector of tuples providing the 2D spatial array indices associated with each measurement. See mangadap.datacube.datacube.DataCube.spatial_index.

  • SKY_COO: On-sky X and Y coordinates. Coordinates are sky-right offsets from the object center; i.e., positive X is along the direction of positive right ascension. See mangadap.datacube.datacube.DataCube.mean_sky_coordinates.

  • ELL_COO: Elliptical (semi-major axis) radius and azimuth angle from N through East with respect to the photometric position angle; based on the provided ellipticity parameters. See mangadap.util.geometry.SemiMajorAxisCoo.

  • FGOODPIX: Fraction of good pixels in each spectrum.

  • MINEQMAX: Flag that min(flux) = max(flux) in the spectrum; i.e., the spaxel has no data.

  • SIGNAL, VARIANCE, SNR : Per pixel means of the flux, flux variance, and signal-to-noise. The VARIANCE and SNR columns use the inverse variance provided by the DRP. See mangadap.datacube.datacube.DataCube.flux_stats().

Parameters
  • cube (mangadap.datacube.datacube.DataCube) – Datacube to analyze.

  • pa (float, optional) – On-sky position angle of the major axis used to calculate elliptical, semi-major-axis coordinates, defined as the angle from North through East and denoted \(\phi_0\).

  • ell (float, optional) – Ellipticity defined as \(\varepsilon=1-b/a\), based on the semi-minor to semi-major axis ratio (\(b/a\)) of the isophotal ellipse used to calculate elliptical, semi-major-axis coordinates.

  • method_list (list, optional) – List of ReductionAssessmentDef objects that define the parameters required to perform the assessments of the DRP file. The method_key must select one of these objects. Default is to construct the list using available_reduction_assessments().

  • dapver (str, optional) – DAP version, which is used to define the default DAP analysis path. (This does not define the version of the code to use.) Default is defined by mangadap.config.defaults.dap_version()

  • analysis_path (str, optional) – The path to the top-level directory for the DAP output files for a given DRP and DAP version. Default is defined by mangadap.config.defaults.dap_analysis_path().

  • directory_path (str, optional) – The exact path for the output file. Default is defined by mangadap.config.defaults.dap_common_path().

  • output_file (str, optional) – The name of the file for the computed assessments. The full path of the output file will be directory_path/output_file. Default is defined by mangadap.config.defaults.dap_file_name().

  • hardcopy (bool, optional) – Flag to write the data to a fits file.

  • symlink_dir (str, optional) – Create a symlink to the file in this directory.

  • clobber (bool, optional) – If the output file already exists, this will force the assessments to be redone and the output file to be overwritten.

  • loggers (list, optional) – List of logging.Logger objects to log progress; ignored if quiet=True. Logging is done using mangadap.util.log.log_output(). Default is no logging.

  • quiet (bool, optional) – Suppress terminal and logging output.

Raises
static default_paths(plate, ifudesign, method_key, directory_path=None, drpver=None, dapver=None, analysis_path=None, output_file=None)[source]

Set the default directory and file name for the output file.

Parameters
Returns

Returns two str objects with the path for the output file and the name of the output file.

Return type

tuple

file_name()[source]

Return the name of the output file.

file_path()[source]

Return the full path to the output file.

info()[source]
class mangadap.proc.reductionassessments.ReductionAssessmentDef(key=None, waverange=None, response_func=None, covariance=False)[source]

Bases: mangadap.par.parset.KeywordParSet

Define how to assess the reduced data.

At the moment this is just a set of parameters that define how the S/N is calculated.

See mangadap.par.parset.ParSet for attributes.

Todo

  • Allow for different ways of calculating covariance?

The defined parameters are:

Key

Type

Options

Default

Description

key

str

Keyword to distinguish the assessment method.

waverange

ndarray, list

A two-element vector with the starting and ending wavelength (angstroms in vacuum) within which to calculate the signal-to-noise

response_func

ndarray, list

A two-column array with a response function to use for the S/N calculation. The columns must br the wavelength and amplitude of the response function, respectively.

covariance

bool

Provide the fiducial spatial covariance. If this is False, no spatial covariance will be available for calculations that use the results of the reduction assessments. If True and a covariance matrix is available directly from the datacube, it will be used. If True and the datacube does not already provide a computed covariance matrix, one is calculated using mangadap.datacube.datacube.DataCube.covariance_matrix() method. WARNING: If the latter fails either, the DAP will issue a warning and continue assuming no spatial covariance.

mangadap.proc.reductionassessments.available_reduction_assessments()[source]

Return the list of available reduction assessment methods. To get a list of default methods provided by the DAP do:

from mangadap.proc.reductionassessments import available_reduction_assessments
rdx_methods = available_reduction_assessments()
print(rdx_methods)

Each element in the rdx_methods list is an instance of ReductionAssessmentDef, which is printed using the ParSet base class representation function.

New methods can be included by adding ini config files to $MANGADAP_DIR/mangadap/config/reduction_assessments. See an example file at $MANGADAP_DIR/example_ini/example_reduction_assessment_config.ini.

Returns

A list of ReductionAssessmentDef objects, each defining a separate assessment method.

Return type

list

Raises
  • IOError – Raised if no reduction assessment configuration files could be found.

  • KeyError – Raised if the assessment method keywords are not all unique.

  • ValueError – Raised if a wavelength range or a response function are not defined by any of the methods.

mangadap.proc.reductionassessments.validate_reduction_assessment_config(cnfg)[source]

Validate the mangadap.util.parser.DefaultConfig object that provides the reduction-assessment method parameters.

Parameters

cnfg (mangadap.util.parser.DefaultConfig) – Object with the reduction-assessment method parameters needed by mangadap.proc.reductionassessments.ReductionAssessmentDef.

Returns

Booleans that specify how the reduction assessment should be constructed. The flags specify to use (1) the wavelength range, (2) a bandpass filter parameter file, or (3) a file with a filter response function.

Return type

bool

Raises
  • KeyError – Raised if required keyword does not exist.

  • ValueError – Raised if keys have unacceptable values.

  • FileNotFoundError – Raised if a file is specified but could not be found.