How to use the extinction.apply function in extinction

To help you get started, we’ve selected a few extinction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daniel-muthukrishna / astrorapid / astrorapid / ANTARES_object / LAobject.py View on Github external
if self.mwebv:
            extinctions = extinction.fitzpatrick99(wave=self._good_filter_wave, \
                                                   a_v=-3.1 * self.mwebv, r_v=3.1, unit='aa')

        for i, pb in enumerate(self._good_filters):
            mask = (self.passband == pb)

            flux_pb = self.flux[mask]
            fluxerr_pb = self.fluxErr[mask]
            npbobs = len(flux_pb)

            if npbobs < 1:
                return

            if self.mwebv:
                flux_out = extinction.apply(extinctions[i], flux_pb, inplace=False)
                fluxerr_out = extinction.apply(extinctions[i], fluxerr_pb, inplace=False)
            else:
                flux_out = flux_pb
                fluxerr_out = fluxerr_pb
                self.fluxUnred[mask] = flux_out
                self.fluxErrUnred[mask] = fluxerr_out

            if npbobs > 1:
                # there's at least enough observations to find minimum and maximum
                minfluxpb = flux_out.min()
                maxfluxpb = flux_out.max()
                norm = maxfluxpb - minfluxpb
                self.fluxRenorm[mask] = (flux_out - minfluxpb) / norm
                self.fluxErrRenorm[mask] = fluxerr_out / norm
            elif npbobs == 1:
                # deal with the case with one observation in this passband by setting renorm = 0.5
github daniel-muthukrishna / astrorapid / astrorapid / ANTARES_object / LAobject.py View on Github external
extinctions = extinction.fitzpatrick99(wave=self._good_filter_wave, \
                                                   a_v=-3.1 * self.mwebv, r_v=3.1, unit='aa')

        for i, pb in enumerate(self._good_filters):
            mask = (self.passband == pb)

            flux_pb = self.flux[mask]
            fluxerr_pb = self.fluxErr[mask]
            npbobs = len(flux_pb)

            if npbobs < 1:
                return

            if self.mwebv:
                flux_out = extinction.apply(extinctions[i], flux_pb, inplace=False)
                fluxerr_out = extinction.apply(extinctions[i], fluxerr_pb, inplace=False)
            else:
                flux_out = flux_pb
                fluxerr_out = fluxerr_pb
                self.fluxUnred[mask] = flux_out
                self.fluxErrUnred[mask] = fluxerr_out

            if npbobs > 1:
                # there's at least enough observations to find minimum and maximum
                minfluxpb = flux_out.min()
                maxfluxpb = flux_out.max()
                norm = maxfluxpb - minfluxpb
                self.fluxRenorm[mask] = (flux_out - minfluxpb) / norm
                self.fluxErrRenorm[mask] = fluxerr_out / norm
            elif npbobs == 1:
                # deal with the case with one observation in this passband by setting renorm = 0.5
                norm = self.fluxUnred[mask] / 0.5
github iancze / Starfish / Starfish / transforms.py View on Github external
def transform(self, wave, flux):
        if self.Rv is not None:
            extinct_mag = self.law(wave, self.Av, self.Rv)
        else:
            extinct_mag = self.law(wave, self.Av)
        extinct_flux = extinction.apply(extinct_mag, flux)
        return wave, extinct_flux
github guillochon / MOSFiT / mosfit / modules / seds / losextinction.py View on Github external
if bi >= 0:
                if bi not in extinct_cache:
                    extinct_cache[bi] = np.zeros_like(
                        self._band_rest_wavelengths[bi])
                    ind = self._ext_indices[bi]
                    if len(ind) > 0:
                        extinct_cache[bi][ind] = odonnell94(
                            self._band_rest_wavelengths[bi][ind],
                            av_host, self._rv_host)
                    ind = self._x_indices[bi]
                    if len(ind) > 0:
                        extinct_cache[bi][ind] = self.mm83(
                            self._nh_host,
                            self._band_rest_wavelengths[bi][ind])
                # Add host and MW contributions
                eapp(
                    self._mw_extinct[bi] + extinct_cache[bi],
                    self._seds[si], inplace=True)
            else:
                # wavelengths = np.array(
                #   [c.c.cgs.value / self._frequencies[si]])
                # Need extinction function for radio
                pass

        # Units of `seds` is ergs / s / Angstrom.
        return {
            'sample_wavelengths': self._sample_wavelengths,
            self.key('seds'): self._seds,
            self.key('avhost'): av_host
        }