m2005.py 3.85 KB
Newer Older
Yannick Roehlly's avatar
Yannick Roehlly committed
1
# -*- coding: utf-8 -*-
2
3
# Copyright (C) 2012, 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
Yannick Roehlly's avatar
Yannick Roehlly committed
5

Yannick Roehlly's avatar
Yannick Roehlly committed
6
7
8
9
10
11
12
13
"""
Maraston (2005) stellar emission module
=======================================

This module implements the Maraston (2005) Single Stellar Populations.

"""

14
from collections import OrderedDict
15

16
from . import SedModule
17
from ..data import Database
Yannick Roehlly's avatar
Yannick Roehlly committed
18

19

20
class M2005(SedModule):
Yannick Roehlly's avatar
Yannick Roehlly committed
21
    """Maraston (2005) stellar emission module
Yannick Roehlly's avatar
Yannick Roehlly committed
22

Yannick Roehlly's avatar
Yannick Roehlly committed
23
24
25
    This SED creation module convolves the SED star formation history with
    a Maraston (2005) single stellar population to add a stellar component to
    the SED.
Yannick Roehlly's avatar
Yannick Roehlly committed
26
27
28

    """

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

49
50
    def _init_code(self):
        """Read the SSP from the database."""
51
52
53
54
55
56
57
58
59
60
        self.imf = int(self.parameters["imf"])
        self.metallicity = float(self.parameters["metallicity"])
        self.separation_age = int(self.parameters["separation_age"])

        if self.imf == 0:
            with Database() as database:
                self.ssp = database.get_m2005('salp', self.metallicity)
        elif self.imf == 1:
            with Database() as database:
                self.ssp = database.get_m2005('krou', self.metallicity)
61
        else:
62
            raise Exception("IMF #{} unknown".format(self.imf))
63

64
    def process(self, sed):
Yannick Roehlly's avatar
Yannick Roehlly committed
65
66
        """Add the convolution of a Maraston 2005 SSP to the SED

Yannick Roehlly's avatar
Yannick Roehlly committed
67
        Parameters
Yannick Roehlly's avatar
Yannick Roehlly committed
68
        ----------
69
        sed: pcigale.sed.SED
Yannick Roehlly's avatar
Yannick Roehlly committed
70
71
72
            SED object.

        """
73
74
        out = self.ssp.convolve(sed.sfh, self.separation_age)
        spec_young, spec_old, info_young, info_old, info_all = out
75

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

78
79
80
        sed.add_info('stellar.imf', self.imf)
        sed.add_info('stellar.metallicity', self.metallicity)
        sed.add_info('stellar.old_young_separation_age', self.separation_age)
81

82
83
84
85
86
87
        sed.add_info('stellar.mass_total_young', info_young[0], True)
        sed.add_info('stellar.mass_alive_young', info_young[1], True)
        sed.add_info('stellar.mass_white_dwarf_young', info_young[2], True)
        sed.add_info('stellar.mass_neutron_young', info_young[3], True)
        sed.add_info('stellar.mass_black_hole_young', info_young[4], True)

88
89
90
91
92
93
        sed.add_info('stellar.mass_total_old', info_old[0], True)
        sed.add_info('stellar.mass_alive_old', info_old[1], True)
        sed.add_info('stellar.mass_white_dwarf_old', info_old[2], True)
        sed.add_info('stellar.mass_neutron_old', info_old[3], True)
        sed.add_info('stellar.mass_black_hole_old', info_old[4], True)

94
95
96
97
98
99
        sed.add_info('stellar.mass_total', info_all[0], True)
        sed.add_info('stellar.mass_alive', info_all[1], True)
        sed.add_info('stellar.mass_white_dwarf', info_all[2], True)
        sed.add_info('stellar.mass_neutron', info_all[3], True)
        sed.add_info('stellar.mass_black_hole', info_all[4], True)
        sed.add_info('stellar.age_mass', info_all[5])
100
101
102
103

        sed.add_contribution("stellar.old", self.ssp.wavelength_grid, spec_old)
        sed.add_contribution("stellar.young", self.ssp.wavelength_grid,
                             spec_young)
Yannick Roehlly's avatar
Yannick Roehlly committed
104

105

106
# SedModule to be returned by get_module
Yannick Roehlly's avatar
Yannick Roehlly committed
107
Module = M2005