bc03.py 5.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- coding: utf-8 -*-
"""
Copyright (C) 2013 Centre de données Astrophysiques de Marseille
Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt

@author: Yannick Roehlly <yannick.roehlly@oamp.fr>

"""


import numpy as np
from . import common
from pcigale.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
Yannick Roehlly's avatar
Yannick Roehlly committed
17
18
# number of parameters. The value is in Myr.
AV_LAPSE = 100
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


class Module(common.SEDCreationModule):
    """Module computing the Star Formation History contribution bases on the
    Bruzual and Charlot (2003) models.
    """

    parameter_list = {
        "imf": (
            "string",
            "Initial mass function: salp (Salpeter) or chab (Chabrier)",
            None
        ),
        "metallicity": (
            "float",
            "Mettalicity, 0.02 for Solar metallicity.",
            None
        ),
        "separation_age": (
38
            "integer",
Yannick Roehlly's avatar
Yannick Roehlly committed
39
40
            "Age [Myr] of the separation between the young and the old star "
            "populations. The default value in 10^7 years (10 Myr). Set "
41
            "to 0 not to differentiate ages (only an old population).",
Yannick Roehlly's avatar
Yannick Roehlly committed
42
            10
43
44
45
46
47
48
        )
    }

    out_parameter_list = {
        "sfr": "Instantaneous Star Formation Rate in solar mass per year, "
               "at the age of the galaxy.",
Yannick Roehlly's avatar
Yannick Roehlly committed
49
        "average_sfr": "Average SFR in the last 100 Myr (default) of the "
50
51
52
                       "galaxy history.",
        "m_star": "Total mass in stars in Solar mass.",
        "m_gas": "Mass returned to the ISM by evolved stars in Solar mass.",
53
        "n_ly": "rate of H-ionizing photons in s^-1, per Solar mass "
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
                "of galaxy.",
        "b_4000": "Amplitude of 4000 Å break (Bruzual 2003)",
        "b4_vn": "Amplitude of 4000 Å narrow break (Balogh et al. 1999)",
        "b4_sdss": "Amplitude of 4000 Å break (Stoughton et al. 2002)",
        "b_912": "Amplitude of Lyman discontinuity"
    }

    def _process(self, sed, parameters):
        """Add the convolution of a Bruzual and Charlot SSP to the SED

        Parameters
        ----------
        sed  : pcigale.sed.SED
            SED object.
        parameters : dictionary
            Dictionary containing the parameters

        """

        imf = self.parameters["imf"]
74
75
        metallicity = float(self.parameters["metallicity"])
        separation_age = int(self.parameters["separation_age"])
Yannick Roehlly's avatar
Yannick Roehlly committed
76
        sfh_time, sfh_sfr = sed.sfh
77
78
79
80
81
82
83
84
85
86
87
88

        # Age of the galaxy at each time of the SFH
        sfh_age = np.max(sfh_time) - sfh_time

        # First, we take the SSP out of the database.
        database = Database()
        ssp = database.get_ssp_bc03(imf, metallicity)
        database.session.close_all()

        # First, we process the young population (age lower than the
        # separation age.)
        young_sfh = np.copy(sfh_sfr)
89
        young_sfh[sfh_age > separation_age] = 0
90
91
92
93
94
        young_wave, young_lumin, young_info = ssp.convolve(sfh_time, young_sfh)

        # Then, we process the old population. If the SFH is shorter than the
        # separation age then all the arrays will consist only of 0.
        old_sfh = np.copy(sfh_sfr)
95
        old_sfh[sfh_age <= separation_age] = 0
96
97
98
99
100
        old_wave, old_lumin, old_info = ssp.convolve(sfh_time, old_sfh)

        # SFR of the galaxy
        sfr = sfh_sfr[len(sfh_sfr) - 1]

Yannick Roehlly's avatar
Yannick Roehlly committed
101
        # Average SFR on the last AV_LAPSE Myr of its history
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
        average_sfr = np.mean(sfh_sfr[sfh_age <= AV_LAPSE])

        # Base name for adding information to the SED.
        name = self.name or "bc03"

        sed.add_module(name, parameters)

        sed.add_info(name + "_imf", imf)
        sed.add_info(name + "_metallicity", metallicity)
        sed.add_info(name + '_old_young_separation_age', separation_age)

        sed.add_info(name + '_sfr', sfr, True)
        sed.add_info(name + '_average_sfr', average_sfr, True)

        sed.add_info(name + "_m_star_young", young_info["m_star"], True)
        sed.add_info(name + "_m_gas_young", young_info["m_gas"], True)
        sed.add_info(name + "_n_ly_young", young_info["n_ly"])
        sed.add_info(name + "_b_400_young", young_info["b_4000"])
        sed.add_info(name + "_b4_vn_young", young_info["b4_vn"])
        sed.add_info(name + "_b4_sdss_young", young_info["b4_sdss"])
        sed.add_info(name + "_b_912_young", young_info["b_912"])

        sed.add_info(name + "_m_star_old", old_info["m_star"], True)
        sed.add_info(name + "_m_gas_old", old_info["m_gas"], True)
        sed.add_info(name + "_n_ly_old", old_info["n_ly"])
        sed.add_info(name + "_b_400_old", old_info["b_4000"])
        sed.add_info(name + "_b4_vn_old", old_info["b4_vn"])
        sed.add_info(name + "_b4_sdss_old", old_info["b4_sdss"])
        sed.add_info(name + "_b_912_old", old_info["b_912"])

        sed.add_contribution(name + '_old',
                             old_wave,
                             old_lumin)
        sed.add_contribution(name + '_young',
                             young_wave,
                             young_lumin)