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.


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.