How to use the extinction.ccm89 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 iancze / Starfish / Starfish / transforms.py View on Github external
Extincts a given spectra according to the given law. Uses the ``extinction``
    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