mangadap.util.drpfits module

Defines a class used to interface with files produced in the 3D phase of the MaNGA Data Reduction Pipeline (DRP).

Todo

  • Calculation in DRPFits._cube_dimensions() will only be correct if the WCS coordinates have no rotation.

  • Further optimize calculation of transfer matrix

  • Make DRP file class flexible to linear or log-linear wavelength sampling? Incorporate into MODE?

  • Reconstructed broad-band images and PSFs are not restructured in the CUBE files! This is why the are transposed in mangadap.drpfits.DRPFits.gri_composite().

  • Image reconstruction has transpose sense wrt DRP output!

  • Add logging

  • Need to be clear about which functions use the RSS spectra to create CUBE related data, like the covariance matrix and instrumental dispersion calculations.

  • Computing the approximate covariance cube is currently not possible with only the CUBE on disk. There’s a logic problem that needs to be fixed.

Revision history

20 Nov 2014: Original implementation by K. Westfall (KBW)
12 Feb 2014: (KBW) Added DRPFits.directory_path()
20 Feb 2015: (KBW) Add covariance calculation to DRPFits
19 Mar 2015: (KBW) Added redux_path to DRPFits. Re-arranged arguments in drpfits_list(), made drpver optional, and added redux_path
22 May 2015: (KBW) Sphinx documentation. Changed DRPFits.w to DRPFits.wcs.
26 May 2015: (KBW) Added checksum=True when opening the DRP file.
04 Jun 2015: (KBW) Moved parse_drp_file_name to mangadap.util.parser.parse_drp_file_name()
15 Jun 2015: (KBW) Moved functions that return default values (like DRPFits._default_pixelscale()) to mangadap.config.defaults
05 Aug 2015: (KBW) Changed mode testing to be more robust. Added directory_path keyword to drpfits_list(). Changed how directory path is set; previously required drpver and redux_path defaults, even if directory_path was provided directly. May need to add checks to other code to make sure drpver and redux_path are not None when directory_path has been directly defined.
28 Aug 2015: (KBW) Added usage of mangadap.config.defaults.manga_fits_root()
15 Feb 2016: (KBW) Added DRPFits.__getitem__() function
17 Feb 2016: (KBW) Converted drpfile class name to DRPFits
23 Mar 2016: (KBW) Added functionality that abstracts the difference between the RSS and CUBE file formats at the user level. CUBE files are now restructured to matched the intended orientation provided by the DRP; i.e., [x,y,lambda]. RSS files are left the same, which is [fiber, lambda]. Documentation. Testing, particularly of x,y order.
10 Nov 2016: (KBW) Included ‘DISP’ in spectral arrays.
30 Nov 2016: (KBW) Include DRPFits.spectral_resolution(), which returns spectral resolution cube or vector independent of MPL
01 Dec 2016: (KBW) Added DRPFits.spectral_resolution_header().
06 Dec 2016: (KBW) Removed wavelength_mask function, now uses mangadap.util.pixelmask.SpectralPixelMask. Moved the main functionality of DRPFits.copy_to_array() and DRPFits.copy_to_masked_array() to mangadap.util.fitsutil.DAPFitsUtil, what’s left are wrapper functions for the more general functions in mangadap.util.fitsutil.DAPFitsUtil.
17 Feb 2017: (KBW) Return nominal inverse variance in DRPFits.regrid_wavelength_plane() if requested.
17 May 2017: (KBW) Include a response function in DRPFits.flux_stats() and DAPFits.mean_sky_coordinates().
21 Aug 2017: (KBW) In spectral resolution function, select pre- vs. post-pixelized Gaussian respresentation.

License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


class mangadap.util.drpfits.DRPFits(plate, ifudesign, mode, log=True, drpver=None, redux_path=None, directory_path=None)[source]

Bases: object

Provides methods common to both mangadap.datacube.manga.MaNGADataCube and mangadap.spectra.manga.MaNGARSS, and not general enough for mangadap.datacube.datacube.DataCube and mangadap.spectra.rowstackedspectra.RowStackedSpectra.

