mangadap.dapfits module

Defines a class used to interface with the final maps files produced by the MaNGA Data Analysis Pipeline (DAP).

Todo

  • Allow DAPFits to read/access both the MAPS and the LOGCUBE files, not just the former.


License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


class mangadap.dapfits.DAPCubeBitMask[source]

Bases: DAPBitMask

Class used to flag/interpret bits in DAP model LOGCUBE files.

The defined bits are listed at MANGA_DAPSPECMASK.

Todo

  • Force read IDLUTILS version as opposed to internal one?

cfg_root = 'dap_cube_bits'
class mangadap.dapfits.DAPMapsBitMask[source]

Bases: DAPBitMask

Class used to flag/interpret bits in DAP MAPS files.

The defined bits are listed at MANGA_DAPPIXMASK.

Todo

  • Force read IDLUTILS version as opposed to internal one?

cfg_root = 'dap_maps_bits'
class mangadap.dapfits.DAPQualityBitMask[source]

Bases: DAPBitMask

Class used to flag/interpret global quality bit.

The defined bits are listed at MANGA_DAPQUAL.

Todo

  • Force read IDLUTILS version as opposed to internal one?

cfg_root = 'dap_quality_bits'
mangadap.dapfits.add_snr_metrics_to_header(hdr, cube, r_re)[source]

For all valid spaxels within 1 Re < R < 1.5 Re calculate the median S/N and combined S/N (including covariance) in the griz bands.

Adds the following keywords (8) to the header:
  • SNR?MED: Median S/N within 1-1.5 Re in each of the griz bands.

  • SNR?RING: The combined S/N of all spaxels within 1-1.5 Re in the griz bands, incuding covariance

The inclusion of covariance is based on the exact calculation of the correlation matrix at the flux-weighted center of each band, and assuming no change in the correlation between the response-weighted correlation within the broad band.

Parameters:
Returns:

The edited header object.

Return type:

astropy.io.fits.Header

Raises:

FileNotFoundError – Raised if any of the response function files cannot be found.

mangadap.dapfits.combine_binid_extensions(cube, binned_spectra, stellar_continuum, emission_line_moments, emission_line_model, spectral_indices, dtype=None)[source]

Combine the bin IDs from the different analysis steps into a single multichannel extension.

mangadap.dapfits.confirm_dap_types(cube, rdxqa, binned_spectra, stellar_continuum, emission_line_moments, emission_line_model, spectral_indices)[source]
class mangadap.dapfits.construct_cube_file(cube, method=None, rdxqa=None, binned_spectra=None, stellar_continuum=None, emission_line_moments=None, emission_line_model=None, spectral_indices=None, output_path=None, output_file=None, overwrite=True, loggers=None, quiet=False, single_precision=False)[source]

Bases: object

Construct a DAP cube file based on the input data.

Set as a class for coherency reasons, but should not be used as an object!

Should force all intermediate objects to be provided.

_get_data_mask(binned_spectra, binned_spectra_3d_hdu)[source]
For the binned spectra:
  • consolidate ANY flag except NO_STDDEV from binned_spectra into IGNORED; done use SpatiallyBinnedSpectra.do_not_fit_flags

  • propagate NONE_IN_STACK from binned_spectra into FLUXINVALID

  • propagate IVARINVALID and FORESTAR

_get_emission_line_model_mask(emission_line_model, emission_line_model_3d_hdu)[source]
For the emission-line models:
  • propagate FORESTAR

  • propagate ARTIFACT

  • consolidate DIDNOTUSE, FORESTAR, LOW_SNR, ARTIFACT, OUTSIDE_RANGE, TPL_PIXELS, TRUNCATED, PPXF_REJECT, INVALID_ERROR into FITIGNORED

_get_stellar_continuum_mask(stellar_continuum, stellar_continuum_3d_hdu)[source]
For the stellar continuum models:
  • propagate FORESTAR

  • propagate INVALID_ERROR into IVARINVALID

  • propagate ARTIFACTs

  • consolidate DIDNOTUSE, FORESTAR, LOW_SNR, ARTIFACT, OUTSIDE_RANGE, EML_REGION, TPL_PIXELS, TRUNCATED, PPXF_REJECT, INVALID_ERROR, NO_FIT into FITIGNORED

  • consolidate FIT_FAILED into FITFAILED

_include_no_model_mask(mask)[source]

