How to use the extinction.MW_Cardelli89 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 nhmc / Barak / barak / sed.py View on Github external
def apply_extinction(self, ext_type, EBmV):
        """ Return a new SED instance with the extinction curve
        applied at the same redshift as the template.

        Allowed extinction laws are:

           MW
           SMC
           LMC
           starburst

        See the extinction module for more information.
        """
        import extinction as ext
        ecurve = dict(MW= ext.MW_Cardelli89             ,
                      SMC=ext.SMC_Gordon03              ,
                      LMC=ext.LMC_Gordon03              ,
                      starburst=ext.starburst_Calzetti00
                      )

        sed = self.copy()
        sed.z0fl[:] = sed.z0fl_noextinct
        tau = ecurve[ext_type](self.z0wa, EBmV=EBmV).tau
        sed.z0fl *= np.exp(-tau)
        sed.EBmV = EBmV

        sed.redshift_to(sed.z)
        return sed