param.py 5.5 KB
Newer Older
BURGARELLA Denis's avatar
BURGARELLA Denis committed
1
2
3
4
5
6
7
8
9
10
11
12
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Laboratoire d'Astrophysique de Marseille
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Denis Burgarella

"""
Module that estimates other parameters, e.g., UV slope, Lick indices, etc.
==========================================================================

This module estimates additional parameters of interest
close to the observation, e.g., the ultraviolet slope (beta), the rest-frame
far-ultraviolet luminosity, any type of indices (Lick), etc.
13
14
15
16
17
18

This module can also be used to compute the fluxes in some filters and add them
to the SED parameters (each flux will be added as “param.FILTERID”).  This can
be used for instance to compute the flux probability distribution for not
observed filters during an analysis.

BURGARELLA Denis's avatar
BURGARELLA Denis committed
19
20
21
22
23
This module will be the last one (after redshifting) to account
for all the physical processes at play to build the received total emission.

"""

24
from collections import OrderedDict
25

BURGARELLA Denis's avatar
BURGARELLA Denis committed
26
import numpy as np
27

28
from . import SedModule
BURGARELLA Denis's avatar
BURGARELLA Denis committed
29
30


31
class Param(SedModule):
BURGARELLA Denis's avatar
BURGARELLA Denis committed
32
33
34
35
36
37
38
39
    """Other parameters

    This module does not need any input.
    It computes some parameters from the models:
    beta_UV, Lum_UV, etc.

    """

40
    parameter_list = OrderedDict([
41
        ("filter_list", (
42
            "string()",
43
            "Filters for which the flux will be computed and added to the SED "
44
45
            "information dictionary. You can give several filter names "
            "separated by a & (don't use commas).",
46
            ""
47
48
        ))
    ])
BURGARELLA Denis's avatar
BURGARELLA Denis committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62

    def process(self, sed):
        """Computes the parameters for each model.

        Parameters
        ----------
        sed: pcigale.sed.SED object

        """
        # Retrieve the final computed SED using all the previous modules
        # including the IGM and the redshifting. In other words,
        # this module must be the last one. Note that it does require
        # an SFH and an SSP module but nothing else (except redshifting)

Médéric Boquien's avatar
Médéric Boquien committed
63
        redshift = sed.info['universe.redshift']
BURGARELLA Denis's avatar
BURGARELLA Denis committed
64
65
66
67
68
        # Wavelengths are in nanometers.
        wavelength = sed.wavelength_grid
        # Luminosity is is W/nm.
        luminosity = sed.luminosity

Médéric Boquien's avatar
Médéric Boquien committed
69
70
71
        # Attenuated (observed) UV slopes beta as defined in Calzetti et al.
        # (1994, ApJ 429, 582, Tab. 2) that excludes the 217.5 nm bump
        # wavelength range and other spectral features
BURGARELLA Denis's avatar
BURGARELLA Denis committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

        w_calz94 = np.where((wavelength >= 126.8 * (1. + redshift)) &
                            (wavelength <= 128.4 * (1. + redshift)) |
                            (wavelength >= 130.9 * (1. + redshift)) &
                            (wavelength <= 131.6 * (1. + redshift)) |
                            (wavelength >= 134.2 * (1. + redshift)) &
                            (wavelength <= 137.1 * (1. + redshift)) |
                            (wavelength >= 140.7 * (1. + redshift)) &
                            (wavelength <= 151.5 * (1. + redshift)) |
                            (wavelength >= 156.2 * (1. + redshift)) &
                            (wavelength <= 158.3 * (1. + redshift)) |
                            (wavelength >= 167.7 * (1. + redshift)) &
                            (wavelength <= 174.0 * (1. + redshift)) |
                            (wavelength >= 176.0 * (1. + redshift)) &
                            (wavelength <= 183.3 * (1. + redshift)) |
                            (wavelength >= 186.6 * (1. + redshift)) &
                            (wavelength <= 189.0 * (1. + redshift)) |
                            (wavelength >= 193.0 * (1. + redshift)) &
                            (wavelength <= 195.0 * (1. + redshift)) |
                            (wavelength >= 240.0 * (1. + redshift)) &
                            (wavelength <= 258.0 * (1. + redshift)))

        # Attenuated (observed) FUV luminosity L_FUV, in the GALEX FUV band,
        # i.e., lambda_eff = 152.8 nm and effective bandwidth = 11.4 nm

        w_FUV = np.where((wavelength >= (152.8 - 11.4) * (1. + redshift)) &
Médéric Boquien's avatar
Médéric Boquien committed
98
                         (wavelength <= (152.8 + 11.4) * (1. + redshift)))
BURGARELLA Denis's avatar
BURGARELLA Denis committed
99

Médéric Boquien's avatar
Médéric Boquien committed
100
101
102
103
        # Strength of the D_4000 break using Balogh et al. (1999, ApJ 527, 54),
        # i.e., ratio of the flux in the red continuum to that in the blue
        # continuum: Blue continuum: 385.0-395.0 nm & red continuum:
        # 410.0-410.0 nm.
BURGARELLA Denis's avatar
BURGARELLA Denis committed
104
105
106

        w_D4000blue = np.where((wavelength >= 385.0 * (1. + redshift)) &
                               (wavelength <= 395.0 * (1. + redshift)))
107
108
        w_D4000red = np.where((wavelength >= 400.0 * (1. + redshift)) &
                              (wavelength <= 410.0 * (1. + redshift)))
BURGARELLA Denis's avatar
BURGARELLA Denis committed
109
110

        regression_calz94 = np.polyfit(np.log10(10.*wavelength[w_calz94]),
Médéric Boquien's avatar
Médéric Boquien committed
111
112
                                       np.log10(1e7/10.*luminosity[w_calz94]),
                                       1)
BURGARELLA Denis's avatar
BURGARELLA Denis committed
113
114
115
116
        beta_calz94 = regression_calz94[0]

        L_FUV = 152.8*(1. + redshift)*np.mean(luminosity[w_FUV])

Médéric Boquien's avatar
Médéric Boquien committed
117
118
        D_4000 = (np.mean(luminosity[w_D4000red]) /
                  np.mean(luminosity[w_D4000blue]))
BURGARELLA Denis's avatar
BURGARELLA Denis committed
119
120
121
122
123

        sed.add_info("param.beta_calz94", beta_calz94)
        sed.add_info("param.FUV_luminosity", L_FUV, True)
        sed.add_info("param.D_4000", D_4000)

124
125
        # Computation of fluxes
        filter_list = [item.strip() for item in
126
127
                       self.parameters["filter_list"].split("&")
                       if item.strip() != '']
128
129
130
131

        for filter_ in filter_list:
            sed.add_info(
                "param.{}".format(filter_),
132
133
                sed.compute_fnu(filter_),
                True
134
135
            )

136

137
# SedModule to be returned by get_module
BURGARELLA Denis's avatar
BURGARELLA Denis committed
138
Module = Param