Assign the NOMODEL bit to spectral regions outside of the fitted spectral range.

Modeled off of StellarContiuumModel.reset_continuum_mask_window.

_set_no_model(mask)[source]
binned_data_cube(prihdr, binned_spectra, binned_spectra_3d_hdu)[source]

Constructs the ‘FLUX’, ‘IVAR’, ‘MASK’, ‘LSF’, ‘WAVE’, and ‘REDCORR’ model cube extensions, and begins the construction of the ‘MASK’.

Returns the primary header, a list of ImageHDUs, and the mask array.

model_cubes(prihdr, binned_spectra, stellar_continuum, stellar_continuum_3d_hdu, emission_line_model, emission_line_model_3d_hdu)[source]

Constructs the ‘MODEL’, ‘MODEL_MASK’, ‘EMLINE’, ‘STELLAR’, and ‘STELLAR_MASK’ model cube extensions, adds the model information to the header, and appends data to the mask.

class mangadap.dapfits.construct_maps_file(cube, method=None, rdxqa=None, binned_spectra=None, stellar_continuum=None, emission_line_moments=None, emission_line_model=None, spectral_indices=None, redshift=None, output_path=None, output_file=None, overwrite=True, loggers=None, quiet=False, single_precision=False)[source]

Bases: object

Construct a DAP MAPS file.

Set as a class to enforce a namespace. Should not be used as an object!

Should force all intermediate objects to be provided.

_build_binning_mask(binned_spectra)[source]

Consolidate the map mask values into NOVALUE.

_consolidate_donotuse(mask)[source]
_emission_line_model_mask_to_map_mask(emission_line_model, elf_mask, for_dispersion=False)[source]

Propagate and consolidate the emission-line moment masks to the map pixel mask.

INSUFFICIENT_DATA propagated to NOVALUE

FIT_FAILED, UNDEFINED_COVAR propagated to FITFAILED

NEAR_BOUND copied to NEARBOUND

UNDEFINED_SIGMA propagated to UNRELIABLE

_emission_line_moment_mask_to_map_mask(emission_line_moments, elm_mask)[source]

Propagate and consolidate the emission-line moment masks to the map pixel mask.

DIDNOTUSE, FORESTAR propagated from already existing mask (self.bin_mask)

MAIN_EMPTY, BLUE_EMPTY, RED_EMPTY, UNDEFINED_BANDS propagated to NOVALUE

MAIN_JUMP, BLUE_JUMP, RED_JUMP, JUMP_BTWN_SIDEBANDS propagated to FITFAILED

MAIN_INCOMP, BLUE_INCOMP, RED_INCOMP propagated to UNRELIABLE

NO_ABSORPTION_CORRECTION propagated to NOCORRECTION

DIVBYZERO propagated to MATHERROR

Second moments not provided so no need to include UNDEFINED_MOM2

static _get_kpc_per_arcsec(z)[source]
static _join_maps(a)[source]
_spectral_index_mask_to_map_mask(spectral_indices, si_mask)[source]

Propagate and consolidate the spectral index masks to the map pixel mask.

DIDNOTUSE, FORESTAR propagated from already existing mask (self.bin_mask)

MAIN_EMPTY, BLUE_EMPTY, RED_EMPTY, UNDEFINED_BANDS propagated to NOVALUE

MAIN_INCOMP, BLUE_INCOMP, RED_INCOMP propagated to UNRELIABLE

NO_DISPERSION_CORRECTION propagated to NOCORRECTION

DIVBYZERO propagated to MATHERROR

Need to further assess *_INCOMP to see if these lead to bad values (BADVALUE).

_stellar_continuum_mask_to_map_mask(stellar_continuum, sc_mask, for_dispersion=False)[source]

sc_mask constains the reconstructed map of the masks in each stellar continuum fit (using the stellar continuum bitmask).

Propagate and consolidate the stellar-continuum masks to the map pixel mask.

DIDNOTUSE, FORESTAR propagated from already existing mask

(self.bin_mask)

LOW_SNR, NO_FIT, INSUFFICIENT_DATA propagated to NOVALUE

FIT_FAILED, NEAR_BOUND propagated to FITFAILED and NEARBOUND

NEGATIVE_WEIGHTS consolidated into UNRELIABLE; if

dispersion=True, include BAD_SIGMA in this

