Package ivs :: Package sed :: Module reddening
[hide private]
[frames] | no frames]

Module reddening

source code

Definitions of interstellar reddening curves

Section 1. General interface

Use the general interface to get different curves:

>>> wave = np.r_[1e3:1e5:10]
>>> for name in ['chiar2006','fitzpatrick1999','fitzpatrick2004','cardelli1989','seaton1979']:
...   wave_,mag_ = get_law(name,wave=wave)
...   p = pl.plot(1e4/wave_,mag_,label=name)
>>> p = pl.xlim(0,10)
>>> p = pl.ylim(0,12)

Use the general interface to get the same curves but with different Rv:

>>> for Rv in [2.0,3.1,5.1]:
...   wave_,mag_ = get_law('cardelli1989',wave=wave,Rv=Rv)
...   p = pl.plot(1e4/wave_,mag_,'--',lw=2,label='cardelli1989 Rv=%.1f'%(Rv))
>>> p = pl.xlim(0,10)
>>> p = pl.ylim(0,12)
>>> p = pl.xlabel('1/$\lambda$ [1/$\mu$m]')
>>> p = pl.ylabel(r'Extinction E(B-$\lambda$) [mag]')
>>> p = pl.legend(prop=dict(size='small'),loc='lower right')

]include figure]]ivs_sed_reddening_curves.png]

Section 2. Individual curve definitions

Get the curves seperately:

>>> wave1,mag1 = cardelli1989()
>>> wave2,mag2 = chiar2006()
>>> wave3,mag3 = seaton1979()
>>> wave4,mag4 = fitzpatrick1999()
>>> wave5,mag5 = fitzpatrick2004()

Section 3. Normalisations

>>> wave = np.logspace(3,6,1000)
>>> photbands = ['JOHNSON.V','JOHNSON.K']

Retrieve two interstellar reddening laws, normalise them to Av and see what the ratio between Ak and Av is. Since the chiar2006 law is not defined in the optical, this procedure actually doesn't make sense for that law. In the case of cardelli1989, compute the ratio Ak/Av. Note that you cannot ask for the chiar2006 to be normalised in the visual, since the curve is not defined their! If you really want to do that anyway, you need to derive a Ak/Av factor from another curve (e.g. the cardelli1989).

>>> p = pl.figure()
>>> for name,norm in zip(['chiar2006','cardelli1989'],['Ak','Av']):
...   wave_,mag_ = get_law(name,wave=wave,norm=norm)
...   photwave,photflux = get_law(name,wave=wave,norm=norm,photbands=photbands)
...   p = pl.plot(wave_/1e4,mag_,label=name)
...   p = pl.plot(photwave/1e4,photflux,'s')
...   if name=='cardelli1989': print 'Ak/Av = %.3g'%(photflux[1]/photflux[0])
Ak/Av = 0.114
>>> p = pl.gca().set_xscale('log')
>>> p = pl.gca().set_yscale('log')
>>> p = pl.xlabel('Wavelength [micron]')
>>> p = pl.ylabel('Extinction A($\lambda$)/Av [mag]')

]include figure]]ivs_sed_reddening_02.png]

Compute the Cardelli law normalised to Ak and Av.

>>> p = pl.figure()
>>> wave_av1,mag_av1 = get_law('cardelli1989',wave=wave,norm='Av')
>>> wave_av2,mag_av2 = get_law('cardelli1989',wave=wave,norm='Av',photbands=['JOHNSON.V'])
>>> p = pl.plot(wave_av1,mag_av1,'k-',lw=2,label='Av')
>>> p = pl.plot(wave_av2,mag_av2,'ks')
>>> wave_ak1,mag_ak1 = get_law('cardelli1989',wave=wave,norm='Ak')
>>> wave_ak2,mag_ak2 = get_law('cardelli1989',wave=wave,norm='Ak',photbands=['JOHNSON.K'])
>>> p = pl.plot(wave_ak1,mag_ak1,'r-',lw=2,label='Ak')
>>> p = pl.plot(wave_ak2,mag_ak2,'rs')
>>> p = pl.gca().set_xscale('log')
>>> p = pl.gca().set_yscale('log')
>>> p = pl.xlabel('Wavelength [micron]')
>>> p = pl.ylabel('Extinction A($\lambda$)/A($\mu$) [mag]')

]include figure]]ivs_sed_reddening_03.png]

