diff --git a/pcigale/sed/__init__.py b/pcigale/sed/__init__.py index f4ddf66a3e9c168659e0fb5e47b048b591dd9463..df2e3e1c92649a5dcd44eb87fc09ee3c97fdbad8 100644 --- a/pcigale/sed/__init__.py +++ b/pcigale/sed/__init__.py @@ -41,6 +41,11 @@ from . import utils from scipy.constants import c from scipy.interpolate import interp1d +# 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 +# number of parameters. The value is in Myr. +AV_LAPSE = 100 + class SED(object): """Spectral Energy Distribution with associated information @@ -79,6 +84,15 @@ class SED(object): def sfh(self, value): self._sfh = value + if value: + sfh_time, sfh_sfr = value + sfh_age = np.max(sfh_time) - sfh_time + self._sfh = value + self.add_info("sfr", sfh_sfr[-1], True, True) + self.add_info("average_sfr", np.mean(sfh_sfr[sfh_age <= AV_LAPSE]), + True, True) + self.add_info("age", np.max(sfh_time), True, True) + @property def wavelength_grid(self): """ Return a copy of the wavelength grid diff --git a/pcigale/sed/modules/bc03.py b/pcigale/sed/modules/bc03.py index de604c9e5dd8d1585d5eb2553dfa27dd2dbba75d..733f30926a63d7448c2e4efa19da9de1a0a115b4 100644 --- a/pcigale/sed/modules/bc03.py +++ b/pcigale/sed/modules/bc03.py @@ -9,12 +9,6 @@ from . import common from ...data import Database -# 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 -# number of parameters. The value is in Myr. -AV_LAPSE = 100 - - class Module(common.SEDCreationModule): """Module computing the Star Formation History contribution bases on the Bruzual and Charlot (2003) models. @@ -95,12 +89,6 @@ class Module(common.SEDCreationModule): old_sfh[sfh_age <= separation_age] = 0 old_wave, old_lumin, old_info = ssp.convolve(sfh_time, old_sfh) - # SFR of the galaxy - sfr = sfh_sfr[len(sfh_sfr) - 1] - - # Average SFR on the last AV_LAPSE Myr of its history - average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE]) - sed.add_module(self.name, self.parameters) sed.add_info("ssp_imf" + self.postfix, imf) @@ -108,9 +96,6 @@ class Module(common.SEDCreationModule): sed.add_info("ssp_old_young_separation_age" + self.postfix, separation_age) - sed.add_info("sfr" + self.postfix, sfr, True) - sed.add_info("average_sfr" + self.postfix, average_sfr, True) - sed.add_info("ssp_m_star_young" + self.postfix, young_info["m_star"], True) sed.add_info("ssp_m_gas_young" + self.postfix, diff --git a/pcigale/sed/modules/m2005.py b/pcigale/sed/modules/m2005.py index 92d6f8efa07875a36b02a477317cae0da0458be2..de9905c73d96f137b29bbc5e0e5b6dd362a7bfdd 100644 --- a/pcigale/sed/modules/m2005.py +++ b/pcigale/sed/modules/m2005.py @@ -8,11 +8,6 @@ from collections import OrderedDict from . import common from ...data import Database -# 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 -# number of parameters. The value is in Myr. -AV_LAPSE = 100 - class Module(common.SEDCreationModule): """Module computing the Star Formation History contribution based on the @@ -23,9 +18,6 @@ class Module(common.SEDCreationModule): Information added to the SED: - imf, metallicity, galaxy_age - - sfr: star formation rate normalised to 1 solar mass formed at the - age of the galaxy. - - average_sfr: SFR averaged on the last 100 Myr of the galaxy history - mass_total, mass_alive, mass_white_dwarf,mass_neutrino, mass_black_hole, mass_turn_off : stellar masses in solar mass. - age: age of the oldest stars in the galaxy. @@ -139,12 +131,6 @@ class Module(common.SEDCreationModule): old_sfh[sfh_age <= separation_age] = 0 old_masses, old_spectrum = ssp.convolve(sfh_time, old_sfh) - # SFR of the galaxy - sfr = sfh_sfr[len(sfh_sfr) - 1] - - # Average SFR on the last AV_LAPSE Myr of its history - average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE]) - sed.add_module(self.name, self.parameters) sed.add_info('ssp_imf' + self.postfix, imf) @@ -152,9 +138,6 @@ class Module(common.SEDCreationModule): sed.add_info('ssp_old_young_separation_age' + self.postfix, separation_age) - sed.add_info('sfr' + self.postfix, sfr, True) - sed.add_info('average_sfr' + self.postfix, 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('ssp_mass_white_dwarf_old' + self.postfix, old_masses[2], diff --git a/pcigale/sed/modules/sfh2exp.py b/pcigale/sed/modules/sfh2exp.py index b07b208e9d22d1af28be133fb4f6b959491a226a..ce21791121a7df37d417fcba585a278ea15f2ed2 100644 --- a/pcigale/sed/modules/sfh2exp.py +++ b/pcigale/sed/modules/sfh2exp.py @@ -106,5 +106,4 @@ class Module(common.SEDCreationModule): sed.add_info("sfh_tau_main" + self.postfix, tau_main) sed.add_info("sfh_tau_burst" + self.postfix, tau_burst) sed.add_info("sfh_f_burst" + self.postfix, f_burst) - sed.add_info("sfh_age" + self.postfix, age) sed.add_info("sfh_burst_age" + self.postfix, burst_age) diff --git a/pcigale/sed/modules/sfhfromfile.py b/pcigale/sed/modules/sfhfromfile.py index 91aa9372693b18d630da039ad58dd04f8d837a36..3d77d84e4cd303676876af09ea5086da523f5346 100644 --- a/pcigale/sed/modules/sfhfromfile.py +++ b/pcigale/sed/modules/sfhfromfile.py @@ -72,5 +72,4 @@ class Module(common.SEDCreationModule): sed.add_module(self.name, self.parameters) sed.sfh = (time_grid, sfr) - sed.add_info("age", age) sed.add_info("sfh_id" + self.postfix, sfr_column_name)