Commit 5a86f3b0 authored by Yannick Roehlly's avatar Yannick Roehlly

Compute age, SFR and average SFR when setting the SFH of the galaxy

parent c7072d8b
......@@ -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
......
......@@ -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,
......
......@@ -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],
......
......@@ -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)
......@@ -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)
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