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.
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 ofReductionAssessmentDef
objects that define the parameters required to perform the assessments of the DRP file. Themethod_key
must select one of these objects. Default is to construct the list usingavailable_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 bymangadap.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 bymangadap.config.defaults.dap_analysis_path()
.directory_path (
str
, optional) – The exact path for the output file. Default is defined bymangadap.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 bedirectory_path
/output_file
. Default is defined bymangadap.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 usingmangadap.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.
- cube¶
Datacube to analyze.
- 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
- symlink_dir¶
Create a symlink to the file in this directory.
- Type
str
- hdu¶
HDUList with the data, with columns as described above.
- correlation¶
If requested, provides the spatial correlation matrix for the flux at a fiducial wavelength in the datacube. See
covar_wave
andcovar_channel
.
- 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 fromcube
.- 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 fromcube
.- 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
; seemangadap.proc.util.select_proc_method()
.- Parameters
method_key (
str
) – Keyword of the selected method. Available methods are provided byavailable_reduction_assessments()
method_list (
list
, optional) – List ofReductionAssessmentDef
objects that define the parameters required to assess the reduced data.
- _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 usingmangadap.util.fitsutil.DAPFitsUtil.clean_dap_primary_header()
.- Returns
Initialized header object.
- Return type
- _set_paths(directory_path, dapver, analysis_path, output_file)[source]¶
Set the I/O paths.
Used to set
directory_path
andoutput_file
. If not provided, the defaults are set using, respectively,mangadap.config.defaults.dap_common_path()
andmangadap.config.defaults.dap_file_name()
.- Parameters
directory_path (
str
) – The exact path to the DAP reduction assessments file. Seedirectory_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. Seecompute()
.
- 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; seeReductionAssessmentDataTable
.CORREL
: The correlation matrix between theSIGNAL
measurements provided in theSPECTRUM
extension. The format of this extension is identical to the nominal output of themangadap.util.covariance.Covariance
object; seemangadap.util.covariance.Covariance.write()
.
- 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 ofReductionAssessmentDef
objects that define the parameters required to perform the assessments of the DRP file. Themethod_key
must select one of these objects. Default is to construct the list usingavailable_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 bymangadap.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 bymangadap.config.defaults.dap_analysis_path()
.directory_path (
str
, optional) – The exact path for the output file. Default is defined bymangadap.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 bedirectory_path
/output_file
. Default is defined bymangadap.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 usingmangadap.util.log.log_output()
. Default is no logging.quiet (
bool
, optional) – Suppress terminal and logging output.
- Raises
TypeError – Raised if the provided
cube
is not amangadap.datacube.datacube.DataCube
.ValueError – Raised if the output path cannot be defined.
- 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
plate (
int
) – Plate numberifudesign (
int
) – IFU design numbermethod_key (
str
) – Keyword designating the method used for the reduction assessments.directory_path (
str
, optional) – The exact path to the DAP reduction assessments file. Default set bymangadap.config.defaults.dap_common_path()
.drpver (
str
, optional) – DRP version. Default set bymangadap.config.defaults.drp_version()
.dapver (
str
, optional) – DAP version. Default set bymangadap.config.defaults.dap_version()
.analysis_path (
str
, optional) – The path to the top-level directory containing the DAP output files for a given DRP and DAP version. Default set bymangadap.config.defaults.dap_analysis_path()
.output_file (
str
, optional) – The name of the file with the reduction assessments. Default set bymangadap.config.defaults.dap_file_name()
.
- Returns
Returns two
str
objects with the path for the output file and the name of the output file.- Return type
tuple
- class mangadap.proc.reductionassessments.ReductionAssessmentDataTable(shape=None)[source]¶
Bases:
mangadap.util.datatable.DataTable
Primary data table with the reduction assessments.
The data table includes:
Key
Type
Description
SPAT_INDX
int64
The 2D spatial array indices associated with each measurement. See
spatial_index
.SKY_COO
float64
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
float64
Elliptical (semi-major axis) radius and azimuth angle from N through E with respect to the photometric position angle; based on the provided ellipticity parameters. See
mangadap.util.geometry.SemiMajorAxisCoo
.FGOODPIX
float64
Fraction of good pixels in each spectrum.
SIGNAL
float64
Per pixel mean flux
VARIANCE
float64
Per pixel mean variance
SNR
float64
Per pixel mean S/N
- Parameters
shape (
int
,tuple
, optional) – The shape of the initial array. If None, the data array will not be instantiated; useinit()
to initialize the data array after instantiation.
- class mangadap.proc.reductionassessments.ReductionAssessmentDef(key=None, waverange=None, response_func=None, covariance=False, minimum_frac=0.8)[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.minimum_frac
int, float
Minimum fraction of unmasked pixels in a spectrum required for inclusion in the spatial covariance calculation. Note this should match the value used for the spatial-binning module.
- 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 theParSet
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 bymangadap.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.