Functions [hide private]
    Main interface
(ndarray,ndarray)
get_law(name, norm='E(B-V)', wave_units='AA', photbands=None, **kwargs)
Retrieve an interstellar reddening law.
source code
ndarray (floats)
redden(flux, wave=None, photbands=None, ebv=0., rtype='flux', law='cardelli1989', **kwargs)
Redden flux or magnitudes
source code
ndarray (floats)
deredden(flux, wave=None, photbands=None, ebv=0., rtype='flux', **kwargs)
Deredden flux or magnitudes.
source code
    Curve definitions
(ndarray,ndarray)
chiar2006(Rv=3.1, curve='ism', **kwargs)
Extinction curve at infrared wavelengths from Chiar and Tielens (2006)
source code
(ndarray,ndarray)
fitzpatrick1999(Rv=3.1, **kwargs)
From Fitzpatrick 1999 (downloaded from ASAGIO database)
source code
(ndarray,ndarray)
fitzpatrick2004(Rv=3.1, **kwargs)
From Fitzpatrick 2004 (downloaded from FTP)
source code
(ndarray,ndarray)
donnell1994(**kwargs)
Small improvement on Cardelli 1989 by James E.
source code
(ndarray,ndarray)
cardelli1989(Rv=3.1, curve='cardelli', wave=None, **kwargs)
Construct extinction laws from Cardelli (1989).
source code
(ndarray,ndarray)
seaton1979(Rv=3.1, wave=None, **kwargs)
Extinction curve from Seaton, 1979.
source code
Variables [hide private]
  logger = logging.getLogger("SED.RED")
  basename = os.path.join(os.path.dirname(__file__), 'redlaws')
Function Details [hide private]

get_law(name, norm='E(B-V)', wave_units='AA', photbands=None, **kwargs)

source code 

Retrieve an interstellar reddening law.

Parameter name must be the function name of one of the laws defined in this module.

By default, the law will be interpolated on a grid from 100 angstrom to 10 micron in steps of 10 angstrom. This can be adjusted with the parameter wave (array), which must be in angstrom. You can change the units ouf the returned wavelength array via wave_units.

By default, the curve is normalised with respect to E(B-V) (you get A(l)/E(B-V)). You can set the norm keyword to Av if you want A(l)/Av. Remember that

A(V) = Rv * E(B-V)

The parameter Rv is by default 3.1, other reasonable values lie between 2.0 and 5.1

Extra accepted keywords depend on the type of reddening law used.

Example usage:

>>> wave = np.r_[1e3:1e5:10]
>>> wave,mag = get_law('cardelli1989',wave=wave,Rv=3.1)
Parameters:
  • name (str, one of the functions defined here) - name of the interstellar law
  • norm (str (one of E(B-V), Av)) - type of normalisation of the curve
  • wave_units (str (interpretable for units.conversions.convert)) - wavelength units
  • photbands (list of strings) - list of photometric passbands
  • wave (ndarray) - wavelength array to interpolate the law on
Returns: (ndarray,ndarray)
wavelength, reddening magnitude

redden(flux, wave=None, photbands=None, ebv=0., rtype='flux', law='cardelli1989', **kwargs)

source code 

Redden flux or magnitudes

The reddening parameters ebv means E(B-V).

If it is negative, we deredden.

If you give the keyword wave, it is assumed that you want to (de)redden a model, i.e. a spectral energy distribution.

If you give the keyword photbands, it is assumed that you want to (de)redden photometry, i.e. integrated fluxes.

