Commit 82092706 authored by Yannick Roehlly's avatar Yannick Roehlly

Add Fritz et al. (2006) AGN torus model.

parent c697fc17
......@@ -18,13 +18,14 @@ import glob
import itertools
import numpy as np
from scipy import interpolate
from pcigale.data import Database, Filter, SspM2005, SspBC03
from pcigale.data import Database, Filter, SspM2005, SspBC03, AgnFritz2006
filters_dir = os.path.join(os.path.dirname(__file__), 'filters/')
m2005_dir = os.path.join(os.path.dirname(__file__), 'maraston2005/')
bc03_dir = os.path.join(os.path.dirname(__file__), 'bc03//')
dh2002_dir = os.path.join(os.path.dirname(__file__), 'dh2002/')
fritz2006_dir = os.path.join(os.path.dirname(__file__), 'fritz2006/')
def read_bc03_ssp(filename):
......@@ -329,6 +330,37 @@ def build_base():
base.add_dh2002_infrared_templates(data)
########################################################################
# Fritz et al. (2006) AGN insertion #
########################################################################
print("5- Importing Fritz et al. (2006) models\n")
model_list = np.genfromtxt(fritz2006_dir + "fritz.dat")
for model_line in model_list:
(model_nb, agn_type, r_ratio, tau,
beta, gamma, theta, psy) = model_line
# Convert some floats to int
model_nb = int(model_nb)
agn_type = int(agn_type)
wave, lumin = np.genfromtxt("{}AGN_fritz{}.spec".format(fritz2006_dir,
model_nb),
skip_header=1).transpose()
# Convert the wavelength from Å to nm
wave = wave * 0.1
# Convert the luminosity from erg/s^-1/Å to W/nm
lumin = lumin * 10 * 1.e-7
agn = AgnFritz2006(model_nb, agn_type, r_ratio, tau, beta, gamma,
theta, psy, wave, lumin)
base.add_fritz2006_agn(agn)
print("\nDONE\n")
print('#' * 78)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#model type Rmax/Rmin tau(9.7micron) beta gamma theta psy
1 2 30 2 -0.5 0. 140 20
2 2 30 10 -0.5 6.0 140 80
3 1 30 2 -0.5 0.0 60 20
4 1 100 2 -0.5 0.0 140 20
5 2 100 6 -0.5 0. 140 80
6 1 30 2 -0.5 6.0 60 80
\ No newline at end of file
......@@ -18,13 +18,14 @@ SqlAlchemy ORM to store the data in a unique SQLite3 database.
import pkg_resources
from sqlalchemy import (create_engine, exc, Column, String, Text,
Float, PickleType)
Float, Integer, PickleType)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from .filters import Filter
from .ssp_m2005 import SspM2005
from .ssp_bc03 import SspBC03
from .ir_templates_dh2002 import IrTemplatesDH2002
from .agn_fritz2006 import AgnFritz2006
DATABASE_FILE = pkg_resources.resource_filename(__name__, 'data.db')
......@@ -118,6 +119,35 @@ class _DH2002InfraredTemplates(BASE):
self.data = data
class _Fritz2006AGN(BASE):
"""Storage for Fritz et al. (2006) models
"""
__tablename__ = 'fritz2006_agn'
model_nb = Column(Integer, primary_key=True)
agn_type = Column(Integer)
r_ratio = Column(Float)
tau = Column(Float)
beta = Column(Float)
gamma = Column(Float)
theta = Column(Float)
psy = Column(Float)
wave = Column(PickleType)
luminosity = Column(PickleType)
def __init__(self, agn):
self.model_nb = agn.model_nb
self.agn_type = agn.agn_type
self.r_ratio = agn.r_ratio
self.tau = agn.tau
self.beta = agn.beta
self.gamma = agn.gamma
self.theta = agn.theta
self.psy = agn.psy
self.wave = agn.wave
self.luminosity = agn.luminosity
class Database(object):
"""Object giving access to pcigale database."""
......@@ -240,6 +270,25 @@ class Database(object):
else:
raise StandardError('The database is not writable.')
def add_fritz2006_agn(self, agn):
"""
Add a Fritz et al. (2006) AGN model to the database.
Parameters
----------
agn : pcigale.data.AgnFritz2006
"""
if self.is_writable:
self.session.add(_Fritz2006AGN(agn))
try:
self.session.commit()
except exc.IntegrityError:
self.session.rollback()
raise StandardError('The agn model is yet in the base.')
else:
raise StandardError('The database is not writable.')
def get_filter(self, name):
"""
Get a specific filter from the collection
......@@ -344,6 +393,32 @@ class Database(object):
else:
return None
def get_agn_fritz2006(self, model_nb):
"""
Get the Fritz et al. (2006) AGN model corresponding to the number.
Parameters
----------
model_nb : integer
Model number.
Returns
-------
agn : pcigale.data.AgnFritz2006
The AGN model or not if no model exists for the given number.
"""
result = (self.session.query(_Fritz2006AGN).
filter(_Fritz2006AGN.model_nb == model_nb).
first())
if result:
return AgnFritz2006(result.model_nb, result.agn_type,
result.r_ratio, result.tau, result.beta,
result.gamma, result.theta, result.psy,
result.wave, result.luminosity)
else:
return None
def get_filter_list(self):
"""Get the list of the filters in the database.
......
# -*- coding: utf-8 -*-
"""
Copyright (C) 2013 Centre de données Astrophysiques de Marseille
Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
@author: Yannick Roehlly <yannick.roehlly@oamp.fr>
"""
import numpy as np
class AgnFritz2006(object):
"""Fritz et al. (2006) AGN dust torus emision model.
This class holds the UV-optical data associated with a Fritz et al. (2006)
AGN model.
"""
def __init__(self, model_nb, agn_type, r_ratio, tau, beta, gamma, theta,
psy, wave, luminosity):
"""Create a new AGN model
Parameters
----------
model_nb : integer
Number identifying the AGN model.
agn_type : integer
Type of AGN.
r_ratio : float
Ratio of the maximum and minimum radii of the dust torus.
tau : float
Tau at 9.7µm
beta : float
Beta
gamma : float
Gamma
theta : float
Opening angle of the dust torus.
psy : float
Angle between AGN axis and line of sight.
wave : array of float
Wavelength grid in nm.
luminosity : array of float
Luminosity density at each wavelength in W/nm.
"""
self.model_nb = model_nb
self.agn_type = agn_type
self.r_ratio = r_ratio
self.tau = tau
self.beta = beta
self.gamma = gamma
self.theta = theta
self.psy = psy
self.wave = np.array(wave)
self.luminosity = np.array(luminosity)
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