Example #1
0
def datacube():
    """Produces a simple 3D array for datacube testing."""

    flux = numpy.tile([numpy.arange(1, 1001, dtype=numpy.float32)],
                      (100, 1)).T.reshape(1000, 10, 10)
    ivar = (1. / (flux / 100))**2
    mask = numpy.zeros(flux.shape, dtype=numpy.int)
    wave = numpy.arange(1, 1001)

    redcorr = numpy.ones(1000) * 1.5

    mask[50:100, 5, 5] = 2**10
    mask[500:600, 3, 3] = 2**4

    scale = 1e-3

    datacube = DataCube(flux,
                        wave,
                        ivar=ivar,
                        mask=mask,
                        redcorr=redcorr,
                        scale=scale,
                        unit=u.erg / u.s / (u.cm**2) / u.Angstrom /
                        spaxel_unit,
                        pixmask_flag='MANGA_DRP3PIXMASK')

    yield datacube
Example #2
0
    def emline_fit(self):
        """Returns the emission line fit."""

        model = self.datamodel['emline_fit']

        emline_array = self._get_extension_data('emline_fit')
        emline_mask = self._get_extension_data('emline_fit', 'mask')

        return DataCube(emline_array,
                        np.array(self._wavelength),
                        ivar=None,
                        mask=emline_mask,
                        redcorr=self._redcorr,
                        binid=self.get_binid(model),
                        unit=model.unit)
Example #3
0
    def full_fit(self):
        """Returns the full fit datacube."""

        model = self.datamodel['full_fit']

        model_array = self._get_extension_data('full_fit')
        model_mask = self._get_extension_data('flux', 'mask')

        return DataCube(model_array,
                        np.array(self._wavelength),
                        ivar=None,
                        mask=model_mask,
                        redcorr=self._redcorr,
                        binid=self.get_binid(model),
                        unit=model.unit)
Example #4
0
    def binned_flux(self):
        """Returns the binned flux datacube."""

        model = self.datamodel['binned_flux']

        binned_flux_array = self._get_extension_data('flux')
        binned_flux_ivar = self._get_extension_data('flux', 'ivar')
        binned_flux_mask = self._get_extension_data('flux', 'mask')

        return DataCube(binned_flux_array,
                        np.array(self._wavelength),
                        ivar=binned_flux_ivar,
                        mask=binned_flux_mask,
                        redcorr=self._redcorr,
                        binid=self.get_binid(model),
                        unit=model.unit)
Example #5
0
    def _get_datacube(self, name):
        """Returns a `.DataCube`."""

        model = self.datamodel.datacubes[name]
        cube_data = self._get_extension_data(name)

        if cube_data is None:
            raise MarvinError('cannot find data for this extension. '
                              'Maybe it is not loaded into the DB.')

        datacube = DataCube(cube_data,
                            np.array(self._wavelength),
                            ivar=self._get_extension_data(name, 'ivar'),
                            mask=self._get_extension_data(name, 'mask'),
                            unit=model.unit, pixmask_flag=model.pixmask_flag)

        return datacube
Example #6
0
    def stellarcont_fit(self):
        """Returns the stellar continuum fit."""

        array = (self._get_extension_data('full_fit') -
                 self._get_extension_data('emline_fit') -
                 self._get_extension_data('emline_base_fit'))

        model = self.datamodel['full_fit']

        stellarcont_mask = self._get_extension_data('flux', 'mask')

        return DataCube(array,
                        np.array(self._wavelength),
                        ivar=None,
                        mask=stellarcont_mask,
                        redcorr=self._redcorr,
                        binid=self.get_binid(model),
                        unit=model.unit)
Example #7
0
    def stellarcont_fit(self):
        """Returns the stellar continuum fit."""

        isMPL8 = check_versions(self._dapver, datamodel['MPL-8'].release)

        if isMPL8:
            array = self._get_extension_data('stellar_fit')
            model = self.datamodel['stellar_fit']
            mask = self._get_extension_data('stellar_fit', 'mask')
        else:
            array = (self._get_extension_data('full_fit') -
                     self._get_extension_data('emline_fit') -
                     self._get_extension_data('emline_base_fit'))
            model = self.datamodel['full_fit']
            mask = self._get_extension_data('flux', 'mask')

        return DataCube(array,
                        np.array(self._wavelength),
                        ivar=None,
                        mask=mask,
                        redcorr=self._redcorr,
                        binid=self.get_binid(model),
                        unit=model.unit,
                        pixmask_flag=model.pixmask_flag)