dl2007.py 4.47 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2013 Centre de données Astrophysiques de Marseille
Yannick Roehlly's avatar
Yannick Roehlly committed
3
# Copyright (C) 2013 Institute of Astronomy, University of Cambridge
4
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
Yannick Roehlly's avatar
Yannick Roehlly committed
5
# Author: Médéric Boquien
6

Yannick Roehlly's avatar
Yannick Roehlly committed
7
8
9
10
11
12
13
14
"""
Draine and Li (2007) IR models module
=====================================

This module implements the Draine and Li (2007) infra-red models.

"""

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


Yannick Roehlly's avatar
Yannick Roehlly committed
21
class DL2007(CreationModule):
Yannick Roehlly's avatar
Yannick Roehlly committed
22
    """Draine and Li (2007) templates IR re-emission module
23
24
25
26
27
28
29
30
31
32

    Given an amount of attenuation (e.g. resulting from the action of a dust
    attenuation module) this module normalises the Draine and Li (2007)
    template corresponding to a given α to this amount of energy and add it
    to the SED.

    Information added to the SED: NAME_alpha.

    """

33
34
    parameter_list = OrderedDict([
        ('qpah', (
35
            'float',
36
            "Mass fraction of PAH. Possible values are: 0.47, 1.12, 1.77, "
37
            "2.50, 3.19, 3.90, 4.58.",
38
            2.50
39
40
        )),
        ('umin', (
41
            'float',
42
            "Minimum radiation field. Possible values are: 0.10, 0.15, 0.20, "
Médéric Boquien's avatar
Médéric Boquien committed
43
44
            "0.30, 0.40, 0.50, 0.70, 0.80, 1.00, 1.20, 1.50, 2.00, 2.50, "
            "3.00, 4.00, 5.00, 7.00, 8.00, 10.0, 12.0, 15.0, 20.0, 25.0.",
45
            1.0
46
47
        )),
        ('umax', (
48
            'float',
49
50
            "Maximum radiation field. Possible values are: 1e3, 1e4, 1e5, "
            "1e6.",
51
            1e6
52
53
        )),
        ('gamma', (
54
            'float',
55
56
            "Fraction illuminated from Umin to Umax. Possible values between "
            "0 and 1.",
57
            0.1
58
59
        ))
    ])
60

61
62
63
64
65
66
    out_parameter_list = OrderedDict([
        ('qpah', 'Mass fraction of PAH'),
        ('umin', 'Minimum radiation field'),
        ('umax', 'Maximum radiation field'),
        ('gamma', 'Fraction illuminated from Umin to Umax')
    ])
67
68
69
70
71
72
73
74
75

    def _init_code(self):
        """Get the model out of the database"""

        qpah = self.parameters["qpah"]
        umin = self.parameters["umin"]
        umax = self.parameters["umax"]
        gamma = self.parameters["gamma"]

76
77
78
        with Database() as database:
            self.model_minmin = database.get_dl2007(qpah, umin, umin)
            self.model_minmax = database.get_dl2007(qpah, umin, umax)
79
80
81
82
83

        # The models in memory are in W/nm for 1 kg of dust. At the same time
        # we need to normalize them to 1 W here to easily scale them from the
        # power absorbed in the UV-optical. If we want to retrieve the dust
        # mass at a later point, we have to save their "emissivity" per unit
84
85
86
        # mass in W (kg of dust)¯¹, The gamma parameter does not affect the
        # fact that it is for 1 kg because it represents a mass fraction of
        # each component.
87
        self.emissivity = np.trapz((1. - gamma) * self.model_minmin.lumin +
88
89
                                   gamma * self.model_minmax.lumin,
                                   x=self.model_minmin.wave)
90

Yannick Roehlly's avatar
Yannick Roehlly committed
91
        # We want to be able to display the respective contributions of both
92
93
94
95
96
97
98
99
100
        # components, therefore we keep they separately.
        self.model_minmin.lumin *= (1. - gamma) / self.emissivity
        self.model_minmax.lumin *= gamma / self.emissivity

    def process(self, sed):
        """Add the IR re-emission contributions

        Parameters
        ----------
101
102
        sed: pcigale.sed.SED object
        parameters: dictionary containing the parameters
103
104

        """
105
106
        if 'dust.luminosity' not in sed.info.keys():
            sed.add_info('dust.luminosity', 1., True)
107
        luminosity = sed.info['dust.luminosity']
108
109
110
111
112
113

        sed.add_module(self.name, self.parameters)
        sed.add_info('dust.qpah', self.parameters["qpah"])
        sed.add_info('dust.umin', self.parameters["umin"])
        sed.add_info('dust.umax', self.parameters["umax"])
        sed.add_info('dust.gamma', self.parameters["gamma"])
114
115
116
        # To compute the dust mass we simply divide the luminosity in W by the
        # emissivity in W/kg of dust.
        sed.add_info('dust.mass', luminosity / self.emissivity, True)
117
118
119
120
121

        sed.add_contribution('dust.Umin_Umin', self.model_minmin.wave,
                             luminosity * self.model_minmin.lumin)
        sed.add_contribution('dust.Umin_Umax', self.model_minmax.wave,
                             luminosity * self.model_minmax.lumin)
Yannick Roehlly's avatar
Yannick Roehlly committed
122
123
124

# CreationModule to be returned by get_module
Module = DL2007