Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
cigale
CIGALE
Commits
34be8f78
Commit
34be8f78
authored
Oct 14, 2015
by
Laure Ciesla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schreiber+16 IR SED library - missing files
parent
1ebda311
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
1 deletion
+125
-1
database_builder/__init__.py
database_builder/__init__.py
+41
-1
pcigale/data/__init__.py
pcigale/data/__init__.py
+84
-0
No files found.
database_builder/__init__.py
View file @
34be8f78
...
...
@@ -19,9 +19,10 @@ import itertools
import
numpy
as
np
from
scipy
import
interpolate
import
scipy.constants
as
cst
from
astropy.table
import
Table
from
pcigale.data
import
(
Database
,
Filter
,
M2005
,
BC03
,
Fritz2006
,
Dale2014
,
DL2007
,
DL2014
,
NebularLines
,
NebularContinuum
)
NebularContinuum
,
Schreiber2016
)
def
read_bc03_ssp
(
filename
):
...
...
@@ -664,6 +665,40 @@ def build_nebular(base):
base
.
add_nebular_continuum
(
models_cont
)
base
.
add_nebular_lines
(
models_lines
)
def
build_schreiber2016
(
base
):
models
=
[]
schreiber2016_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'schreiber2016/'
)
pah
=
Table
.
read
(
schreiber2016_dir
+
'g15_pah.fits'
)
dust
=
Table
.
read
(
schreiber2016_dir
+
'g15_dust.fits'
)
# Getting the lambda grid for the templates and convert from microns to nm.
wave
=
dust
[
0
][
0
][
0
]
*
1E3
for
td
in
range
(
15
,
100
,
1
):
# Find the closest temperature in the model list of tdust
tsed
=
np
.
where
(
np
.
absolute
(
np
.
array
(
dust
[
0
][
6
])
-
td
)
==
np
.
min
(
np
.
absolute
(
np
.
array
(
dust
[
0
][
6
])
-
td
)))[
0
]
# The models are in nuFnu.
# We convert this to W/nm.
lumin_dust
=
dust
[
0
][
1
][
tsed
]
/
wave
lumin_dust
=
lumin_dust
[
0
]
#norm = np.trapz(lumin_dust, x=wave)
#lumin_dust /= norm
models
.
append
(
Schreiber2016
(
0
,
np
.
float
(
td
),
wave
,
lumin_dust
))
# The models are in nuFnu.
# We convert this to W/nm.
lumin_pah
=
pah
[
0
][
1
][
tsed
]
/
wave
lumin_pah
=
lumin_pah
[
0
]
#norm = np.trapz(lumin_pah, x=wave)
#lumin_pah /= norm
models
.
append
(
Schreiber2016
(
1
,
np
.
float
(
td
),
wave
,
lumin_pah
))
base
.
add_schreiber2016
(
models
)
def
build_base
():
base
=
Database
(
writable
=
True
)
base
.
upgrade_base
()
...
...
@@ -709,6 +744,11 @@ def build_base():
print
(
"
\n
DONE
\n
"
)
print
(
'#'
*
78
)
print
(
"9- Importing Schreiber et al (2016) models
\n
"
)
build_schreiber2016
(
base
)
print
(
"
\n
DONE
\n
"
)
print
(
'#'
*
78
)
base
.
session
.
close_all
()
...
...
pcigale/data/__init__.py
View file @
34be8f78
...
...
@@ -30,6 +30,7 @@ from .dl2014 import DL2014
from
.fritz2006
import
Fritz2006
from
.nebular_continuum
import
NebularContinuum
from
.nebular_lines
import
NebularLines
from
.schreiber2016
import
Schreiber2016
DATABASE_FILE
=
pkg_resources
.
resource_filename
(
__name__
,
'data.db'
)
...
...
@@ -235,6 +236,21 @@ class _NebularContinuum(BASE):
self
.
wave
=
nebular_continuum
.
wave
self
.
lumin
=
nebular_continuum
.
lumin
class
_Schreiber2016
(
BASE
):
"""Storage for Schreiber et al (2016) infra-red templates
"""
__tablename__
=
'schreiber2016_templates'
type
=
Column
(
Float
,
primary_key
=
True
)
tdust
=
Column
(
String
,
primary_key
=
True
)
wave
=
Column
(
PickleType
)
lumin
=
Column
(
PickleType
)
def
__init__
(
self
,
ir
):
self
.
type
=
ir
.
type
self
.
tdust
=
ir
.
tdust
self
.
wave
=
ir
.
wave
self
.
lumin
=
ir
.
lumin
class
Database
(
object
):
"""Object giving access to pcigale database."""
...
...
@@ -611,6 +627,8 @@ class Database(object):
dictionary of parameters and their values
"""
return
self
.
_get_parameters
(
_Dale2014
)
def
add_fritz2006
(
self
,
models
):
"""
...
...
@@ -792,6 +810,72 @@ class Database(object):
"""
return
self
.
_get_parameters
(
_NebularContinuum
)
def
add_schreiber2016
(
self
,
models
):
"""
Add Schreiber et al (2016) templates the collection.
Parameters
----------
models: list of pcigale.data.Schreiber2016 objects
"""
if
self
.
is_writable
:
for
model
in
models
:
self
.
session
.
add
(
_Schreiber2016
(
model
))
try
:
self
.
session
.
commit
()
except
exc
.
IntegrityError
:
self
.
session
.
rollback
()
raise
DatabaseInsertError
(
'The Schreiber2016 template is already in the base.'
)
else
:
raise
Exception
(
'The database is not writable.'
)
def
get_schreiber2016
(
self
,
type
,
tdust
):
"""
Get the Schreiber et al (2016) template corresponding to the given set of
parameters.
Parameters
----------
type: float
Dust template or PAH template
tdust: float
Dust temperature
Returns
-------
template: pcigale.data.Schreiber2016
The Schreiber et al. (2016) IR template.
Raises
------
DatabaseLookupError: if the requested template is not in the database.
"""
result
=
(
self
.
session
.
query
(
_Schreiber2016
).
filter
(
_Schreiber2016
.
type
==
type
).
filter
(
_Schreiber2016
.
tdust
==
tdust
).
first
())
if
result
:
return
Schreiber2016
(
result
.
type
,
result
.
tdust
,
result
.
wave
,
result
.
lumin
)
else
:
raise
DatabaseLookupError
(
"The Schreiber2016 template for type <{0}> and tdust <{1}> "
"is not in the database."
.
format
(
type
,
tdust
))
def
get_schreiber2016_parameters
(
self
):
"""Get parameters for the Scnreiber 2016 models.
Returns
-------
paramaters: dictionary
dictionary of parameters and their values
"""
return
self
.
_get_parameters
(
_Schreiber2016
)
def
_get_parameters
(
self
,
schema
):
"""Generic function to get parameters from an arbitrary schema.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment