Commit ea468ea2 authored by Médéric Boquien's avatar Médéric Boquien

Remove the possibility to use the same module several times. Simplification of...

Remove the possibility to use the same module several times. Simplification of the code ensues. Now sed.info keys are prefixed with the characteristic of the module (stellar, nebular, etc.).
parent 8b84aca4
......@@ -125,13 +125,6 @@ class CreationModule(object):
# module class is coded.
self.name = name or os.path.basename(inspect.getfile(self))[:4]
# We want to postfix the various keys of the SED with the same
# postfix as the module name, if any.
if '.' in name:
self.postfix = "." + name.split(".", 1)[1]
else:
self.postfix = ""
if not blank:
# Parameters given in constructor.
parameters = kwargs
......
......@@ -78,7 +78,6 @@ class BC03(CreationModule):
SED object.
"""
imf = self.parameters["imf"]
metallicity = float(self.parameters["metallicity"])
separation_age = int(self.parameters["separation_age"])
......@@ -102,35 +101,28 @@ class BC03(CreationModule):
sed.add_module(self.name, self.parameters)
sed.add_info("ssp_imf" + self.postfix, imf)
sed.add_info("ssp_metallicity" + self.postfix, metallicity)
sed.add_info("ssp_old_young_separation_age" + self.postfix,
separation_age)
sed.add_info("ssp_m_star_young" + self.postfix,
young_info["m_star"], True)
sed.add_info("ssp_m_gas_young" + self.postfix,
young_info["m_gas"], True)
sed.add_info("ssp_n_ly_young" + self.postfix, young_info["n_ly"])
sed.add_info("ssp_b_400_young" + self.postfix, young_info["b_4000"])
sed.add_info("ssp_b4_vn_young" + self.postfix, young_info["b4_vn"])
sed.add_info("ssp_b4_sdss_young" + self.postfix, young_info["b4_sdss"])
sed.add_info("ssp_b_912_young" + self.postfix, young_info["b_912"])
sed.add_info("ssp_m_star_old" + self.postfix, old_info["m_star"], True)
sed.add_info("ssp_m_gas_old" + self.postfix, old_info["m_gas"], True)
sed.add_info("ssp_n_ly_old" + self.postfix, old_info["n_ly"])
sed.add_info("ssp_b_400_old" + self.postfix, old_info["b_4000"])
sed.add_info("ssp_b4_vn_old" + self.postfix, old_info["b4_vn"])
sed.add_info("ssp_b4_sdss_old" + self.postfix, old_info["b4_sdss"])
sed.add_info("ssp_b_912_old" + self.postfix, old_info["b_912"])
sed.add_contribution("ssp_old" + self.postfix,
old_wave,
old_lumin)
sed.add_contribution("ssp_young" + self.postfix,
young_wave,
young_lumin)
sed.add_info("stellar.imf", imf)
sed.add_info("stellar.metallicity", metallicity)
sed.add_info("stellar.old_young_separation_age", separation_age)
sed.add_info("stellar.m_star_young", young_info["m_star"], True)
sed.add_info("stellar.m_gas_young", young_info["m_gas"], True)
sed.add_info("stellar.n_ly_young", young_info["n_ly"])
sed.add_info("stellar.b_400_young", young_info["b_4000"])
sed.add_info("stellar.b4_vn_young", young_info["b4_vn"])
sed.add_info("stellar.b4_sdss_young", young_info["b4_sdss"])
sed.add_info("stellar.b_912_young", young_info["b_912"])
sed.add_info("stellar.m_star_old", old_info["m_star"], True)
sed.add_info("stellar.m_gas_old", old_info["m_gas"], True)
sed.add_info("stellar.n_ly_old", old_info["n_ly"])
sed.add_info("stellar.b_400_old", old_info["b_4000"])
sed.add_info("stellar.b4_vn_old", old_info["b4_vn"])
sed.add_info("stellar.b4_sdss_old", old_info["b4_sdss"])
sed.add_info("stellar.b_912_old", old_info["b_912"])
sed.add_contribution("stellar.old", old_wave, old_lumin)
sed.add_contribution("stellar.young", young_wave, young_lumin)
# CreationModule to be returned by get_module
Module = BC03
......@@ -42,14 +42,6 @@ class Casey2012(CreationModule):
"float",
"Mid-infrared powerlaw slope.",
None
)),
('attenuation_value_keys', (
'string',
"Keys of the SED information dictionary where the module will "
"look for the attenuation (in W) to re-emit. You can give several "
"keys separated with a & (don't use commas), a re-emission "
"contribution will be added for each key.",
"attenuation"
))
])
......@@ -103,31 +95,17 @@ class Casey2012(CreationModule):
sed : pcigale.sed.SED object
"""
luminosity = sed.info['attenuation.total']
sed.add_module(self.name, self.parameters)
sed.add_info("dust.temperature", self.parameters["temperature"])
sed.add_info("dust.alpha", self.parameters["alpha"])
sed.add_info("dust.beta", self.parameters["beta"])
# Base name for adding information to the SED.
name = self.name or 'casey2012'
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
sed.add_module(name, self.parameters)
sed.add_info("temperature" + self.postfix,
self.parameters["temperature"])
sed.add_info("alpha" + self.postfix, self.parameters["alpha"])
sed.add_info("beta" + self.postfix, self.parameters["beta"])
for attenuation in attenuation_value_keys:
sed.add_contribution(
name + '_powerlaw_' + attenuation,
self.wave,
sed.info[attenuation] * self.lumin_powerlaw
)
sed.add_contribution(
name + '_blackbody_' + attenuation,
self.wave,
sed.info[attenuation] * self.lumin_blackbody
)
sed.add_contribution('dust.powerlaw', self.wave,
luminosity * self.lumin_powerlaw)
sed.add_contribution('dust.blackbody', self.wave,
luminosity * self.lumin_blackbody)
# CreationModule to be returned by get_module
Module = Casey2012
......@@ -79,28 +79,18 @@ class Dale2014(CreationModule):
parameters : dictionary containing the parameters
"""
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
luminosity = sed.info['attenuation.total']
frac_agn = self.parameters["fracAGN"]
sed.add_module(self.name, self.parameters)
sed.add_info("fracAGN" + self.postfix, self.parameters["fracAGN"])
sed.add_info("alpha" + self.postfix, self.parameters["alpha"])
for attenuation in attenuation_value_keys:
sed.add_contribution(
'dale2014_sb_' + attenuation + self.postfix,
self.model_sb.wave,
sed.info[attenuation] * self.model_sb.lumin
)
sed.add_contribution(
'dale2014_quasar_' + attenuation + self.postfix,
self.model_quasar.wave,
frac_agn * sed.info[attenuation] * self.model_quasar.lumin
)
sed.add_info("agn.fracAGN", self.parameters["fracAGN"])
sed.add_info("dust.alpha", self.parameters["alpha"])
sed.add_contribution('dust', self.model_sb.wave,
luminosity * self.model_sb.lumin)
sed.add_contribution('agn', self.model_quasar.wave,
frac_agn * luminosity * self.model_quasar.lumin)
# CreationModule to be returned by get_module
Module = Dale2014
......@@ -60,21 +60,16 @@ class DH2002(CreationModule):
"""
alpha = float(self.parameters["alpha"])
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
luminosity = sed.info['attenuation.total']
ir_template = self.dh2002.get_template(alpha)
sed.add_module(self.name, self.parameters)
sed.add_info("alpha" + self.postfix, alpha)
for attenuation in attenuation_value_keys:
sed.add_contribution(
self.name + "_" + attenuation,
self.dh2002.wavelength_grid,
sed.info[attenuation] * ir_template
)
sed.add_info("dust.alpha", alpha)
sed.add_contribution('dust', self.dh2002.wavelength_grid,
luminosity * ir_template)
# CreationModule to be returned by get_module
Module = DH2002
......@@ -50,14 +50,6 @@ class DL2007(CreationModule):
'float',
"Fraction illuminated from Umin to Umax",
None
)),
('attenuation_value_keys', (
'string',
"Keys of the SED information dictionary where the module will "
"look for the attenuation (in W) to re-emit. You can give several "
"keys separated with a & (don't use commas), a re-emission "
"contribution will be added for each key.",
"attenuation"
))
])
......@@ -104,30 +96,18 @@ class DL2007(CreationModule):
parameters : dictionary containing the parameters
"""
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
# Base name for adding information to the SED.
name = self.name or 'dl2007'
sed.add_module(name, self.parameters)
sed.add_info('qpah' + self.postfix, self.parameters["qpah"])
sed.add_info('umin' + self.postfix, self.parameters["umin"])
sed.add_info('umax' + self.postfix, self.parameters["umax"])
sed.add_info('gamma' + self.postfix, self.parameters["gamma"])
for attenuation in attenuation_value_keys:
sed.add_contribution(
name + '_Umin_Umin_' + attenuation,
self.model_minmin.wave,
sed.info[attenuation] * self.model_minmin.lumin
)
sed.add_contribution(
name + '_Umin_Umax_' + attenuation,
self.model_minmax.wave,
sed.info[attenuation] * self.model_minmax.lumin
)
luminosity = sed.info['attenuation.total']
sed.add_module(self.name, self.parameters)
sed.add_info('dust.qpah', self.parameters["qpah"])
sed.add_info('dust.umin', self.parameters["umin"])
sed.add_info('dust.umax', self.parameters["umax"])
sed.add_info('dust.gamma', self.parameters["gamma"])
sed.add_contribution('dust.Umin_Umin', self.model_minmin.wave,
luminosity * self.model_minmin.lumin)
sed.add_contribution('dust.Umin_Umax', self.model_minmax.wave,
luminosity * self.model_minmax.lumin)
# CreationModule to be returned by get_module
Module = DL2007
......@@ -192,19 +192,6 @@ class CalzLeit(CreationModule):
"to the young one (<1).",
None
)),
("young_contribution_name", (
"string",
"Name of the contribution containing the spectrum of the "
"young population.",
"ssp_young"
)),
("old_contribution_name", (
"string",
"Name of the contribution containing the spectrum of the "
"old population. If it is set to 'None', only one population "
"is considered.",
"ssp_old"
)),
("uv_bump_wavelength", (
"float",
"Central wavelength of the UV bump in nm.",
......@@ -235,17 +222,12 @@ class CalzLeit(CreationModule):
])
out_parameter_list = OrderedDict([
("E_BVs_young", "E(B-V)*, the colour excess of the stellar continuum "
"light for the young population."),
("E_BVs_old", "E(B-V)*, the colour excess of the stellar "
"continuum light for the old population."),
("attenuation_young", "Amount of luminosity attenuated from the "
"young population in W."),
("E_BVs_old_factor", "Ratio of the old population E(B-V)* to the "
("E_BVs", "E(B-V), the colour excess of the stellar continuum "
"light for each population."),
("E_BVs_old_factor", "Ratio of the old population E(B-V) to the "
"young one."),
("attenuation_old", "Amount of luminosity attenuated from the "
"old population in W."),
("attenuation", "Total amount of luminosity attenuated in W."),
("attenuation", "Amount of luminosity attenuated in W for each "
"component and in total."),
("uv_bump_wavelength", "Central wavelength of UV bump in nm."),
("uv_bump_width", "Width of the UV bump in nm."),
("uv_bump_amplitude", "Amplitude of the UV bump in nm."),
......@@ -270,12 +252,10 @@ class CalzLeit(CreationModule):
sed : pcigale.sed.SED object
"""
ebvs = {}
wavelength = sed.wavelength_grid
ebvs_young = float(self.parameters["E_BVs_young"])
ebvs_old = float(self.parameters["E_BVs_old_factor"]) * ebvs_young
young_contrib = self.parameters["young_contribution_name"]
old_contrib = self.parameters["old_contribution_name"]
ebvs['young'] = float(self.parameters["E_BVs_young"])
ebvs['old'] = float(self.parameters["E_BVs_old_factor"]) * ebvs['young']
uv_bump_wavelength = float(self.parameters["uv_bump_wavelength"])
uv_bump_width = float(self.parameters["uv_bump_wavelength"])
uv_bump_amplitude = float(self.parameters["uv_bump_amplitude"])
......@@ -295,45 +275,26 @@ class CalzLeit(CreationModule):
uv_bump_width, uv_bump_amplitude,
powerlaw_slope)
# Young population attenuation
luminosity = sed.get_lumin_contribution(young_contrib)
attenuated_luminosity = luminosity * 10 ** (ebvs_young
* sel_attenuation / -2.5)
attenuated_luminosity[wavelength < 91.2] = 0
attenuation_spectrum = attenuated_luminosity - luminosity
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_module(self.name, self.parameters)
sed.add_info("E_BVs_young" + self.postfix, ebvs_young)
sed.add_info("attenuation_young" + self.postfix, attenuation_young)
sed.add_contribution("attenuation_young" + self.postfix,
wavelength, attenuation_spectrum)
# Old population (if any) attenuation
if old_contrib:
luminosity = sed.get_lumin_contribution(old_contrib)
attenuated_luminosity = (luminosity *
10 ** (ebvs_old
* sel_attenuation / -2.5))
attenuated_luminosity[wavelength < 91.2] = 0
attenuation_total = 0.
for contrib in list(sed.contribution_names):
age = contrib.split('.')[-1].split('_')[-1]
luminosity = sed.get_lumin_contribution(contrib)
attenuated_luminosity = (luminosity * 10 **
(ebvs[age] * sel_attenuation / -2.5))
attenuation_spectrum = attenuated_luminosity - luminosity
attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_info("E_BVs_old" + self.postfix, ebvs_old)
sed.add_info("E_BVs_old_factor" + self.postfix,
self.parameters["E_BVs_old_factor"])
sed.add_info("attenuation_old" + self.postfix, attenuation_old)
sed.add_contribution("attenuation_old" + self.postfix,
wavelength, attenuation_spectrum)
else:
attenuation_old = 0
# Total attenuation (we don't take into account the energy attenuated
# in the spectral lines)
sed.add_info("attenuation" + self.postfix,
attenuation_young + attenuation_old)
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
attenuation = -1 * np.trapz(attenuation_spectrum, wavelength)
attenuation_total += attenuation
sed.add_module(self.name, self.parameters)
sed.add_info("attenuation.E_BVs." + contrib, ebvs[age])
sed.add_info("attenuation." + contrib, attenuation)
sed.add_contribution("attenuation." + contrib, wavelength,
attenuation_spectrum)
# Total attenuation
sed.add_info("attenuation.total", attenuation_total)
# Fλ fluxes (only from continuum) in each filter after attenuation.
flux_att = {}
......@@ -345,7 +306,7 @@ class CalzLeit(CreationModule):
# Attenuation in each filter
for filter_name in filters:
sed.add_info(filter_name + "_attenuation" + self.postfix,
sed.add_info("attenuation." + filter_name,
-2.5 * np.log10(flux_att[filter_name] /
flux_noatt[filter_name]))
......
......@@ -117,19 +117,6 @@ class PowerLawAtt(CreationModule):
"population compared to the young one (<1).",
None
)),
("young_contribution_name", (
"string",
"Name of the contribution containing the spectrum of the "
"young population.",
"ssp_young"
)),
("old_contribution_name", (
"string",
"Name of the contribution containing the spectrum of the "
"old population. If it is set to 'None', only one population "
"is considered.",
"ssp_old"
)),
("uv_bump_wavelength", (
"float",
"Central wavelength of the UV bump in nm.",
......@@ -160,16 +147,12 @@ class PowerLawAtt(CreationModule):
])
out_parameter_list = OrderedDict([
("Av_young", "V-band attenuation of the young population."),
("Av_old", "V-band attenuation of the old population."),
("attenuation_young", "Amount of luminosity attenuated from the "
"young population in W."),
("Av", "V-band attenuation."),
("Av_old_factor", "Reduction factor for the V-band attenuation "
"of the old population compared to the young "
"one (<1)."),
("attenuation_old", "Amount of luminosity attenuated from the "
"old population in W."),
("attenuation", "Total amount of luminosity attenuated in W."),
("attenuation", "Amount of luminosity attenuated in W for each "
"component and in total."),
("uv_bump_wavelength", "Central wavelength of UV bump in nm."),
("uv_bump_width", "Width of the UV bump in nm."),
("uv_bump_amplitude", "Amplitude of the UV bump in nm."),
......@@ -194,12 +177,10 @@ class PowerLawAtt(CreationModule):
sed : pcigale.sed.SED object
"""
av = {}
wavelength = sed.wavelength_grid
av_young = float(self.parameters["Av_young"])
av_old = float(self.parameters["Av_old_factor"] * av_young)
young_contrib = self.parameters["young_contribution_name"]
old_contrib = self.parameters["old_contribution_name"]
av['young'] = float(self.parameters["Av_young"])
av['old'] = float(self.parameters["Av_old_factor"] * av['young'])
uv_bump_wavelength = float(self.parameters["uv_bump_wavelength"])
uv_bump_width = float(self.parameters["uv_bump_wavelength"])
uv_bump_amplitude = float(self.parameters["uv_bump_amplitude"])
......@@ -219,43 +200,26 @@ class PowerLawAtt(CreationModule):
uv_bump_wavelength, uv_bump_width,
uv_bump_amplitude)
# Young population attenuation
luminosity = sed.get_lumin_contribution(young_contrib)
attenuated_luminosity = luminosity * 10 ** (av_young
* sel_attenuation / -2.5)
attenuation_spectrum = attenuated_luminosity - luminosity
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_module(self.name, self.parameters)
sed.add_info("Av_young" + self.postfix, av_young)
sed.add_info("attenuation_young" + self.postfix, attenuation_young)
sed.add_contribution("attenuation_young" + self.postfix, wavelength,
attenuation_spectrum)
# Old population (if any) attenuation
if old_contrib:
luminosity = sed.get_lumin_contribution(old_contrib)
attenuated_luminosity = (luminosity *
10 ** (av_old
* sel_attenuation / -2.5))
attenuation_total = 0.
for contrib in list(sed.contribution_names):
age = contrib.split('.')[-1].split('_')[-1]
luminosity = sed.get_lumin_contribution(contrib)
attenuated_luminosity = (luminosity * 10 **
(av[age] * sel_attenuation / -2.5))
attenuation_spectrum = attenuated_luminosity - luminosity
attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_info("Av_old" + self.postfix, av_old)
sed.add_info("Av_old_factor" + self.postfix,
self.parameters["Av_old_factor"])
sed.add_info("attenuation_old" + self.postfix, attenuation_old)
sed.add_contribution("attenuation_old" + self.postfix,
wavelength, attenuation_spectrum)
else:
attenuation_old = 0
# Total attenuation (we don't take into account the energy attenuated
# in the spectral lines)
sed.add_info("attenuation" + self.postfix,
attenuation_young + attenuation_old)
# We integrate the amount of luminosity attenuated (-1 because the
# spectrum is negative).
attenuation = -1 * np.trapz(attenuation_spectrum, wavelength)
attenuation_total += attenuation
sed.add_module(self.name, self.parameters)
sed.add_info("attenuation.Av." + contrib, av[age])
sed.add_info("attenuation." + contrib, attenuation)
sed.add_contribution("attenuation." + contrib, wavelength,
attenuation_spectrum)
# Total attenuation
sed.add_info("attenuation.total", attenuation_total)
# Fλ fluxes (only in continuum) in each filter after attenuation.
flux_att = {}
......@@ -267,7 +231,7 @@ class PowerLawAtt(CreationModule):
# Attenuation in each filter
for filter_name in filters:
sed.add_info(filter_name + "_attenuation" + self.postfix,
sed.add_info("attenuation." + filter_name,
-2.5 * np.log10(flux_att[filter_name] /
flux_noatt[filter_name]))
......
......@@ -42,9 +42,7 @@ class IgmAttenuation(CreationModule):
sed : pcigale.sed.SED object
"""
if sed.redshift > 0:
# To memoize the IGM attenuation computation (with depends on the
# wavelength grid and the redshift), we have to make the
# wavelength grid hashable. We do this by converting to a string.
......@@ -58,11 +56,7 @@ class IgmAttenuation(CreationModule):
igm_effect = self.igm_att[wave_redshift] * sed .luminosity
sed.add_module(self.name, self.parameters)
sed.add_contribution(
self.name,
sed.wavelength_grid,
igm_effect
)
sed.add_contribution('igm', sed.wavelength_grid, igm_effect)
def igm_transmission_meiksin(wavelength, redshift):
......
......@@ -116,7 +116,6 @@ class M2005(CreationModule):
SED object.
"""
imf = self.parameters["imf"]
metallicity = float(self.parameters["metallicity"])
separation_age = int(self.parameters["separation_age"])
......@@ -140,52 +139,41 @@ class M2005(CreationModule):
sed.add_module(self.name, self.parameters)
sed.add_info('ssp_imf' + self.postfix, imf)
sed.add_info('ssp_metallicity' + self.postfix, metallicity)
sed.add_info('ssp_old_young_separation_age' + self.postfix,
separation_age)
sed.add_info('ssp_mass_total_old' + self.postfix, old_masses[0], True)
sed.add_info('ssp_mass_alive_old' + self.postfix, old_masses[1], True)
sed.add_info('ssp_mass_white_dwarf_old' + self.postfix, old_masses[2],
True)
sed.add_info('ssp_mass_neutrino_old' + self.postfix, old_masses[3],
True)
sed.add_info('ssp_mass_black_hole_old' + self.postfix, old_masses[4],
True)
sed.add_info('ssp_mass_turn_off_old' + self.postfix, old_masses[5],
True)
sed.add_info('ssp_mass_total_young' + self.postfix, young_masses[0],
True)
sed.add_info('ssp_mass_alive_young' + self.postfix, young_masses[1],
True)
sed.add_info('ssp_mass_white_dwarf_young' + self.postfix,
young_masses[2], True)
sed.add_info('ssp_mass_neutrino_young' + self.postfix, young_masses[3],
True)
sed.add_info('ssp_mass_black_hole_young' + self.postfix,
young_masses[4], True)
sed.add_info('ssp_mass_turn_off_young' + self.postfix, young_masses[5],
True)
sed.add_info('ssp_mass_total' + self.postfix,
sed.add_info('stellar.imf', imf)
sed.add_info('stellar.metallicity', metallicity)
sed.add_info('stellar.old_young_separation_age', separation_age)
sed.add_info('stellar.mass_total_old', old_masses[0], True)
sed.add_info('stellar.mass_alive_old', old_masses[1], True)
sed.add_info('stellar.mass_white_dwarf_old', old_masses[2], True)
sed.add_info('stellar.mass_neutrino_old', old_masses[3], True)
sed.add_info('stellar.mass_black_hole_old', old_masses[4], True)
sed.add_info('stellar.mass_turn_off_old', old_masses[5], True)
sed.add_info('stellar.mass_total_young', young_masses[0], True)
sed.add_info('stellar.mass_alive_young', young_masses[1], True)
sed.add_info('stellar.mass_white_dwarf_young', young_masses[2], True)
sed.add_info('stellar.mass_neutrino_young', young_masses[3], True)
sed.add_info('stellar.mass_black_hole_young', young_masses[4], True)
sed.add_info('stellar.mass_turn_off_young', young_masses[5], True)
sed.add_info('stellar.mass_total',
old_masses[0] + young_masses[0], True)
sed.add_info('ssp_mass_alive' + self.postfix,
sed.add_info('stellar.mass_alive',
old_masses[1] + young_masses[1], True)
sed.add_info('ssp_mass_white_dwarf' + self.postfix,
sed.add_info('stellar.mass_white_dwarf',
old_masses[2] + young_masses[2], True)
sed.add_info('ssp_mass_neutrino' + self.postfix,
sed.add_info('stellar.mass_neutrino',
old_masses[3] + young_masses[3], True)
sed.add_info('ssp_mass_black_hole' + self.postfix,
sed.add_info('stellar.mass_black_hole',
old_masses[4] + young_masses[4], True)
sed.add_info('ssp_mass_turn_off' + self.postfix,
sed.add_info('stellar.mass_turn_off',
old_masses[5] + young_masses[5], True)
sed.add_contribution("ssp_old" + self.postfix,
sed.add_contribution("ssp_old",
ssp.wavelength_grid,
old_spectrum)
sed.add_contribution("ssp_young" + self.postfix,
sed.add_contribution("ssp_young",
ssp.wavelength_grid,
young_spectrum)
......
......@@ -132,29 +132,25 @@ class NebularEmission(CreationModule):
parameters : dictionary containing the parameters
"""
# Base name for adding information to the SED.
name = self.name or 'nebular'
f_esc = self.parameters['f_esc']
f_dust = self.parameters['f_dust']
NLy_old = sed.info['ssp_n_ly_old']
NLy_young = sed.info['ssp_n_ly_young']
lines = self.lines_template[sed.info['ssp_metallicity']]
cont = self.cont_template[sed.info['ssp_metallicity']]
NLy_old = sed.info['stellar.n_ly_old']
NLy_young = sed.info['stellar.n_ly_young']
lines = self.lines_template[sed.info['stellar.metallicity']]
cont = self.cont_template[sed.info['stellar.metallicity']]
sed.add_module(name, self.parameters)
sed.add_info(name + '_f_esc', f_esc)
sed.add_info(name + '_f_dust', f_dust)
sed.add_module(self.name, self.parameters)
sed.add_info('nebular.f_esc', f_esc)
sed.add_info('nebular.f_dust', f_dust)
sed.add_contribution('nebular_lines_old', lines.wave, lines.ratio *
sed.add_contribution('nebular.lines_old', lines.wave, lines.ratio *
NLy_old * self.conv_line)
sed.add_contribution('nebular_lines_young', lines.wave, lines.ratio *
sed.add_contribution('nebular.lines_young', lines.wave, lines.ratio *
NLy_young * self.conv_line)
sed.add_contribution('nebular_continuum_old', cont.wave, cont.lumin *
sed.add_contribution('nebular.continuum_old', cont.wave, cont.lumin *
NLy_old * self.conv_cont)
sed.add_contribution('nebular_continuum_young', cont.wave, cont.lumin *
sed.add_contribution('nebular.continuum_young', cont.wave, cont.lumin *
NLy_young * self.conv_cont)
# CreationModule to be returned by get_module
......
......@@ -76,7 +76,6 @@ class Sfh2Exp(CreationModule):
sed : pcigale.sed.SED object
"""
tau_main = float(self.parameters["tau_main"])
tau_burst = float(self.parameters["tau_burst"])
f_burst = float(self.parameters["f_burst"])
......@@ -105,16 +104,16 @@ class Sfh2Exp(CreationModule):
(-time_grid[mask] + age - burst_age) / tau_burst)
# We normalise the SFH to have one solar mass produced.
sfr = sfr / np.trapz(sfr * 1.e6, time_grid)
sfr = sfr / np.trapz(sfr * 1e6, time_grid)
sed.add_module(self.name, self.parameters)
# Add the sfh and the output parameters to the SED.
sed.sfh = (time_grid, sfr)
sed.add_info("sfh_tau_main" + self.postfix, tau_main)
sed.add_info("sfh_tau_burst" + self.postfix, tau_burst)
sed.