Parameters:
  • flux (ndarray (floats)) - fluxes to (de)redden (magnitudes if rtype='mag')
  • wave (ndarray (floats)) - wavelengths matching the fluxes (or give photbands)
  • photbands (ndarray of str) - photometry bands matching the fluxes (or give wave)
  • ebv (float) - reddening parameter E(B-V)
  • rtype (str ('flux' or 'mag')) - type of dereddening (magnituds or fluxes)
Returns: ndarray (floats)
(de)reddened flux/magnitude

deredden(flux, wave=None, photbands=None, ebv=0., rtype='flux', **kwargs)

source code 

Deredden flux or magnitudes.

Parameters:
  • flux (ndarray (floats)) - fluxes to (de)redden (NOT magnitudes)
  • wave (ndarray (floats)) - wavelengths matching the fluxes (or give photbands)
  • photbands (ndarray of str) - photometry bands matching the fluxes (or give wave)
  • ebv (float) - reddening parameter E(B-V)
  • rtype (str ('flux' or 'mag')) - type of dereddening (magnituds or fluxes)
Returns: ndarray (floats)
(de)reddened flux

chiar2006(Rv=3.1, curve='ism', **kwargs)

source code 

Extinction curve at infrared wavelengths from Chiar and Tielens (2006)

We return A(lambda)/E(B-V), by multiplying A(lambda)/Av with Rv.

This is only defined for Rv=3.1. If it is different, this will raise an AssertionError

Extra kwags are to catch unwanted keyword arguments.

UNCERTAIN NORMALISATION

Parameters:
  • Rv (float) - Rv
  • curve (string (one of 'gc' or 'ism', galactic centre or local ISM)) - extinction curve
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized

fitzpatrick1999(Rv=3.1, **kwargs)

source code 

From Fitzpatrick 1999 (downloaded from ASAGIO database)

This function returns A(lambda)/A(V).

To get A(lambda)/E(B-V), multiply the return value with Rv (A(V)=Rv*E(B-V))

Extra kwags are to catch unwanted keyword arguments.

Parameters:
  • Rv (float) - Rv (2.1, 3.1 or 5.0)
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized

fitzpatrick2004(Rv=3.1, **kwargs)

source code 

From Fitzpatrick 2004 (downloaded from FTP)

This function returns A(lambda)/A(V).

To get A(lambda)/E(B-V), multiply the return value with Rv (A(V)=Rv*E(B-V))

Extra kwags are to catch unwanted keyword arguments.

Parameters:
  • Rv (float) - Rv (2.1, 3.1 or 5.0)
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized

donnell1994(**kwargs)

source code 

Small improvement on Cardelli 1989 by James E. O'Donnell (1994).

Extra kwags are to catch unwanted keyword arguments.

Parameters:
  • Rv (float) - Rv
  • wave (ndarray) - wavelengths to compute the curve on
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized

cardelli1989(Rv=3.1, curve='cardelli', wave=None, **kwargs)

source code 

Construct extinction laws from Cardelli (1989).

Improvement in optical by James E. O'Donnell (1994)

wavelengths in Angstrom!

This function returns A(lambda)/A(V).

To get A(lambda)/E(B-V), multiply the return value with Rv (A(V)=Rv*E(B-V))

Extra kwags are to catch unwanted keyword arguments.

Parameters:
  • Rv (float) - Rv
  • curve (string (one of 'cardelli' or 'donnell')) - extinction curve
  • wave (ndarray) - wavelengths to compute the curve on
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized

seaton1979(Rv=3.1, wave=None, **kwargs)

source code 

Extinction curve from Seaton, 1979.

This function returns A(lambda)/A(V).

To get A(lambda)/E(B-V), multiply the return value with Rv (A(V)=Rv*E(B-V))

Extra kwags are to catch unwanted keyword arguments.

Parameters:
  • Rv (float) - Rv
  • wave (ndarray) - wavelengths to compute the curve on
Returns: (ndarray,ndarray)
wavelengths (A), A(lambda)/Av
Decorators:
  • @memoized