Commit b545a5bd authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Take galaxy mass into account

A list is added to the SED object to store the key names from the info
dictionary whose values are proportional to the galaxy mass.
This is used by the statistical module to multiplicate the value by the
galaxy mass (correction factor) in the analysis.
parent 96621fd6
# -*- coding: utf-8 -*-
Copyright (C) 2012 Centre de données Astrophysiques de Marseille
Copyright (C) 2012, 2013 Centre de données Astrophysiques de Marseille
Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
@author: Yannick Roehlly <>
......@@ -14,8 +14,7 @@ from scipy.constants import c
class SED(object):
Spectral Energy Distribution with associated information
"""Spectral Energy Distribution with associated information
This class represents a Spectral Energy Distribution (SED) as constructed
by pCigale. Such a SED is characterised by:
......@@ -36,6 +35,9 @@ class SED(object):
- A dictionnary of arbitrary information associated with the SED.
- The list of the keys from the info dictionary whose value is
proportional to the galaxy mass.
def __init__(self):
......@@ -44,6 +46,7 @@ class SED(object):
self.lumin_contributions = None
self.contribution_names = [] = {}
self.mass_proportional_info = []
def wavelength_grid(self):
......@@ -109,7 +112,7 @@ class SED(object):
return wavelength, f_nu
def add_info(self, key, value):
def add_info(self, key, value, mass_proportional=False):
Add a key / value to the information dictionary
......@@ -123,10 +126,15 @@ class SED(object):
The key used to retrieve the information.
value : anything
The information.
mass_proportional : boolean
If True, the added variable is set as proportional to the
if key not in[key] = value
if mass_proportional:
raise KeyError("The information %s is yet present "
"in the SED. " % key)
......@@ -192,29 +192,29 @@ class Module(common.SEDCreationModule):
sed.add_info('metallicity', metallicity)
sed.add_info('old_young_separation_age', separation_age)
sed.add_info('sfr', sfr)
sed.add_info('average_sfr', average_sfr)
sed.add_info('mass_total_old', old_masses[0])
sed.add_info('mass_alive_old', old_masses[1])
sed.add_info('mass_white_dwarf_old', old_masses[2])
sed.add_info('mass_neutrino_old', old_masses[3])
sed.add_info('mass_black_hole_old', old_masses[4])
sed.add_info('mass_turn_off_old', old_masses[5])
sed.add_info('mass_total_young', young_masses[0])
sed.add_info('mass_alive_young', young_masses[1])
sed.add_info('mass_white_dwarf_young', young_masses[2])
sed.add_info('mass_neutrino_young', young_masses[3])
sed.add_info('mass_black_hole_young', young_masses[4])
sed.add_info('mass_turn_off_young', young_masses[5])
sed.add_info('mass_total', old_masses[0] + young_masses[0])
sed.add_info('mass_alive', old_masses[1] + young_masses[1])
sed.add_info('mass_white_dwarf', old_masses[2] + young_masses[2])
sed.add_info('mass_neutrino', old_masses[3] + young_masses[3])
sed.add_info('mass_black_hole', old_masses[4] + young_masses[4])
sed.add_info('mass_turn_off', old_masses[5] + young_masses[5])
sed.add_info('sfr', sfr, True)
sed.add_info('average_sfr', average_sfr, True)
sed.add_info('mass_total_old', old_masses[0], True)
sed.add_info('mass_alive_old', old_masses[1], True)
sed.add_info('mass_white_dwarf_old', old_masses[2], True)
sed.add_info('mass_neutrino_old', old_masses[3], True)
sed.add_info('mass_black_hole_old', old_masses[4], True)
sed.add_info('mass_turn_off_old', old_masses[5], True)
sed.add_info('mass_total_young', young_masses[0], True)
sed.add_info('mass_alive_young', young_masses[1], True)
sed.add_info('mass_white_dwarf_young', young_masses[2], True)
sed.add_info('mass_neutrino_young', young_masses[3], True)
sed.add_info('mass_black_hole_young', young_masses[4], True)
sed.add_info('mass_turn_off_young', young_masses[5], True)
sed.add_info('mass_total', old_masses[0] + young_masses[0], True)
sed.add_info('mass_alive', old_masses[1] + young_masses[1], True)
sed.add_info('mass_white_dwarf', old_masses[2] + young_masses[2], True)
sed.add_info('mass_neutrino', old_masses[3] + young_masses[3], True)
sed.add_info('mass_black_hole', old_masses[4] + young_masses[4], True)
sed.add_info('mass_turn_off', old_masses[5] + young_masses[5], True)
sed.add_contribution(name + '_old',
......@@ -170,8 +170,12 @@ class Module(common.AnalysisModule):
comp_table[model_index, obs_index, 2] = galaxy_mass
for index, variable in enumerate(analysed_variables):
comp_table[model_index, obs_index, index + 3] = \[variable]
if variable in sed.mass_proportional_info:
comp_table[model_index, obs_index, index + 3] = \
galaxy_mass *[variable]
comp_table[model_index, obs_index, index + 3] = \[variable]
# Find the model corresponding to the least reduced Chi-square for
# each observation.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment