sfhdelayed.py 2.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (C) 2013 Centre de données Astrophysiques de Marseille
# Copyright (C) 2014 Laboratoire d'Astrophysique de Marseille
# Copyright (C) 2014 University of Cambridge
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Yannick Roehlly, Véronique Buat & Médéric Boquien

"""
Delayed tau model for star formation history
============================================

This module implements a star formation history (SFH) described as a delayed
rise of the SFR up to a maximum, followed by an exponential decrease.

"""

import numpy as np
from . import CreationModule

# Time lapse used in the age grid in Myr. If should be consistent with the
# time lapse in the SSP modules.
AGE_LAPSE = 1


class SFHDelayed(CreationModule):
    """Delayed tau model for Star Formation History

    This module sets the SED star formation history (SFH) proportional to time,
    with a declining exponential parametrised with a time-scale (tau_main).

    """

32
    parameter_list = dict([
33
34
35
36
37
38
39
40
41
42
        ("tau_main", (
            "float",
            "e-folding time of the main stellar population model in Myr.",
            None
        )),
        ("age", (
            "integer",
            "Age of the oldest stars in the galaxy in Myr. The precision "
            "is 1 Myr.",
            None
Denis's avatar
Denis committed
43
        )),
Médéric Boquien's avatar
Médéric Boquien committed
44
        ("sfr_A", (
45
46
47
48
49
50
51
            "float",
            "Multiplicative factor controlling the amplitude of SFR.",
            1.
        )),
        ("normalise", (
            "boolean",
            "Normalise the SFH to produce one solar mass.",
Denis's avatar
Denis committed
52
            "True"
53
        ))
Médéric Boquien's avatar
Médéric Boquien committed
54
    ])
55

56
    out_parameter_list = dict([
57
58
        ("tau_main", "e-folding time of the main stellar population model "
                     "in Myr."),
Denis's avatar
Denis committed
59
        ("age", "Age of the oldest stars in the galaxy in Myr."),
60
        ("sfr_A", "Multiplicative factor controlling the amplitude of SFR.")
61
62
63
64
65
66
67
68
69
70
71
    ])

    def process(self, sed):
        """
        Parameters
        ----------
        sed : pcigale.sed.SED object

        """
        tau_main = float(self.parameters["tau_main"])
        age = int(self.parameters["age"])
72
73
        sfr_A = int(self.parameters["sfr_A"])
        normalise = (self.parameters["normalise"].lower() == "true")
74
75
76
77
78

        # Time grid and age. If needed, the age is rounded to the inferior Myr
        time_grid = np.arange(AGE_LAPSE, age + AGE_LAPSE, AGE_LAPSE)

        # Main SFR
79
        sfr = sfr_A * time_grid / tau_main**2 * np.exp(-time_grid / tau_main)
80

81
82
83
        # Compute the galaxy mass and normalise the SFH to 1 solar mass
        # produced if asked to.
        galaxy_mass = np.trapz(sfr * 1e6, time_grid)
84
        if normalise:
85
86
            sfr = sfr / galaxy_mass
            galaxy_mass = 1.
87
88
89
90
91

        sed.add_module(self.name, self.parameters)

        # Add the sfh and the output parameters to the SED.
        sed.sfh = (time_grid, sfr)
92
        sed.add_info("galaxy_mass", galaxy_mass, True)
93
94
95
96
        sed.add_info("sfh.tau_main", tau_main)

# CreationModule to be returned by get_module
Module = SFHDelayed