diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eccd5dd4df19c996bd62fbe068a3def3e62fa58..a047f2ee68a1f1faea8db5090ede3072eb679d0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/pcigale/data/bc03.py b/pcigale/data/bc03.py index ce2894cbbf578c58fd179e47d114e862d219a349..26d1dd47977ff28f1ec73ff60bb4f40aa4c499e7 100644 --- a/pcigale/data/bc03.py +++ b/pcigale/data/bc03.py @@ -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 diff --git a/pcigale/data/m2005.py b/pcigale/data/m2005.py index b296aff4576fe6c235448a2036a3fa178ab79b35..384de08bb033356d8bda1d2075c9ad6ba361888d 100644 --- a/pcigale/data/m2005.py +++ b/pcigale/data/m2005.py @@ -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 diff --git a/pcigale/sed_modules/bc03.py b/pcigale/sed_modules/bc03.py index dbd582d477eeeeb5987260db7361a727685ed5a4..c06f9dad320c02fd88f9b2ca0512c74940f82ac6 100644 --- a/pcigale/sed_modules/bc03.py +++ b/pcigale/sed_modules/bc03.py @@ -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) diff --git a/pcigale/sed_modules/m2005.py b/pcigale/sed_modules/m2005.py index 5872a66fc83382cca3048bbfcbd038cec68beb08..d8be9d8a4b4b484083d6ff70f0a5c7ed19db81ce 100644 --- a/pcigale/sed_modules/m2005.py +++ b/pcigale/sed_modules/m2005.py @@ -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,