sfhdelayed.py 2.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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.

"""

16
from collections import OrderedDict
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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).

    """

33
    parameter_list = OrderedDict([
34
35
36
37
38
39
40
41
42
43
        ("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
44
        )),
Médéric Boquien's avatar
Médéric Boquien committed
45
        ("sfr_A", (
46
47
48
49
50
51
52
            "float",
            "Multiplicative factor controlling the amplitude of SFR.",
            1.
        )),
        ("normalise", (
            "boolean",
            "Normalise the SFH to produce one solar mass.",
Denis's avatar
Denis committed
53
            "True"
54
        ))
Médéric Boquien's avatar
Médéric Boquien committed
55
    ])
56
57
58
59
60
61
62
63
64
65

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

        """
        tau_main = float(self.parameters["tau_main"])
        age = int(self.parameters["age"])
66
67
        sfr_A = int(self.parameters["sfr_A"])
        normalise = (self.parameters["normalise"].lower() == "true")
68
69
70
71
72

        # 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
73
        sfr = time_grid / tau_main**2 * np.exp(-time_grid / tau_main)
74

75
76
        # Compute the galaxy mass and normalise the SFH to 1 solar mass
        # produced if asked to.
77
        galaxy_mass = np.trapz(sfr, time_grid) * 1e6
78
        if normalise:
79
80
            sfr = sfr / galaxy_mass
            galaxy_mass = 1.
81
82
83
        else:
            sfr *= sfr_A
            galaxy_mass *= sfr_A
84
85
86
87
88

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

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

# CreationModule to be returned by get_module
Module = SFHDelayed