binned_spectra_maps(prihdr, binned_spectra)[source]

Constructs the ‘BIN_LWSKYCOO’, ‘BIN_LWELLCOO’, ‘BIN_AREA’, ‘BIN_FAREA’, ‘BIN_MFLUX’, ‘BIN_MFLUX_IVAR’, ‘BIN_MFLUX_MASK’, and ‘BIN_SNR’ map extensions.

emission_line_model_maps(prihdr, emission_line_model)[source]

Construct the ‘EMLINE_GFLUX’, ‘EMLINE_GFLUX_IVAR’, ‘EMLINE_GFLUX_MASK’, ‘EMLINE_GEW’, ‘EMLINE_GEW_CNT’, ‘EMLINE_GEW_IVAR’, ‘EMLINE_GEW_MASK’, ‘EMLINE_GVEL’, ‘EMLINE_GVEL_IVAR’, ‘EMLINE_GVEL_MASK’, ‘EMLINE_GSIGMA’, ‘EMLINE_GSIGMA_IVAR’, ‘EMLINE_GSIGMA_MASK’, ‘EMLINE_INSTSIGMA’, ‘EMLINE_TPLSIGMA’, ‘EMLINE_GA’, ‘EMLINE_GANR’, ‘EMLINE_FOM’, ‘EMLINE_LFOM’ map extensions.

emission_line_moment_maps(prihdr, emission_line_moments)[source]

Construct the ‘EMLINE_SFLUX’, ‘EMLINE_SFLUX_IVAR’, ‘EMLINE_SFLUX_MASK’, ‘EMLINE_SEW’, ‘EMLINE_SEW_IVAR’, and ‘EMLINE_SEW_MASK’ maps extensions.

reduction_assessment_maps(prihdr, rdxqa)[source]

Constructs the ‘SPX_SKYCOO’, ‘SPX_ELLCOO’, ‘SPX_MFLUX’, ‘SPX_MFLUX_IVAR’, and ‘SPX_SNR’ map extensions.

Todo

Add the spaxel correlation data.

spectral_index_maps(prihdr, spectral_indices)[source]

Construct the ‘SPECINDEX’, ‘SPECINDEX_IVAR’, ‘SPECINDEX_MASK’, and ‘SPECINDEX_CORR’.

stellar_continuum_maps(prihdr, stellar_continuum)[source]

Construct the ‘STELLAR_VEL’, ‘STELLAR_VEL_IVAR’, ‘STELLAR_VEL_MASK’, ‘STELLAR_SIGMA’, ‘STELLAR_SIGMA_IVAR’, ‘STELLAR_SIGMA_MASK’, ‘STELLAR_SIGMACORR’, ‘STELLAR_FOM’ maps extensions.

mangadap.dapfits.default_paths(cube, file_type='MAPS', rdxqa_method=None, binning_method=None, stelcont_method=None, elmom_method=None, elmodel_method=None, sindex_method=None, method=None, output_path=None, output_file=None)[source]

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

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

  • file_type (str, optional) – The DAP output file type. Should be ‘MAPS’ or ‘LOGCUBE’.

  • rdxqa_method (str, optional) – The method key for the basic assessments of the datacube.

  • binning_method (str, optional) – The method key for the spatial binning.

  • stelcont_method (str, optional) – The method key for the stellar-continuum fitting method. If None, not included in output file name.

  • elmom_method (str, optional) – The method key for the emission-line moments method. If None, not included in the output file name.

  • elmodel_method (str, optional) – The method key for the emission-line modeling method. If None, not included in the output file name.

  • sindex_method (str, optional) – The method key for the spectral index measurements. If None, not included in the output file name.

  • method (str, optional) – The method to use instead of the default. The default method is to simply concatenate the list of methods used by eadch module. The order of the keys is the order of operations (rdxqa, binning, stellar continuum, emission-line model, spectral indices).

  • output_path (str, Path, optional) – The path for the output file. If None, the current working directory is used.

  • output_file (str, optional) – The name of the output file. The full path of the output file will be directory_path/output_file. If None, the default is to combine cube.output_root and the method (see method).

Returns:

Returns a Path with the output directory and a str with the output file name.

Return type:

tuple

mangadap.dapfits.finalize_dap_primary_header(prihdr, cube, metadata, binned_spectra, stellar_continuum, loggers=None, quiet=False)[source]