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

Homogenise the bc03 and m2005 sed modules, mainly making variable names consistent.

parent c6e3bd6f
......@@ -26,6 +26,7 @@ class BC03(SedModule):
This SED creation module convolves the SED star formation history with a
Bruzual and Charlot (2003) single stellar population to add a stellar
component to the SED.
"""
parameter_list = OrderedDict([
......@@ -75,21 +76,21 @@ class BC03(SedModule):
"""
# First, we process the young population (age lower than the
# separation age.)
young_lumin, young_info = self.ssp.convolve(
spec_young, info_young = self.ssp.convolve(
sed.sfh[-self.separation_age:])
# Then, we process the old population. If the SFH is shorter than the
# separation age then all the arrays will consist only of 0.
old_sfh = np.copy(sed.sfh)
old_sfh[-self.separation_age:] = 0.
old_lumin, old_info = self.ssp.convolve(old_sfh)
spec_old, info_old = self.ssp.convolve(old_sfh)
# We compute the Lyman continuum luminosity as it is important to
# compute the energy absorbed by the dust before ionising gas.
wave = self.ssp.wavelength_grid
w = np.where(wave <= 91.1)
lum_ly_young = np.trapz(young_lumin[w], wave[w])
lum_ly_old = np.trapz(old_lumin[w], wave[w])
lum_lyc_young = np.trapz(spec_young[w], wave[w])
lum_lyc_old = np.trapz(spec_old[w], wave[w])
sed.add_module(self.name, self.parameters)
......@@ -97,33 +98,31 @@ class BC03(SedModule):
sed.add_info("stellar.metallicity", self.metallicity)
sed.add_info("stellar.old_young_separation_age", self.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"], True)
sed.add_info("stellar.lum_ly_young", lum_ly_young, True)
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"], True)
sed.add_info("stellar.lum_ly_old", lum_ly_old, True)
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_info("stellar.m_star_young", info_young["m_star"], True)
sed.add_info("stellar.m_gas_young", info_young["m_gas"], True)
sed.add_info("stellar.n_ly_young", info_young["n_ly"], True)
sed.add_info("stellar.lum_ly_young", lum_lyc_young, True)
sed.add_info("stellar.b_400_young", info_young["b_4000"])
sed.add_info("stellar.b4_vn_young", info_young["b4_vn"])
sed.add_info("stellar.b4_sdss_young", info_young["b4_sdss"])
sed.add_info("stellar.b_912_young", info_young["b_912"])
sed.add_info("stellar.m_star_old", info_old["m_star"], True)
sed.add_info("stellar.m_gas_old", info_old["m_gas"], True)
sed.add_info("stellar.n_ly_old", info_old["n_ly"], True)
sed.add_info("stellar.lum_ly_old", lum_lyc_old, True)
sed.add_info("stellar.b_400_old", info_old["b_4000"])
sed.add_info("stellar.b4_vn_old", info_old["b4_vn"])
sed.add_info("stellar.b4_sdss_old", info_old["b4_sdss"])
sed.add_info("stellar.b_912_old", info_old["b_912"])
sed.add_info("stellar.m_star",
young_info["m_star"] + old_info["m_star"],
True)
info_young["m_star"] + info_old["m_star"], True)
sed.add_info("stellar.m_gas",
young_info["m_gas"] + old_info["m_gas"],
True)
info_young["m_gas"] + info_old["m_gas"], True)
sed.add_contribution("stellar.old", wave, old_lumin)
sed.add_contribution("stellar.young", wave, young_lumin)
sed.add_contribution("stellar.old", wave, spec_old)
sed.add_contribution("stellar.young", wave, spec_young)
# SedModule to be returned by get_module
Module = BC03
......@@ -26,19 +26,6 @@ class M2005(SedModule):
a Maraston (2005) single stellar population to add a stellar component to
the SED.
Information added to the SED:
- imf, metallicity, galaxy_age
- mass_total, mass_alive, mass_white_dwarf,mass_neutron,
mass_black_hole: stellar masses in solar mass.
- age: age of the oldest stars in the galaxy.
- old_young_separation_age: age (in Myr) separating the young and the
old star populations (if 0, there is only one population)
- mass_total_old, mass_alive_old, mass_white_dwarf_old,
mass_neutron_old, mass_black_hole_old, : old star population masses.
- mass_total_young, mass_alive_young, mass_white_dwarf_young,
mass_neutron_young, mass_black_hole_young: young star population
masses.
"""
parameter_list = OrderedDict([
......@@ -87,14 +74,14 @@ class M2005(SedModule):
"""
# First, we process the young population (age lower than the
# separation age.)
young_masses, young_spectrum = self.ssp.convolve(
info_young, spec_young = self.ssp.convolve(
sed.sfh[-self.separation_age:])
# Then, we process the old population. If the SFH is shorter than the
# separation age then all the arrays will consist only of 0.
old_sfh = np.copy(sed.sfh)
old_sfh[-self.separation_age:] = 0.
old_masses, old_spectrum = self.ssp.convolve(old_sfh)
info_old, spec_old = self.ssp.convolve(old_sfh)
sed.add_module(self.name, self.parameters)
......@@ -102,35 +89,29 @@ class M2005(SedModule):
sed.add_info('stellar.metallicity', self.metallicity)
sed.add_info('stellar.old_young_separation_age', self.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_neutron_old', old_masses[3], True)
sed.add_info('stellar.mass_black_hole_old', old_masses[4], 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_neutron_young', young_masses[3], True)
sed.add_info('stellar.mass_black_hole_young', young_masses[4], True)
sed.add_info('stellar.mass_total',
old_masses[0] + young_masses[0], True)
sed.add_info('stellar.mass_alive',
old_masses[1] + young_masses[1], True)
sed.add_info('stellar.mass_white_dwarf',
old_masses[2] + young_masses[2], True)
sed.add_info('stellar.mass_neutron',
old_masses[3] + young_masses[3], True)
sed.add_info('stellar.mass_black_hole',
old_masses[4] + young_masses[4], True)
sed.add_contribution("stellar.old",
self.ssp.wavelength_grid,
old_spectrum)
sed.add_contribution("stellar.young",
self.ssp.wavelength_grid,
young_spectrum)
sed.add_info('stellar.mass_total_old', info_old[0], True)
sed.add_info('stellar.mass_alive_old', info_old[1], True)
sed.add_info('stellar.mass_white_dwarf_old', info_old[2], True)
sed.add_info('stellar.mass_neutron_old', info_old[3], True)
sed.add_info('stellar.mass_black_hole_old', info_old[4], True)
sed.add_info('stellar.mass_total_young', info_young[0], True)
sed.add_info('stellar.mass_alive_young', info_young[1], True)
sed.add_info('stellar.mass_white_dwarf_young', info_young[2], True)
sed.add_info('stellar.mass_neutron_young', info_young[3], True)
sed.add_info('stellar.mass_black_hole_young', info_young[4], True)
sed.add_info('stellar.mass_total', info_old[0] + info_young[0], True)
sed.add_info('stellar.mass_alive', info_old[1] + info_young[1], True)
sed.add_info('stellar.mass_white_dwarf', info_old[2] + info_young[2],
True)
sed.add_info('stellar.mass_neutron', info_old[3] + info_young[3], True)
sed.add_info('stellar.mass_black_hole', info_old[4] + info_young[4],
True)
sed.add_contribution("stellar.old", self.ssp.wavelength_grid, spec_old)
sed.add_contribution("stellar.young", self.ssp.wavelength_grid,
spec_young)
# SedModule to be returned by get_module
Module = M2005
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