static build_file_name(plate, ifudesign, mode, log=True)[source]

Return the name of the DRP row-stacked spectra file.

Parameters
  • plate (int) – Plate number

  • ifudesign (int) – IFU design

  • mode (str) – Format mode (CUBE or RSS)

  • log (bool, optional) – Use the spectra that are logarithmically sampled in wavelength. If False, sampling is linear in wavelength.

Returns

The relevant file name.

Return type

str

static check_mode(mode)[source]

Check that the mode is valid.

Valide modes are set by mode_options().

Parameters

mode (str) – Mode value to check.

Raises

ValueError – Raised if the mode is undefined.

static default_paths(plate, ifudesign, mode, log=True, drpver=None, redux_path=None, directory_path=None)[source]

Return the primary directory and file name with the DRP fits LOG-binned file.

Parameters
  • plate (int) – Plate number

  • ifudesign (int) – IFU design

  • mode (str) – Format mode (CUBE or RSS)

  • log (bool, optional) – Use the spectra that are logarithmically sampled in wavelength. If False, sampling is linear in wavelength.

  • drpver (str, optional) – DRP version, which is used to define the default DRP redux path. Default is defined by mangadap.config.defaults.drp_version()

  • redux_path (str, optional) – The path to the top level directory containing the DRP output files for a given DRP version. Default is defined by mangadap.config.defaults.drp_redux_path().

  • directory_path (str, optional) – The exact path to the DRP file. Default is defined by mangadap.config.defaults.drp_directory_path(). Providing this ignores anything provided for drpver or redux_path.

Returns

Two strings with the default path to and name of the DRP data file.

Return type

tuple

static do_not_fit_flags()[source]

Return the maskbit names that should not be fit.

static do_not_stack_flags()[source]

Return the maskbit names that should not be stacked.

static do_not_use_flags()[source]

Return the maskbit names that should not be used.

file_path()[source]

Return the full path to the DRP file

finding_chart_path()[source]

Return the full path to the PNG finding chart for the targetted object.

Todo

  • Move this to the defaults file?

classmethod from_config(cfgfile, drpver=None, redux_path=None, directory_path=None)[source]

Construct a mangadap.datacube.manga.MaNGADataCube or mangadap.spectra.manga.MaNGARSS object from a configuration file.

Using the data read from the configuration file, the method instantiates the class using mangadap.spectra.manga.MaNGARSS.from_plateifu() or mangadap.datacube.manga.MaNGADataCube.from_plateifu(). This method will therefore fault for this base class!

The format of the configuration file is:

Todo

Fill this in.

Parameters
  • cfgfile (str) – Configuration file

  • drpver (str, optional) – DRP version, which is used to define the default DRP redux path. Overrides any value in the configuration file.

  • redux_path (str, optional) – The path to the top level directory containing the DRP output files for a given DRP version. Overrides any value in the configuration file.

  • directory_path (str, optional) – The exact path to the DRP file. Providing this ignores anything provided for drpver or redux_path. Overrides any value in the configuration file.

static mode_options()[source]

Return the allowed modes.

Returns

List of the allowed DRP fits file modes.

Return type

list

static sampling_options()[source]

Return the allowed wavelength sampling modes.

Returns

List of the allowed DRP fits wavelength sampling modes.

Return type

list

static spectral_resolution(hdu, ext=None, fill=False, median=False)[source]

Return the spectral resolution for all spectra.

See spectral_resolution_extension() for a description of the precedence used when ext is None.

Parameters
  • hdu (astropy.io.fits.HDUList) – The opened MaNGA DRP file.

  • ext (str, optional) – Specify the extension with the spectral estimate to use. See spectral_resolution_extension().

  • fill (bool, optional) – Fill masked values by interpolation. Default is to leave masked pixels in returned array.

  • median (bool, optional) – Return a single vector with the median spectral resolution instead of a per spectrum array. When using the SPECRES extension, this just returns the vector provided by the DRP file; when using either of the LSF extensions, this performs a masked median across the array and then interpolates any wavelengths that were masked in all vectors.

