How to use the extinction.odonnell94 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 guillochon / MOSFiT / mosfit / modules / seds / losextinction.py View on Github external
self._frequencies = kwargs['all_frequencies']
        self._band_rest_wavelengths = self._sample_wavelengths / zp1

        av_host = self._nh_host / 1.8e21

        extinct_cache = OrderedDict()
        for si, cur_band in enumerate(self._bands):
            bi = self._band_indices[si]
            # Extinct out host gal (using rest wavelengths)
            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
github guillochon / MOSFiT / mosfit / modules / seds / losextinction.py View on Github external
self._ebv = kwargs[self.key('ebv')]
        self._av_mw = self.MW_RV * self._ebv
        self._nh_mw = self._av_mw * 1.8e21
        # Pre-calculate LOS dust from MW for all bands
        self._mw_extinct = np.zeros_like(self._sample_wavelengths)
        self._ext_indices = []
        self._x_indices = []
        add_refs = set()
        for si, sw in enumerate(self._sample_wavelengths):
            self._ext_indices.append(
                self._sample_wavelengths[si] >= self.LYMAN)
            self._x_indices.append(
                (self._sample_wavelengths[si] >= self._min_wavelength) &
                (self._sample_wavelengths[si] < self.LYMAN))
            if len(self._ext_indices[si]) > 0:
                self._mw_extinct[si][self._ext_indices[si]] = odonnell94(
                    self._sample_wavelengths[si][self._ext_indices[si]],
                    self._av_mw, self.MW_RV)
                add_refs.add('1')
            if len(self._x_indices[si]) > 0:
                self._mw_extinct[si][self._x_indices[si]] = self.mm83(
                    self._nh_mw,
                    self._sample_wavelengths[si][self._x_indices[si]])
                add_refs.add('2')
        for ref in list(add_refs):
            self._REFERENCES.extend(self._ref_table[ref])
        self._preprocessed = True
github iancze / Starfish / Starfish / transforms.py View on Github external
package under the hood

    :param law: the extinction law, one of {'ccm89', 'odonnell94', 'calzetti00',
        'fitzpatrick99', 'fm07'}
    :type law: str
    :param Av: The scaling total extinction value.
    :type Av: float
    :param Rv: The ratio of total to selective extinction. If using law 'fm07' you do
        not need to provide this (fixed 3.1).
    :type Rv: float

    :raises ValueError: If not using an expected law or ill-specifying Av or Rv
    """
    LAWS = {
        'ccm89': extinction.ccm89,
        'odonnell94': extinction.odonnell94,
        'calzetti00': extinction.calzetti00,
        'fitzpatrick99': extinction.fitzpatrick99,
        'fm07': extinction.fm07,
    }
    def __init__(self, law, Av, Rv=None):
        if not law in self.LAWS:
            raise ValueError('Need to specify a law from {}'.format(self.LAWS.keys()))
        if Av < 0:
            raise ValueError('Cannot have negative extinction')
        if Rv is None or Rv < 0 and law is not 'fm07':
            raise ValueError('Must provide positive r_v for law "{}"'.format(law))
        elif law is 'fm07':
            Rv = None
        self.law = self.LAWS[law]
        self.Av = Av
        self.Rv = Rv