dl2007.py 3.89 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
36
37
            'float',
            "Mass fraction of PAH",
            None
38
39
        )),
        ('umin', (
40
41
42
            'float',
            "Minimum radiation field",
            None
43
44
        )),
        ('umax', (
45
46
47
            'float',
            "Maximum radiation field",
            None
48
49
        )),
        ('gamma', (
50
51
52
            'float',
            "Fraction illuminated from Umin to Umax",
            None
53
54
        ))
    ])
55

56
57
58
59
60
61
    out_parameter_list = OrderedDict([
        ('qpah', 'Mass fraction of PAH'),
        ('umin', 'Minimum radiation field'),
        ('umax', 'Maximum radiation field'),
        ('gamma', 'Fraction illuminated from Umin to Umax')
    ])
62
63
64
65
66
67
68
69
70

    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"]

71
72
73
        with Database() as database:
            self.model_minmin = database.get_dl2007(qpah, umin, umin)
            self.model_minmax = database.get_dl2007(qpah, umin, umax)
74
75
76
77
78
79
80
81

        # 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
        # mass in W kg¯¹, The gamma parameter does not affect the fact that it
        # is for 1 kg because it represents a mass fraction of each component.
        self.emissivity = np.trapz((1. - gamma) * self.model_minmin.lumin +
82
83
                                   gamma * self.model_minmax.lumin,
                                   x=self.model_minmin.wave)
84

Yannick Roehlly's avatar
Yannick Roehlly committed
85
        # We want to be able to display the respective contributions of both
86
87
88
89
90
91
92
93
94
95
96
97
98
        # 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
        ----------
        sed  : pcigale.sed.SED object
        parameters : dictionary containing the parameters

        """
99
100
101
        if 'dust.luminosity' not in sed.info.keys():
            sed.add_info('dust.luminosity', 1., True)
        luminosity = 1.
102
103
104
105
106
107
108
109
110
111
112

        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"])

        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
113
114
115

# CreationModule to be returned by get_module
Module = DL2007