Commit 435cd87d authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Minor corrections to Laure's Dale (2014) code

Class name should be CamelCased, arguments and variable inside functions
should be lower case.

There's no need to put my name in authors when I did not do anything.

Use the new post-fixed key names for contributions.
parent bfcea745
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Copyright (C) 2012, 2013 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 # Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Yannick Roehlly <yannick.roehlly@oamp.fr> # Author: Yannick Roehlly <yannick.roehlly@oamp.fr>
# Author: Médéric Boquien <mederic.boquien@oamp.fr>
# Author: Laure Ciesla <ciesla@physics.uoc.gr>
""" """
This script is used the build pcigale internal database containing: This script is used the build pcigale internal database containing:
...@@ -20,7 +22,7 @@ import numpy as np ...@@ -20,7 +22,7 @@ import numpy as np
from scipy import interpolate from scipy import interpolate
import scipy.constants as cst import scipy.constants as cst
from pcigale.data import (Database, Filter, SspM2005, SspBC03, AgnFritz2006, from pcigale.data import (Database, Filter, SspM2005, SspBC03, AgnFritz2006,
DALE2014, DL2007) Dale2014, DL2007)
def read_bc03_ssp(filename): def read_bc03_ssp(filename):
...@@ -361,7 +363,7 @@ def build_dale2014(base): ...@@ -361,7 +363,7 @@ def build_dale2014(base):
norm = np.trapz(lumin, x = wave) norm = np.trapz(lumin, x = wave)
lumin = lumin/norm lumin = lumin/norm
base.add_dale2014(DALE2014(fraction, alpha_grid[al-1], wave, lumin)) base.add_dale2014(Dale2014(fraction, alpha_grid[al-1], wave, lumin))
# Emission from dust heated by AGN - Quasar template # Emission from dust heated by AGN - Quasar template
fraction = 1.0 fraction = 1.0
...@@ -378,7 +380,7 @@ def build_dale2014(base): ...@@ -378,7 +380,7 @@ def build_dale2014(base):
norm = np.trapz(lumin_quasar, x = wave) norm = np.trapz(lumin_quasar, x = wave)
lumin_quasar = lumin_quasar/norm lumin_quasar = lumin_quasar/norm
base.add_dale2014(DALE2014(fraction, alpha_grid[al-1], wave, lumin_quasar)) base.add_dale2014(Dale2014(fraction, alpha_grid[al-1], wave, lumin_quasar))
def build_dl2007(base): def build_dl2007(base):
......
...@@ -24,7 +24,7 @@ from .filters import Filter ...@@ -24,7 +24,7 @@ from .filters import Filter
from .ssp_m2005 import SspM2005 from .ssp_m2005 import SspM2005
from .ssp_bc03 import SspBC03 from .ssp_bc03 import SspBC03
from .ir_templates_dh2002 import IrTemplatesDH2002 from .ir_templates_dh2002 import IrTemplatesDH2002
from .ir_agn_templates_dale2014 import DALE2014 from .ir_agn_templates_dale2014 import Dale2014
from .ir_models_dl2007 import DL2007 from .ir_models_dl2007 import DL2007
from .agn_fritz2006 import AgnFritz2006 from .agn_fritz2006 import AgnFritz2006
...@@ -119,7 +119,8 @@ class _DH2002InfraredTemplates(BASE): ...@@ -119,7 +119,8 @@ class _DH2002InfraredTemplates(BASE):
self.description = description self.description = description
self.data = data self.data = data
class _DALE2014(BASE):
class _Dale2014(BASE):
"""Storage for Dale et al (2014) infra-red templates """Storage for Dale et al (2014) infra-red templates
""" """
...@@ -135,6 +136,7 @@ class _DALE2014(BASE): ...@@ -135,6 +136,7 @@ class _DALE2014(BASE):
self.wave = iragn.wave self.wave = iragn.wave
self.lumin = iragn.lumin self.lumin = iragn.lumin
class _DL2007(BASE): class _DL2007(BASE):
"""Storage for Draine and Li (2007) IR models """Storage for Draine and Li (2007) IR models
""" """
...@@ -305,25 +307,25 @@ class Database(object): ...@@ -305,25 +307,25 @@ class Database(object):
else: else:
raise StandardError('The database is not writable.') raise StandardError('The database is not writable.')
def add_dale2014(self, iragn): def add_dale2014(self, iragn):
""" """
Add Dale et al (2014) templates the collection. Add Dale et al (2014) templates the collection.
Parameters Parameters
---------- ----------
iragn : pcigale.data.DALE2014 iragn : pcigale.data.Dale2014
""" """
if self.is_writable: if self.is_writable:
template = _DALE2014(iragn) template = _Dale2014(iragn)
self.session.add(template) self.session.add(template)
try: try:
self.session.commit() self.session.commit()
except exc.IntegrityError: except exc.IntegrityError:
self.session.rollback() self.session.rollback()
raise StandardError('The DALE2014 template is already in the base.') raise StandardError(
'The Dale2014 template is already in the base.')
else: else:
raise StandardError('The database is not writable.') raise StandardError('The database is not writable.')
...@@ -469,25 +471,26 @@ class Database(object): ...@@ -469,25 +471,26 @@ class Database(object):
else: else:
return None return None
def get_dale2014(self, fracAGN, alpha): def get_dale2014(self, frac_agn, alpha):
""" """
Get the Dale et al (2014) template corresponding to the given set of Get the Dale et al (2014) template corresponding to the given set of
parameters. parameters.
Parameters Parameters
---------- ----------
fracAGN: float frac_agn: float
contribution of the AGN to the IR luminosity contribution of the AGN to the IR luminosity
alpha: float alpha: float
alpha corresponding to the updated Dale & Helou (2002) star forming template. alpha corresponding to the updated Dale & Helou (2002) star
forming template.
""" """
result = (self.session.query(_DALE2014). result = (self.session.query(_Dale2014).
filter(_DALE2014.fracAGN == fracAGN). filter(_Dale2014.fracAGN == frac_agn).
filter(_DALE2014.alpha == alpha). filter(_Dale2014.alpha == alpha).
first()) first())
if result: if result:
return DALE2014(result.fracAGN, result.alpha, result.wave, return Dale2014(result.fracAGN, result.alpha, result.wave,
result.lumin) result.lumin)
else: else:
return None return None
......
## -*- coding: utf-8 -*- ## -*- coding: utf-8 -*-
# Copyright (C) 2013 Centre de données Astrophysiques de Marseille # Copyright (C) 2013 Centre de données Astrophysiques de Marseille
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt # Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Yannick Roehlly <yannick.roehlly@oamp.fr>, Laure Ciesla <ciesla@physics.uoc.gr> # Author: Laure Ciesla <ciesla@physics.uoc.gr>
class DALE2014(object): class Dale2014(object):
"""Dale et al (2014) IR templates containing an AGN component. """Dale et al (2014) IR templates containing an AGN component.
This class holds the data associated with the Dale et al (2014) This class holds the data associated with the Dale et al (2014)
...@@ -12,12 +12,12 @@ class DALE2014(object): ...@@ -12,12 +12,12 @@ class DALE2014(object):
""" """
def __init__(self, fracAGN, alpha, wave, lumin): def __init__(self, frac_agn, alpha, wave, lumin):
"""Create a new IR model """Create a new IR model
Parameters Parameters
---------- ----------
fracAGN: float frac_agn: float
Contribution of the AGN Contribution of the AGN
alpha: float alpha: float
Dale & Helou (2002) alpha slope. Dale & Helou (2002) alpha slope.
...@@ -31,8 +31,7 @@ class DALE2014(object): ...@@ -31,8 +31,7 @@ class DALE2014(object):
""" """
self.fracAGN = fracAGN self.fracAGN = frac_agn
self.alpha = alpha self.alpha = alpha
self.wave = wave self.wave = wave
self.lumin = lumin self.lumin = lumin
\ No newline at end of file
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2013 Centre de données Astrophysiques de Marseille # Copyright (C) 2013 Centre de données Astrophysiques de Marseille
# Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt # Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
# Author: Yannick Roehlly <yannick.roehlly@oamp.fr>, Laure Ciesla <ciesla@physics.uoc.gr> # Author: Laure Ciesla <ciesla@physics.uoc.gr>
from . import common from . import common
from collections import OrderedDict from collections import OrderedDict
import numpy as np
from pcigale.data import Database from pcigale.data import Database
...@@ -53,8 +52,10 @@ class Module(common.SEDCreationModule): ...@@ -53,8 +52,10 @@ class Module(common.SEDCreationModule):
def _init_code(self): def _init_code(self):
""" """
Get the models out of the database Get the models out of the database
model_sb corresponds to an AGN fraction of 0%: only the dust heated by star formation model_sb corresponds to an AGN fraction of 0%: only the dust heated by
model_quasar corresponds to an AGN fraction of 100%: only the SED of the quasar star formation
model_quasar corresponds to an AGN fraction of 100%: only the SED of
the quasar
The energy attenuated is re-injected in model_sb only. The energy attenuated is re-injected in model_sb only.
""" """
alpha = self.parameters["alpha"] alpha = self.parameters["alpha"]
...@@ -77,24 +78,21 @@ class Module(common.SEDCreationModule): ...@@ -77,24 +78,21 @@ class Module(common.SEDCreationModule):
item.strip() for item in item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")] self.parameters["attenuation_value_keys"].split("&")]
fracAGN = self.parameters["fracAGN"] frac_agn = self.parameters["fracAGN"]
# Base name for adding information to the SED. sed.add_module(self.name, self.parameters)
name = self.name or 'dale2014'
sed.add_module(name, self.parameters)
sed.add_info("fracAGN" + self.postfix, self.parameters["fracAGN"]) sed.add_info("fracAGN" + self.postfix, self.parameters["fracAGN"])
sed.add_info("alpha" + self.postfix, self.parameters["alpha"]) sed.add_info("alpha" + self.postfix, self.parameters["alpha"])
for attenuation in attenuation_value_keys: for attenuation in attenuation_value_keys:
sed.add_contribution( sed.add_contribution(
name + '_sb_' + attenuation, 'dale2014_sb_' + attenuation + self.postfix,
self.model_sb.wave, self.model_sb.wave,
sed.info[attenuation] * self.model_sb.lumin sed.info[attenuation] * self.model_sb.lumin
) )
sed.add_contribution( sed.add_contribution(
name + '_quasar', 'dale2014_quasar' + self.postfix,
self.model_quasar.wave, self.model_quasar.wave,
fracAGN * sed.info[attenuation] * self.model_quasar.lumin frac_agn * sed.info[attenuation] * self.model_quasar.lumin
) )
Markdown is supported
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