Commit 2311afd4 authored by Médéric Boquien's avatar Médéric Boquien

Implement the computation of the mass-weighted age for the bc03 and m2005...

Implement the computation of the mass-weighted age for the bc03 and m2005 module. This is done in the corresponding convolve() functions. The information is returned in a new variable called info_all, which also contains all the information when the entire SFH is included (rather than separating old and young populations).
parent 48ce09d3
......@@ -2,6 +2,8 @@
## Unreleased
### Added
- The stellar mass-weighted age is now provided. This is a much more usual measure of the age than the age of the oldest star. This is accessible with the `stellar.age_m_star` keyword in the `bc03` module with with the `stellar.age_mass` keyword in the `m2005` module. (Médéric Boquien)
### Changed
- We do not output the break strength from the `bc03` module anymore as these were not computed properly. (Médéric Boquien)
......
......@@ -93,6 +93,9 @@ class BC03(object):
* "n_ly": rate of H-ionizing photons (s-1)
info_old : dictionary
Same as info_young but for the old stellar populations.
info_all: dictionary
Same as info_young but for the entire stellar population. Also
contains "age_mass", the stellar mass-weighted age
"""
# We cut the SSP to the maximum age considered to simplify the
......@@ -116,7 +119,13 @@ class BC03(object):
spec_old = 1e6 * np.dot(spec_table[:, separation_age:],
sfh[:-separation_age][::-1])
info_all = info_young + info_old
info_young = dict(zip(["m_star", "m_gas", "n_ly"], info_young))
info_old = dict(zip(["m_star", "m_gas", "n_ly"], info_old))
info_all = dict(zip(["m_star", "m_gas", "n_ly"], info_all))
info_all['age_mass'] = np.average(self.time_grid[:sfh.size],
weights=info_table[0, :] * sfh[::-1])
return spec_young, spec_old, info_young, info_old
return spec_young, spec_old, info_young, info_old, info_all
......@@ -89,11 +89,14 @@ class M2005(object):
* 4: black holes mass
info_old: array of floats
Same as info_young but for the old stellar populations.
info_all: array of floats
Same as info_young but for the entire stellar population. Also
contains 5: stellar mass-weighted age
"""
# We cut the SSP to the maximum age considered to simplify the
# computation.
info_table = self.info_table[:, :sfh.size]
info_table = self.info_table[:5, :sfh.size]
spec_table = self.spec_table[:, :sfh.size]
# As both the SFH and the SSP (limited to the age of the SFH) data now
......@@ -111,4 +114,9 @@ class M2005(object):
spec_old = 1e6 * np.dot(spec_table[:, separation_age:],
sfh[:-separation_age][::-1])
return spec_young, spec_old, info_young, info_old
info_all = info_young + info_old
info_all = np.append(info_all, np.average(self.time_grid[:sfh.size],
weights=info_table[1, :] *
sfh[::-1]))
return spec_young, spec_old, info_young, info_old, info_all
......@@ -74,8 +74,8 @@ class BC03(SedModule):
SED object.
"""
spec_young, spec_old, info_young, info_old = self.ssp.convolve(sed.sfh,
self.separation_age)
out = self.ssp.convolve(sed.sfh, self.separation_age)
spec_young, spec_old, info_young, info_old, info_all = out
# We compute the Lyman continuum luminosity as it is important to
# compute the energy absorbed by the dust before ionising gas.
......@@ -100,10 +100,11 @@ class BC03(SedModule):
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.m_star",
info_young["m_star"] + info_old["m_star"], True)
sed.add_info("stellar.m_gas",
info_young["m_gas"] + info_old["m_gas"], True)
sed.add_info("stellar.m_star", info_all["m_star"], True)
sed.add_info("stellar.m_gas", info_all["m_gas"], True)
sed.add_info("stellar.n_ly", info_all["n_ly"], True)
sed.add_info("stellar.lum_ly", lum_lyc_young + lum_lyc_old, True)
sed.add_info("stellar.age_m_star", info_all["age_mass"])
sed.add_contribution("stellar.old", wave, spec_old)
sed.add_contribution("stellar.young", wave, spec_young)
......
......@@ -72,8 +72,8 @@ class M2005(SedModule):
SED object.
"""
spec_young, spec_old, info_young, info_old = self.ssp.convolve(sed.sfh,
self.separation_age)
out = self.ssp.convolve(sed.sfh, self.separation_age)
spec_young, spec_old, info_young, info_old, info_all = out
sed.add_module(self.name, self.parameters)
......@@ -93,13 +93,12 @@ class M2005(SedModule):
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', info_young[0] + info_old[0], True)
sed.add_info('stellar.mass_alive', info_young[1] + info_old[1], True)
sed.add_info('stellar.mass_white_dwarf', info_young[2] + info_old[2],
True)
sed.add_info('stellar.mass_neutron', info_young[3] + info_old[3], True)
sed.add_info('stellar.mass_black_hole', info_young[4] + info_old[4],
True)
sed.add_info('stellar.mass_total', info_all[0], True)
sed.add_info('stellar.mass_alive', info_all[1], True)
sed.add_info('stellar.mass_white_dwarf', info_all[2], True)
sed.add_info('stellar.mass_neutron', info_all[3], True)
sed.add_info('stellar.mass_black_hole', info_all[4], True)
sed.add_info('stellar.age_mass', info_all[5])
sed.add_contribution("stellar.old", self.ssp.wavelength_grid, spec_old)
sed.add_contribution("stellar.young", self.ssp.wavelength_grid,
......
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