Commit dcb72a5e authored by Médéric Boquien's avatar Médéric Boquien
Browse files

During a given run the set of wavelengths will always be the same. Then it...

During a given run the set of wavelengths will always be the same. Then it means we do not have to recompute the shape of the attenuation curve each time. So we compute it only the first time reuse it later.
parent 21a634bf
......@@ -243,6 +243,9 @@ class CalzLeit(CreationModule):
with Database() as base:
for filter_name in filter_list:
self.filters[filter_name] = base.get_filter(filter_name)
# We cannot compute the attenuation until we know the wavelengths. Yet,
# we reserve the object.
self.sel_attenuation = None
def process(self, sed):
"""Add the CCM dust attenuation to the SED.
......@@ -270,7 +273,8 @@ class CalzLeit(CreationModule):
filter_.effective_wavelength)
# Compute attenuation curve
sel_attenuation = a_vs_ebv(wavelength, uv_bump_wavelength,
if self.sel_attenuation is None:
self.sel_attenuation = a_vs_ebv(wavelength, uv_bump_wavelength,
uv_bump_width, uv_bump_amplitude,
powerlaw_slope)
......@@ -279,7 +283,7 @@ class CalzLeit(CreationModule):
age = contrib.split('.')[-1].split('_')[-1]
luminosity = sed.get_lumin_contribution(contrib)
attenuated_luminosity = (luminosity * 10 **
(ebvs[age] * sel_attenuation / -2.5))
(ebvs[age] * self.sel_attenuation / -2.5))
attenuation_spectrum = attenuated_luminosity - luminosity
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
......
......@@ -168,6 +168,9 @@ class PowerLawAtt(CreationModule):
with Database() as base:
for filter_name in filter_list:
self.filters[filter_name] = base.get_filter(filter_name)
# We cannot compute the attenuation until we know the wavelengths. Yet,
# we reserve the object.
self.sel_attenuation = None
def process(self, sed):
"""Add the CCM dust attenuation to the SED.
......@@ -195,7 +198,8 @@ class PowerLawAtt(CreationModule):
filter_.effective_wavelength)
# Compute attenuation curve
sel_attenuation = alambda_av(wavelength, powerlaw_slope,
if self.sel_attenuation is None:
self.sel_attenuation = alambda_av(wavelength, powerlaw_slope,
uv_bump_wavelength, uv_bump_width,
uv_bump_amplitude)
......@@ -204,7 +208,7 @@ class PowerLawAtt(CreationModule):
age = contrib.split('.')[-1].split('_')[-1]
luminosity = sed.get_lumin_contribution(contrib)
attenuated_luminosity = (luminosity * 10 **
(av[age] * sel_attenuation / -2.5))
(av[age] * self.sel_attenuation / -2.5))
attenuation_spectrum = attenuated_luminosity - luminosity
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment