bc03.py 5.33 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
3
# Copyright (C) 2013 Centre de données Astrophysiques de Marseille
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
Yannick Roehlly's avatar
Yannick Roehlly committed
4
# Author: Yannick Roehlly
5

Yannick Roehlly's avatar
Yannick Roehlly committed
6
7
8
9
10
11
12
13
14
"""
Bruzual and Charlot (2003) stellar emission module
==================================================

This module implements the Bruzual and Charlot (2003) Single Stellar
Populations.

"""

15
import numpy as np
16
from collections import OrderedDict
17
from . import CreationModule
18
from ..data import Database
19

20

Yannick Roehlly's avatar
Yannick Roehlly committed
21
class BC03(CreationModule):
Yannick Roehlly's avatar
Yannick Roehlly committed
22
23
24
25
26
    """Bruzual and Charlot (2003) stellar emission module

    This SED creation module convolves the SED star formation history with a
    Bruzual and Charlot (2003) single stellar population to add a stellar
    component to the SED.
27
28
    """

29
30
    parameter_list = OrderedDict([
        ("imf", (
31
            "int",
32
            "Initial mass function: 0 (Salpeter) or 1 (Chabrier).",
33
            0
34
35
        )),
        ("metallicity", (
36
            "float",
37
38
            "Metalicity. Possible values are: 0.0001, 0.0004, 0.004, 0.008, "
            "0.02, 0.05.",
39
            0.02
40
41
42
        )),
        ("separation_age", (
            "int",
Yannick Roehlly's avatar
Yannick Roehlly committed
43
44
            "Age [Myr] of the separation between the young and the old star "
            "populations. The default value in 10^7 years (10 Myr). Set "
45
            "to 0 not to differentiate ages (only an old population).",
Yannick Roehlly's avatar
Yannick Roehlly committed
46
            10
47
48
        ))
    ])
49

50
51
52
    out_parameter_list = OrderedDict([
        ("sfr", "Instantaneous Star Formation Rate in solar mass per year, "
                "at the age of the galaxy."),
53
54
55
56
        ('sfr10Myrs', 'Average SFR in the last 10 Myr (default) of the '
                        'galaxy history.'),
        ('sfr100Myrs', 'Average SFR in the last 100 Myr (default) of the '
                        'galaxy history.'),
57
58
59
60
61
62
63
64
65
        ("ssp_m_star", "Total mass in stars in Solar mass."),
        ("ssp_m_gas", "Mass returned to the ISM by evolved stars in Solar "
                      "mass."),
        ("ssp_n_ly", "rate of H-ionizing photons in s^-1, per Solar mass "
                     "of galaxy."),
        ("ssp_b_4000", "Amplitude of 4000 Å break (Bruzual 2003)"),
        ("ssp_b4_vn", "Amplitude of 4000 Å narrow break (Balogh et al. 1999)"),
        ("ssp_b4_sdss", "Amplitude of 4000 Å break (Stoughton et al. 2002)"),
        ("ssp_b_912", "Amplitude of Lyman discontinuity")
66
    ])
67

68
69
    def _init_code(self):
        """Read the SSP from the database."""
70
71
72
73
        if self.parameters["imf"] == 0:
            imf = 'salp'
        elif self.parameters["imf"] == 1:
            imf = 'chab'
74
        metallicity = float(self.parameters["metallicity"])
75
        with Database() as database:
76
            self.ssp = database.get_bc03(imf, metallicity)
77

78
    def process(self, sed):
79
80
81
82
        """Add the convolution of a Bruzual and Charlot SSP to the SED

        Parameters
        ----------
83
        sed: pcigale.sed.SED
84
85
86
87
            SED object.

        """
        imf = self.parameters["imf"]
88
89
        metallicity = float(self.parameters["metallicity"])
        separation_age = int(self.parameters["separation_age"])
Yannick Roehlly's avatar
Yannick Roehlly committed
90
        sfh_time, sfh_sfr = sed.sfh
91
        ssp = self.ssp
92
93
94
95
96
97
98

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

        # First, we process the young population (age lower than the
        # separation age.)
        young_sfh = np.copy(sfh_sfr)
99
        young_sfh[sfh_age > separation_age] = 0
100
101
102
103
104
        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)
105
        old_sfh[sfh_age <= separation_age] = 0
106
107
        old_wave, old_lumin, old_info = ssp.convolve(sfh_time, old_sfh)

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

110
111
112
113
114
115
        sed.add_info("stellar.imf", imf)
        sed.add_info("stellar.metallicity", metallicity)
        sed.add_info("stellar.old_young_separation_age", separation_age)

        sed.add_info("stellar.m_star_young", young_info["m_star"], True)
        sed.add_info("stellar.m_gas_young", young_info["m_gas"], True)
116
        sed.add_info("stellar.n_ly_young", young_info["n_ly"], True)
117
118
119
120
121
122
123
        sed.add_info("stellar.b_400_young", young_info["b_4000"])
        sed.add_info("stellar.b4_vn_young", young_info["b4_vn"])
        sed.add_info("stellar.b4_sdss_young", young_info["b4_sdss"])
        sed.add_info("stellar.b_912_young", young_info["b_912"])

        sed.add_info("stellar.m_star_old", old_info["m_star"], True)
        sed.add_info("stellar.m_gas_old", old_info["m_gas"], True)
124
        sed.add_info("stellar.n_ly_old", old_info["n_ly"], True)
125
126
127
128
129
        sed.add_info("stellar.b_400_old", old_info["b_4000"])
        sed.add_info("stellar.b4_vn_old", old_info["b4_vn"])
        sed.add_info("stellar.b4_sdss_old", old_info["b4_sdss"])
        sed.add_info("stellar.b_912_old", old_info["b_912"])

130
131
132
133
134
135
136
        sed.add_info("stellar.m_star",
                     young_info["m_star"] + old_info["m_star"],
                     True)
        sed.add_info("stellar.m_gas",
                     young_info["m_gas"] + old_info["m_gas"],
                     True)

137
138
        sed.add_contribution("stellar.old", old_wave, old_lumin)
        sed.add_contribution("stellar.young", young_wave, young_lumin)
Yannick Roehlly's avatar
Yannick Roehlly committed
139
140
141

# CreationModule to be returned by get_module
Module = BC03