Commit a78bf8c3 authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Postfix the key instead of prefixing

Instead of prefixing the key in the SED with the module name, we postfix
them with the same postfix as the module name if any. This makes easier
to inter-change modules adding the same information (for instance
attenuation modules adding the attenuation value).
That implies that when using several modules adding the same
information, one must postfix the name of each.
parent bce2582f
...@@ -8,6 +8,7 @@ from collections import OrderedDict ...@@ -8,6 +8,7 @@ from collections import OrderedDict
from . import common from . import common
from ...data import Database from ...data import Database
# Time lapse used to compute the average star formation rate. We use a # Time lapse used to compute the average star formation rate. We use a
# constant to keep it easily changeable for advanced user while limiting the # constant to keep it easily changeable for advanced user while limiting the
# number of parameters. The value is in Myr. # number of parameters. The value is in Myr.
...@@ -44,14 +45,15 @@ class Module(common.SEDCreationModule): ...@@ -44,14 +45,15 @@ class Module(common.SEDCreationModule):
"at the age of the galaxy."), "at the age of the galaxy."),
("average_sfr", "Average SFR in the last 100 Myr (default) of the " ("average_sfr", "Average SFR in the last 100 Myr (default) of the "
"galaxy history."), "galaxy history."),
("m_star", "Total mass in stars in Solar mass."), ("ssp_m_star", "Total mass in stars in Solar mass."),
("m_gas", "Mass returned to the ISM by evolved stars in Solar mass."), ("ssp_m_gas", "Mass returned to the ISM by evolved stars in Solar "
("n_ly", "rate of H-ionizing photons in s^-1, per Solar mass " "mass."),
"of galaxy."), ("ssp_n_ly", "rate of H-ionizing photons in s^-1, per Solar mass "
("b_4000", "Amplitude of 4000 Å break (Bruzual 2003)"), "of galaxy."),
("b4_vn", "Amplitude of 4000 Å narrow break (Balogh et al. 1999)"), ("ssp_b_4000", "Amplitude of 4000 Å break (Bruzual 2003)"),
("b4_sdss", "Amplitude of 4000 Å break (Stoughton et al. 2002)"), ("ssp_b4_vn", "Amplitude of 4000 Å narrow break (Balogh et al. 1999)"),
("b_912", "Amplitude of Lyman discontinuity") ("ssp_b4_sdss", "Amplitude of 4000 Å break (Stoughton et al. 2002)"),
("ssp_b_912", "Amplitude of Lyman discontinuity")
]) ])
def _init_code(self): def _init_code(self):
...@@ -99,37 +101,37 @@ class Module(common.SEDCreationModule): ...@@ -99,37 +101,37 @@ class Module(common.SEDCreationModule):
# Average SFR on the last AV_LAPSE Myr of its history # Average SFR on the last AV_LAPSE Myr of its history
average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE]) average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE])
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or "bc03"
sed.add_info("ssp_imf" + self.postfix, imf)
sed.add_module(name, self.parameters) sed.add_info("ssp_metallicity" + self.postfix, metallicity)
sed.add_info("ssp_old_young_separation_age" + self.postfix,
sed.add_info(name + "_imf", imf) separation_age)
sed.add_info(name + "_metallicity", metallicity)
sed.add_info(name + '_old_young_separation_age', separation_age) sed.add_info("sfr" + self.postfix, sfr, True)
sed.add_info("average_sfr" + self.postfix, average_sfr, True)
sed.add_info(name + '_sfr', sfr, True)
sed.add_info(name + '_average_sfr', average_sfr, True) sed.add_info("ssp_m_star_young" + self.postfix,
young_info["m_star"], True)
sed.add_info(name + "_m_star_young", young_info["m_star"], True) sed.add_info("ssp_m_gas_young" + self.postfix,
sed.add_info(name + "_m_gas_young", young_info["m_gas"], True) young_info["m_gas"], True)
sed.add_info(name + "_n_ly_young", young_info["n_ly"]) sed.add_info("ssp_n_ly_young" + self.postfix, young_info["n_ly"])
sed.add_info(name + "_b_400_young", young_info["b_4000"]) sed.add_info("ssp_b_400_young" + self.postfix, young_info["b_4000"])
sed.add_info(name + "_b4_vn_young", young_info["b4_vn"]) sed.add_info("ssp_b4_vn_young" + self.postfix, young_info["b4_vn"])
sed.add_info(name + "_b4_sdss_young", young_info["b4_sdss"]) sed.add_info("ssp_b4_sdss_young" + self.postfix, young_info["b4_sdss"])
sed.add_info(name + "_b_912_young", young_info["b_912"]) sed.add_info("ssp_b_912_young" + self.postfix, young_info["b_912"])
sed.add_info(name + "_m_star_old", old_info["m_star"], True) sed.add_info("ssp_m_star_old" + self.postfix, old_info["m_star"], True)
sed.add_info(name + "_m_gas_old", old_info["m_gas"], True) sed.add_info("ssp_m_gas_old" + self.postfix, old_info["m_gas"], True)
sed.add_info(name + "_n_ly_old", old_info["n_ly"]) sed.add_info("ssp_n_ly_old" + self.postfix, old_info["n_ly"])
sed.add_info(name + "_b_400_old", old_info["b_4000"]) sed.add_info("ssp_b_400_old" + self.postfix, old_info["b_4000"])
sed.add_info(name + "_b4_vn_old", old_info["b4_vn"]) sed.add_info("ssp_b4_vn_old" + self.postfix, old_info["b4_vn"])
sed.add_info(name + "_b4_sdss_old", old_info["b4_sdss"]) sed.add_info("ssp_b4_sdss_old" + self.postfix, old_info["b4_sdss"])
sed.add_info(name + "_b_912_old", old_info["b_912"]) sed.add_info("ssp_b_912_old" + self.postfix, old_info["b_912"])
sed.add_contribution(name + '_old', sed.add_contribution("ssp_old" + self.postfix,
old_wave, old_wave,
old_lumin) old_lumin)
sed.add_contribution(name + '_young', sed.add_contribution("ssp_young" + self.postfix,
young_wave, young_wave,
young_lumin) young_lumin)
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt # Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Yannick Roehlly <yannick.roehlly@oamp.fr> # Author: Yannick Roehlly <yannick.roehlly@oamp.fr>
import os
import inspect
from importlib import import_module from importlib import import_module
from collections import OrderedDict from collections import OrderedDict
...@@ -84,9 +86,8 @@ class SEDCreationModule(object): ...@@ -84,9 +86,8 @@ class SEDCreationModule(object):
# parameters that are added to the SED info dictionary and for which a # parameters that are added to the SED info dictionary and for which a
# statistical analysis may be done. Each parameter name is associated with # statistical analysis may be done. Each parameter name is associated with
# its description. In the SED info dictionary, the parameter name in # its description. In the SED info dictionary, the parameter name in
# prefixed with the name of the module plus an underscore (to allow # is postfixed with a same postfix used in the module name, to allow
# several modules to add a parameter with the same name, for instance a # the use of repeated modules.
# repeated module.)
out_parameter_list = OrderedDict() out_parameter_list = OrderedDict()
# comments is the text that is used to comment the module section in # comments is the text that is used to comment the module section in
...@@ -122,7 +123,16 @@ class SEDCreationModule(object): ...@@ -122,7 +123,16 @@ class SEDCreationModule(object):
unexpected parameter is given. unexpected parameter is given.
""" """
self.name = name # If a name is not given, we take if from the file in which the
# 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)
else:
self.postfix = ""
if not blank: if not blank:
# Parameters given in constructor. # Parameters given in constructor.
......
...@@ -61,15 +61,12 @@ class Module(common.SEDCreationModule): ...@@ -61,15 +61,12 @@ class Module(common.SEDCreationModule):
ir_template = self.dh2002.get_template(alpha) ir_template = self.dh2002.get_template(alpha)
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'dh2002' sed.add_info("alpha" + self.postfix, alpha)
sed.add_module(name, self.parameters)
sed.add_info(name + '_alpha', alpha)
for attenuation in attenuation_value_keys: for attenuation in attenuation_value_keys:
sed.add_contribution( sed.add_contribution(
name + '_' + attenuation, self.name + "_" + attenuation,
self.dh2002.wavelength_grid, self.dh2002.wavelength_grid,
sed.info[attenuation] * ir_template sed.info[attenuation] * ir_template
) )
...@@ -239,7 +239,7 @@ class Module(common.SEDCreationModule): ...@@ -239,7 +239,7 @@ class Module(common.SEDCreationModule):
("uv_bump_width", "Width of the UV bump in nm."), ("uv_bump_width", "Width of the UV bump in nm."),
("uv_bump_amplitude", "Amplitude of the UV bump in nm."), ("uv_bump_amplitude", "Amplitude of the UV bump in nm."),
("powerlaw_slope", "Slope of the power law."), ("powerlaw_slope", "Slope of the power law."),
("FILTER", "Attenuation in the FILTER filter.") ("FILTER_attenuation", "Attenuation in the FILTER filter.")
]) ])
def _init_code(self): def _init_code(self):
...@@ -261,9 +261,6 @@ class Module(common.SEDCreationModule): ...@@ -261,9 +261,6 @@ class Module(common.SEDCreationModule):
""" """
# Base name for adding information to the SED.
name = self.name or 'dustatt_calzleit_'
wavelength = sed.wavelength_grid wavelength = sed.wavelength_grid
ebvs_young = float(self.parameters["E_BVs_young"]) ebvs_young = float(self.parameters["E_BVs_young"])
ebvs_old = float(self.parameters["E_BVs_old_factor"]) * ebvs_young ebvs_old = float(self.parameters["E_BVs_old_factor"]) * ebvs_young
...@@ -298,10 +295,11 @@ class Module(common.SEDCreationModule): ...@@ -298,10 +295,11 @@ class Module(common.SEDCreationModule):
# spectrum is negative). # spectrum is negative).
attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength) attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_module(name, self.parameters) sed.add_module(self.name, self.parameters)
sed.add_info(name + "_E_BVs_young", ebvs_young) sed.add_info("E_BVs_young" + self.postfix, ebvs_young)
sed.add_info(name + "_attenuation_young", attenuation_young) sed.add_info("attenuation_young" + self.postfix, attenuation_young)
sed.add_contribution(name + "_young", wavelength, attenuation_spectrum) sed.add_contribution("attenuation_young" + self.postfix,
wavelength, attenuation_spectrum)
# Old population (if any) attenuation # Old population (if any) attenuation
if old_contrib: if old_contrib:
...@@ -313,11 +311,11 @@ class Module(common.SEDCreationModule): ...@@ -313,11 +311,11 @@ class Module(common.SEDCreationModule):
attenuation_spectrum = attenuated_luminosity - luminosity attenuation_spectrum = attenuated_luminosity - luminosity
attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength) attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_info(name + "_E_BVs_old", ebvs_old) sed.add_info("E_BVs_old" + self.postfix, ebvs_old)
sed.add_info(name + "_E_BVs_old_factor", sed.add_info("E_BVs_old_factor" + self.postfix,
self.parameters["E_BVs_old_factor"]) self.parameters["E_BVs_old_factor"])
sed.add_info(name + "_attenuation_old", attenuation_old) sed.add_info("attenuation_old" + self.postfix, attenuation_old)
sed.add_contribution(name + "_old", sed.add_contribution("attenuation_old" + self.postfix,
wavelength, attenuation_spectrum) wavelength, attenuation_spectrum)
else: else:
attenuation_old = 0 attenuation_old = 0
...@@ -338,7 +336,7 @@ class Module(common.SEDCreationModule): ...@@ -338,7 +336,7 @@ class Module(common.SEDCreationModule):
# Total attenuation (we don't take into account the energy attenuated # Total attenuation (we don't take into account the energy attenuated
# in the spectral lines) # in the spectral lines)
sed.add_info(name + "_attenuation", sed.add_info("attenuation" + self.postfix,
attenuation_young + attenuation_old) attenuation_young + attenuation_old)
# Fλ fluxes (only from continuum) in each filter after attenuation. # Fλ fluxes (only from continuum) in each filter after attenuation.
...@@ -351,6 +349,6 @@ class Module(common.SEDCreationModule): ...@@ -351,6 +349,6 @@ class Module(common.SEDCreationModule):
# Attenuation in each filter # Attenuation in each filter
for filter_name in filters: for filter_name in filters:
sed.add_info(name + "_" + filter_name, sed.add_info(filter_name + "_attenuation" + self.postfix,
-2.5 * np.log(flux_att[filter_name] / -2.5 * np.log(flux_att[filter_name] /
flux_noatt[filter_name])) flux_noatt[filter_name]))
...@@ -150,21 +150,21 @@ class Module(common.SEDCreationModule): ...@@ -150,21 +150,21 @@ class Module(common.SEDCreationModule):
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = OrderedDict([
("NAME_Av_young", "V-band attenuation of the young population."), ("Av_young", "V-band attenuation of the young population."),
("NAME_Av_old", "V-band attenuation of the old population."), ("Av_old", "V-band attenuation of the old population."),
("NAME_attenuation_young", "Amount of luminosity attenuated from the " ("attenuation_young", "Amount of luminosity attenuated from the "
"young population in W."), "young population in W."),
("NAME_Av_old_factor", "Reduction factor for the V-band attenuation " ("Av_old_factor", "Reduction factor for the V-band attenuation "
"of the old population compared to the young " "of the old population compared to the young "
"one (<1)."), "one (<1)."),
("NAME_attenuation_old", "Amount of luminosity attenuated from the " ("attenuation_old", "Amount of luminosity attenuated from the "
"old population in W."), "old population in W."),
("NAME_attenuation", "Total amount of luminosity attenuated in W."), ("attenuation", "Total amount of luminosity attenuated in W."),
("NAME_uv_bump_wavelength", "Central wavelength of UV bump in nm."), ("uv_bump_wavelength", "Central wavelength of UV bump in nm."),
("NAME_uv_bump_width", "Width of the UV bump in nm."), ("uv_bump_width", "Width of the UV bump in nm."),
("NAME_uv_bump_amplitude", "Amplitude of the UV bump in nm."), ("uv_bump_amplitude", "Amplitude of the UV bump in nm."),
("NAME_powerlaw_slope", "Slope of the power law."), ("powerlaw_slope", "Slope of the power law."),
("NAME_FILTER", "Attenuation in the FILTER filter.") ("FILTER", "Attenuation in the FILTER filter.")
]) ])
def _init_code(self): def _init_code(self):
...@@ -186,9 +186,6 @@ class Module(common.SEDCreationModule): ...@@ -186,9 +186,6 @@ class Module(common.SEDCreationModule):
""" """
# Base name for adding information to the SED.
name = self.name or 'dustatt_powerlaw_'
wavelength = sed.wavelength_grid wavelength = sed.wavelength_grid
av_young = float(self.parameters["Av_young"]) av_young = float(self.parameters["Av_young"])
av_old = float(self.parameters["Av_old_factor"] * av_young) av_old = float(self.parameters["Av_old_factor"] * av_young)
...@@ -222,10 +219,11 @@ class Module(common.SEDCreationModule): ...@@ -222,10 +219,11 @@ class Module(common.SEDCreationModule):
# spectrum is negative). # spectrum is negative).
attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength) attenuation_young = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_module(name, self.parameters) sed.add_module(self.name, self.parameters)
sed.add_info(name + "_Av_young", av_young) sed.add_info("Av_young" + self.postfix, av_young)
sed.add_info(name + "_attenuation_young", attenuation_young) sed.add_info("attenuation_young" + self.postfix, attenuation_young)
sed.add_contribution(name + "_young", wavelength, attenuation_spectrum) sed.add_contribution("attenuation_young" + self.postfix, wavelength,
attenuation_spectrum)
# Old population (if any) attenuation # Old population (if any) attenuation
if old_contrib: if old_contrib:
...@@ -236,11 +234,11 @@ class Module(common.SEDCreationModule): ...@@ -236,11 +234,11 @@ class Module(common.SEDCreationModule):
attenuation_spectrum = attenuated_luminosity - luminosity attenuation_spectrum = attenuated_luminosity - luminosity
attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength) attenuation_old = -1 * np.trapz(attenuation_spectrum, wavelength)
sed.add_info(name + "_Av_old", av_old) sed.add_info("Av_old" + self.postfix, av_old)
sed.add_info(name + "_Av_old_factor", sed.add_info("Av_old_factor" + self.postfix,
self.parameters["Av_old_factor"]) self.parameters["Av_old_factor"])
sed.add_info(name + "_attenuation_old", attenuation_old) sed.add_info("attenuation_old" + self.postfix, attenuation_old)
sed.add_contribution(name + "_old", sed.add_contribution("attnuation_old" + self.postfix,
wavelength, attenuation_spectrum) wavelength, attenuation_spectrum)
else: else:
attenuation_old = 0 attenuation_old = 0
...@@ -261,7 +259,7 @@ class Module(common.SEDCreationModule): ...@@ -261,7 +259,7 @@ class Module(common.SEDCreationModule):
# Total attenuation (we don't take into account the energy attenuated # Total attenuation (we don't take into account the energy attenuated
# in the spectral lines) # in the spectral lines)
sed.add_info(name + "_attenuation", sed.add_info("attenuation" + self.postfix,
attenuation_young + attenuation_old) attenuation_young + attenuation_old)
# Fλ fluxes (only in continuum) in each filter after attenuation. # Fλ fluxes (only in continuum) in each filter after attenuation.
...@@ -274,6 +272,6 @@ class Module(common.SEDCreationModule): ...@@ -274,6 +272,6 @@ class Module(common.SEDCreationModule):
# Attenuation in each filter # Attenuation in each filter
for filter_name in filters: for filter_name in filters:
sed.add_info(name + "_" + filter_name, sed.add_info(filter_name + "_attenuation" + self.postfix,
-2.5 * np.log(flux_att[filter_name] / -2.5 * np.log(flux_att[filter_name] /
flux_noatt[filter_name])) flux_noatt[filter_name]))
...@@ -80,16 +80,13 @@ class Module(common.SEDCreationModule): ...@@ -80,16 +80,13 @@ class Module(common.SEDCreationModule):
igm_effect = red_l_lambda - init_l_lambda igm_effect = red_l_lambda - init_l_lambda
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'igmattenuation'
sed.add_module(name, self.parameters) sed.add_info("redshift" + self.postfix, self.parameters['redshift'])
sed.add_info('rtau' + self.postfix, self.parameters['rtau'])
sed.add_info(name + '_redshift', self.parameters['redshift'])
sed.add_info(name + '_rtau', self.parameters['rtau'])
sed.add_contribution( sed.add_contribution(
name, self.name,
new_wavelen, new_wavelen,
igm_effect igm_effect
) )
...@@ -47,13 +47,10 @@ class Module(common.SEDCreationModule): ...@@ -47,13 +47,10 @@ class Module(common.SEDCreationModule):
filename = self.parameters['filename'] filename = self.parameters['filename']
table = atpy.Table(filename, verbose=False) table = atpy.Table(filename, verbose=False)
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'loadfile'
sed.add_module(name, self.parameters)
sed.add_contribution( sed.add_contribution(
name + '_' + filename, filename,
table[self.parameters['lambda_column']], table[self.parameters['lambda_column']],
table[self.parameters['l_lambda_column']] table[self.parameters['l_lambda_column']]
) )
...@@ -145,42 +145,56 @@ class Module(common.SEDCreationModule): ...@@ -145,42 +145,56 @@ class Module(common.SEDCreationModule):
# Average SFR on the last AV_LAPSE Myr of its history # Average SFR on the last AV_LAPSE Myr of its history
average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE]) average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE])
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'm2005_sfh'
sed.add_info('ssp_imf' + self.postfix, imf)
sed.add_module(name, self.parameters) sed.add_info('ssp_metallicity' + self.postfix, metallicity)
sed.add_info('ssp_old_young_separation_age' + self.postfix,
sed.add_info('imf', imf) separation_age)
sed.add_info('metallicity', metallicity)
sed.add_info('old_young_separation_age', separation_age) sed.add_info('sfr' + self.postfix, sfr, True)
sed.add_info('average_sfr' + self.postfix, average_sfr, True)
sed.add_info('sfr', sfr, True)
sed.add_info('average_sfr', average_sfr, True) 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('mass_total_old', old_masses[0], True) sed.add_info('ssp_mass_white_dwarf_old' + self.postfix, old_masses[2],
sed.add_info('mass_alive_old', old_masses[1], True) True)
sed.add_info('mass_white_dwarf_old', old_masses[2], True) sed.add_info('ssp_mass_neutrino_old' + self.postfix, old_masses[3],
sed.add_info('mass_neutrino_old', old_masses[3], True) True)
sed.add_info('mass_black_hole_old', old_masses[4], True) sed.add_info('ssp_mass_black_hole_old' + self.postfix, old_masses[4],
sed.add_info('mass_turn_off_old', old_masses[5], True) True)
sed.add_info('ssp_mass_turn_off_old' + self.postfix, old_masses[5],
sed.add_info('mass_total_young', young_masses[0], True) True)
sed.add_info('mass_alive_young', young_masses[1], True)
sed.add_info('mass_white_dwarf_young', young_masses[2], True) sed.add_info('ssp_mass_total_young' + self.postfix, young_masses[0],
sed.add_info('mass_neutrino_young', young_masses[3], True) True)
sed.add_info('mass_black_hole_young', young_masses[4], True) sed.add_info('ssp_mass_alive_young' + self.postfix, young_masses[1],
sed.add_info('mass_turn_off_young', young_masses[5], True) True)
sed.add_info('ssp_mass_white_dwarf_young' + self.postfix,
sed.add_info('mass_total', old_masses[0] + young_masses[0], True) young_masses[2], True)
sed.add_info('mass_alive', old_masses[1] + young_masses[1], True) sed.add_info('ssp_mass_neutrino_young' + self.postfix, young_masses[3],
sed.add_info('mass_white_dwarf', old_masses[2] + young_masses[2], True) True)
sed.add_info('mass_neutrino', old_masses[3] + young_masses[3], True) sed.add_info('ssp_mass_black_hole_young' + self.postfix,
sed.add_info('mass_black_hole', old_masses[4] + young_masses[4], True) young_masses[4], True)
sed.add_info('mass_turn_off', old_masses[5] + young_masses[5], True) sed.add_info('ssp_mass_turn_off_young' + self.postfix, young_masses[5],
True)
sed.add_contribution(name + '_old',
sed.add_info('ssp_mass_total' + self.postfix,
old_masses[0] + young_masses[0], True)
sed.add_info('ssp_mass_alive' + self.postfix,
old_masses[1] + young_masses[1], True)
sed.add_info('ssp_mass_white_dwarf' + self.postfix,
old_masses[2] + young_masses[2], True)
sed.add_info('ssp_mass_neutrino' + self.postfix,
old_masses[3] + young_masses[3], True)
sed.add_info('ssp_mass_black_hole' + self.postfix,
old_masses[4] + young_masses[4], True)
sed.add_info('ssp_mass_turn_off' + self.postfix,
old_masses[5] + young_masses[5], True)
sed.add_contribution("ssp_old" + self.postfix,
ssp.wavelength_grid, ssp.wavelength_grid,
old_spectrum) old_spectrum)
sed.add_contribution(name + '_young', sed.add_contribution("ssp_young" + self.postfix,
ssp.wavelength_grid, ssp.wavelength_grid,
young_spectrum) young_spectrum)
...@@ -99,15 +99,12 @@ class Module(common.SEDCreationModule): ...@@ -99,15 +99,12 @@ class Module(common.SEDCreationModule):
# We normalise the SFH to have one solar mass produced. # We normalise the SFH to have one solar mass produced.
sfr = sfr / np.trapz(sfr * 1.e6, time_grid) sfr = sfr / np.trapz(sfr * 1.e6, time_grid)
# Base name for adding information to the SED.
name = self.name or "sfh2exp"
sed.add_module(name, self.parameters) sed.add_module(name, self.parameters)
# Add the sfh and the output parameters to the SED. # Add the sfh and the output parameters to the SED.
sed.sfh = (time_grid, sfr) sed.sfh = (time_grid, sfr)
sed.add_info(name + "_tau_main", tau_main) sed.add_info("sfh_tau_main" + self.postfix, tau_main)
sed.add_info(name + "_tau_burst", tau_burst) sed.add_info("sfh_tau_burst" + self.postfix, tau_burst)
sed.add_info(name + "_f_burst", f_burst) sed.add_info("sfh_f_burst" + self.postfix, f_burst)
sed.add_info(name + "_age", age) sed.add_info("sfh_age" + self.postfix, age)
sed.add_info(name + "_burst_age", burst_age) sed.add_info("sfh_burst_age" + self.postfix, burst_age)
...@@ -70,10 +70,7 @@ class Module(common.SEDCreationModule): ...@@ -70,10 +70,7 @@ class Module(common.SEDCreationModule):
# The we normalise it to 1 solar mass produced. # The we normalise it to 1 solar mass produced.
sfr = sfr / np.trapz(sfr * 1.e6, time_grid) sfr = sfr / np.trapz(sfr * 1.e6, time_grid)
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'loadfile'
sed.add_module(name, self.parameters)
sed.sfh = (time_grid, sfr)