Returns

Returns a str with the name of the extension used for the spectral-resolution measurements and a numpy.ma.MaskedArray with the spectral resolution data. Even if interpolated such that there should be no masked values, the function returns a masked array. Array contains the spectral resolution (\(R = \lambda/\Delta\lambda\)) pulled from the DRP file.

Return type

tuple

static spectral_resolution_extension(hdu, ext=None)[source]

Determine the spectral resolution channel to use.

Precedence follows this order: LSFPRE, PRESPECRES, LSFPOST, SPECRES.

Parameters
  • hdu (astropy.io.fits.HDUList) – The opened MaNGA DRP file.

  • ext (str, optional) – Specify the extension with the spectral estimate to use. Should be in None, LSFPRE, PRESPECRES, LSFPOST, or SPECRES. The default is None, which means it will return the extension found first in the order above. None is returned if none of the extensions are present.

Returns

The name of the preferred extension to use.

Return type

str

static write_config(ofile, plate, ifudesign, log=True, z=None, vdisp=None, ell=None, pa=None, reff=None, sres_ext=None, sres_fill=None, covar_ext=None, drpver=None, redux_path=None, directory_path=None, overwrite=True)[source]

Write the configuration file that can be used to instantiate a MaNGA data object (mangadap.datacube.manga.MaNGADataCube or mangadap.spectra.manga.MaNGARSS).

See from_config().

Parameters
  • ofile (str, optional) – Name of the configuration file.

  • plate (int) – Plate number

  • ifudesign (int) – IFU design

  • log (bool, optional) – Use the datacube that is logarithmically binned in wavelength.

  • z (float, optional) – Estimated bulk redshift. If None, some of the DAP analysis modules will fault.

  • vdisp (float, optional) – Estimated velocity dispersion. If None, some of the DAP analysis modules will assume an initial guess of 100 km/s.

  • ell (float, optional) – Characteristic isophotal ellipticity (1-b/a). If None, some of the DAP modules will issue a warning and continue by assuming ell=0.

  • pa (float, optional) – Characteristic isophotal position angle (through E from N). If None, some of the DAP modules will issue a warning and continue by assuming pa=0.

  • reff (float, optional) – Effective (half-light) radius in arcsec. If None, some of the DAP modules will issue a warning and continue by assuming reff=1.

  • sres_ext (str, optional) – The extension to use when constructing the spectral resolution vectors. See spectral_resolution().

  • sres_fill (bool, optional) – Fill masked values by interpolation. Default is to leave masked pixels in returned array.

  • covar_ext (str, optional) – Extension to use as the single spatial correlation matrix for all wavelength channels, read from the DRP file. For generating the covariance matrix directly for an arbitrary wavelength channel using the RSS file, see mangadap.datacube.datacube.DataCube.covariance_matrix().

  • drpver (str, optional) – DRP version, which is used to define the default DRP redux path. Default is defined by mangadap.config.defaults.drp_version()

  • redux_path (str, optional) – The path to the top level directory containing the DRP output files for a given DRP version. Default is defined by mangadap.config.defaults.drp_redux_path().

  • directory_path (str, optional) – The exact path to the DRP file. Default is defined by mangadap.config.defaults.drp_directory_path(). Providing this ignores anything provided for drpver or redux_path.

  • overwrite (bool, optional) – Overwrite any existing parameter file.

class mangadap.util.drpfits.DRPFitsBitMask(sdss_maskbits=None, mode='CUBE')[source]

Bases: mangadap.util.bitmask.BitMask

Structure with the DRP mask bits.

The defined bits are listed at MANGA_DRP3PIXMASK.

class mangadap.util.drpfits.DRPQuality3DBitMask(sdss_maskbits=None)[source]

Bases: mangadap.util.bitmask.BitMask

Structure with the definition of the DRP3QUAL mask bits.

The defined bits are listed at MANGA_DRP3QUAL.