m2005.py 3.96 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

Yannick Roehlly's avatar
Yannick Roehlly committed
16
import numpy as np
17

18
from . import SedModule
19
from ..data import Database
Yannick Roehlly's avatar
Yannick Roehlly committed
20

21

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

Yannick Roehlly's avatar
Yannick Roehlly committed
25
26
27
    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
28
29
30

    """

31
    parameter_list = OrderedDict([
32
        ('imf', (
33
            'cigale_list(dtype=int, options=0. & 1.)',
34
            "Initial mass function: 0 (Salpeter) or 1 (Kroupa)",
35
            0
36
37
        )),
        ('metallicity', (
38
            'cigale_list(options=0.001 & 0.01 & 0.02 & 0.04)',
39
            "Metallicity. Possible values are: 0.001, 0.01, 0.02, 0.04.",
40
            0.02
41
42
        )),
        ('separation_age', (
43
            'cigale_list(dtype=int, minvalue=0.)',
Yannick Roehlly's avatar
Yannick Roehlly committed
44
45
46
47
            "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
48
49
        ))
    ])
Yannick Roehlly's avatar
Yannick Roehlly committed
50

51
52
    def _init_code(self):
        """Read the SSP from the database."""
53
54
55
56
57
58
59
60
61
62
        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)
63
        else:
64
            raise Exception("IMF #{} unknown".format(self.imf))
65

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

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

        """
75
76
        spec_young, spec_old, info_young, info_old = self.ssp.convolve(sed.sfh,
                                                         self.separation_age)
77

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

80
81
82
        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)
83

84
85
86
87
88
89
        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)

90
91
92
93
94
95
96
97
98
        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)

        sed.add_info('stellar.mass_total', info_young[0] + info_old[0], True)
        sed.add_info('stellar.mass_alive', info_young[1] + info_old[1], True)
        sed.add_info('stellar.mass_white_dwarf', info_young[2] + info_old[2],
99
                     True)
100
101
        sed.add_info('stellar.mass_neutron', info_young[3] + info_old[3], True)
        sed.add_info('stellar.mass_black_hole', info_young[4] + info_old[4],
102
103
104
105
106
                     True)

        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
107

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