Commit ff201074 authored by Yannick Roehlly's avatar Yannick Roehlly

Import subversion code

parent 5843307f
Python Code Investigating Galaxy Emission
# -*- coding: utf-8 -*-
"""
Copyright (C) 2012 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>
This script is used the build pcigale internal database containing:
- The various filter transmission tables;
- The Maraston 2005 single stellar population (SSP) data;
- The Dale and Helou 2002 infra-red templates.
"""
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
import glob
import numpy as np
from scipy import interpolate
from pcigale.data import Database, Filter, SspM2005
filters_dir = os.path.join(os.path.dirname(__file__), 'filters/')
m2005_dir = os.path.join(os.path.dirname(__file__), 'maraston2005/')
dh2002_dir = os.path.join(os.path.dirname(__file__), 'dh2002/')
def build_base():
base = Database(writable=True)
base.upgrade_base()
print('#' * 78)
########################################################################
# Filter transmission tables insertion #
########################################################################
print("1- Importing filters...\n")
for filter_file in glob.glob(filters_dir + '*.dat'):
with open(filter_file, 'r') as filter_file_read:
filter_name = filter_file_read.readline().strip('# \n\t')
filter_type = filter_file_read.readline().strip('# \n\t')
filter_description = filter_file_read.readline().strip('# \n\t')
filter_table = np.genfromtxt(filter_file)
# The table is transposed to have table[0] containing the wavelength
# and table[1] containing the transmission.
filter_table = filter_table.transpose()
# We convert the wavelength from Å to nm.
filter_table[0] *= 0.1
print("Importing %s... (%s points)" % (filter_name,
filter_table.shape[1]))
new_filter = Filter(filter_name, filter_description,
filter_type, filter_table)
# We normalise the filter and compute the effective wavelength.
new_filter.normalise()
base.add_filter(new_filter)
print("\nDONE\n")
print('#' * 78)
########################################################################
# Maraston 2005 SSP insertion #
########################################################################
print("2- Importing Maraston 2005 SSP\n")
# Age grid (1My to 13.7Gy with 1My step)
age_grid = np.arange(1e-3, 13.701, 1e-3)
# Transpose the table to have access to each value vector on the first
# axis
kroupa_mass = np.genfromtxt(m2005_dir + 'stellarmass.kroupa').transpose()
salpeter_mass = \
np.genfromtxt(m2005_dir + '/stellarmass.salpeter').transpose()
for spec_file in glob.glob(m2005_dir + '*.rhb'):
print("Importing %s..." % spec_file)
spec_table = np.genfromtxt(spec_file).transpose()
metallicity = spec_table[1, 0]
if 'krz' in spec_file:
imf = 'kr'
mass_table = np.copy(kroupa_mass)
elif 'ssz' in spec_file:
imf = 'ss'
mass_table = np.copy(salpeter_mass)
else:
raise ValueError('Unknown IMF!!!')
# Keep only the actual metallicity values in the mass table
# we don't take the first column which contains metallicity
mass_table = mass_table[1:, mass_table[0] == metallicity]
# Interpolate the mass table over the new age grid
mass_table = interpolate.interp1d(mass_table[0], mass_table)(age_grid)
# Remove the age column from the mass table
mass_table = np.delete(mass_table, 0, 0)
# Remove the metallicity column from the spec table
spec_table = np.delete(spec_table, 1, 0)
# Convert the wavelength from Å to nm
spec_table[1] = spec_table[1] * 0.1
# For all ages, the lambda grid is the same.
lambda_grid = np.unique(spec_table[1])
# Creation of the age vs lambda flux table
tmpList = []
for wavelength in lambda_grid:
[age_grid_orig, lambda_grid_orig, flux_orig] = \
spec_table[:, spec_table[1, :] == wavelength]
flux_orig = flux_orig * 10 * 1.e-7 # From erg/s^-1/Å to W/nm
flux_regrid = interpolate.interp1d(age_grid_orig,
flux_orig)(age_grid)
tmpList.append(flux_regrid)
flux_age = np.array(tmpList)
base.add_ssp_m2005(SspM2005(imf, metallicity, age_grid,
lambda_grid, mass_table, flux_age))
print("\nDONE\n")
print('#' * 78)
########################################################################
# Dale and Helou 2002 templates insertion #
########################################################################
print("3- Importing Dale and Helou 2002 templates\n")
# Getting the alpha grid for the templates
dhcal = np.genfromtxt(dh2002_dir + 'dhcal.dat')
alpha_grid = dhcal[:, 1]
# Getting the lambda grid for the templates (we checked that all share the
# same grid).
first_template = np.genfromtxt(dh2002_dir + 'irdh01.spec', skip_header=1)
lambda_grid = first_template[:, 0] * 0.1 # Convert Å to nm
templates = []
for i in range(len(alpha_grid)):
filename = dh2002_dir + 'irdh' + ("%02d" % (i + 1)) + '.spec'
print("Importing %s..." % filename)
table = np.genfromtxt(filename, skip_header=1)[:, 1] # Luminosity
# column
# The table give the luminosity density in Lsun/Å normalised to 1 Lsun
# over the full spectrum. As we converted the wavelengths to nm, we
# must multiply the density per 10 to keep the normalisation.
table = table * 10
templates.append(table)
templates = np.array(templates)
data = (alpha_grid, lambda_grid, templates)
base.add_dh2002_infrared_templates(data)
print("\nDONE\n")
print('#' * 78)
base.session.close_all()
if __name__ == '__main__':
build_base()
The files in this directory are the Dale and Helou (2002) templates as used
by the Fortran Cigale code. They are different from the pristine Dale and
Helou templates as the stellar contribution has been removed (see Noll et
al., 2009).
# Ndhmod
# 64
# Ndh alpha lgfnu60_fnu100 lgLIR_M[Lsol] lgLIR_C[Lsol]
01 0.0625 0.2135 14.350 14.168
02 0.1250 0.2104 14.326 14.148
03 0.1875 0.2069 14.300 14.125
04 0.2500 0.2032 14.272 14.102
05 0.3125 0.1991 14.241 14.077
06 0.3750 0.1947 14.208 14.048
07 0.4375 0.1898 14.171 14.016
08 0.5000 0.1846 14.132 13.984
09 0.5625 0.1787 14.089 13.946
10 0.6250 0.1723 14.042 13.905
11 0.6875 0.1653 13.990 13.860
12 0.7500 0.1576 13.934 13.810
13 0.8125 0.1490 13.872 13.754
14 0.8750 0.1395 13.803 13.693
15 0.9375 0.1291 13.729 13.626
16 1.0000 0.1175 13.647 13.550
17 1.0625 0.1046 13.556 13.466
18 1.1250 0.0903 13.456 13.372
19 1.1875 0.0744 13.346 13.268
20 1.2500 0.0567 13.224 13.151
21 1.3125 0.0371 13.091 13.021
22 1.3750 0.0154 12.944 12.877
23 1.4375 -0.0084 12.784 12.717
24 1.5000 -0.0345 12.611 12.542
25 1.5625 -0.0629 12.423 12.350
26 1.6250 -0.0933 12.222 12.143
27 1.6875 -0.1257 12.008 11.921
28 1.7500 -0.1596 11.785 11.685
29 1.8125 -0.1944 11.554 11.434
30 1.8750 -0.2298 11.318 11.167
31 1.9375 -0.2649 11.081 10.879
32 2.0000 -0.2990 10.849 10.551
33 2.0625 -0.3316 10.625 10.130
34 2.1250 -0.3621 10.412 9.452
35 2.1875 -0.3900 10.214 8.321
36 2.2500 -0.4151 10.035 7.106
37 2.3125 -0.4372 9.876 6.024
38 2.3750 -0.4565 9.735 5.079
39 2.4375 -0.4731 9.614 4.268
40 2.5000 -0.4871 9.511 3.584
41 2.5625 -0.4989 9.424 3.009
42 2.6250 -0.5086 9.353 2.536
43 2.6875 -0.5166 9.294 2.146
44 2.7500 -0.5232 9.246 1.825
45 2.8125 -0.5284 9.209 1.572
46 2.8750 -0.5327 9.178 1.363
47 2.9375 -0.5361 9.154 1.197
48 3.0000 -0.5388 9.136 1.066
49 3.0625 -0.5408 9.123 0.969
50 3.1250 -0.5424 9.113 0.891
51 3.1875 -0.5435 9.107 0.838
52 3.2500 -0.5444 9.103 0.794
53 3.3125 -0.5450 9.100 0.765
54 3.3750 -0.5453 9.100 0.750
55 3.4375 -0.5454 9.102 0.745
56 3.5000 -0.5455 9.103 0.740
57 3.5625 -0.5454 9.106 0.745
58 3.6250 -0.5451 9.110 0.760
59 3.6875 -0.5448 9.115 0.774
60 3.7500 -0.5445 9.119 0.789
61 3.8125 -0.5440 9.125 0.813
62 3.8750 -0.5436 9.130 0.832
63 3.9375 -0.5430 9.136 0.861
64 4.0000 -0.5425 9.142 0.885
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
# BX_B90
# energy
# Bessel 90 [to use in U-B]
3600. 0.000
3700. 0.026
3800. 0.120
3900. 0.523
4000. 0.875
4100. 0.956
4200. 1.000
4300. 0.998
4400. 0.972
4500. 0.901
4600. 0.793
4700. 0.694
4800. 0.587
4900. 0.470
5000. 0.362
5100. 0.263
5200. 0.169
5300. 0.107
5400. 0.049
5500. 0.010
5600. 0.000
# B_B90
# energy
# Bessel 90
3600. 0.000
3700. 0.030
3800. 0.134
3900. 0.567
4000. 0.920
4100. 0.978
4200. 1.000
4300. 0.978
4400. 0.935
4500. 0.853
4600. 0.740
4700. 0.640
4800. 0.536
4900. 0.424
5000. 0.325
5100. 0.235
5200. 0.150
5300. 0.095
5400. 0.043
5500. 0.009
5600. 0.000
# FUV
# photon
# GALEX 1500A
1340.62 0.0000
1350.49 0.1154
1370.21 0.1765
1399.81 0.1231
1449.13 0.3367
1477.08 0.3685
1500.10 0.3504
1519.83 0.3470
1549.42 0.2617
1608.61 0.2549
1648.07 0.1601
1705.61 0.1188
1750.00 0.1050
1810.83 -0.0009
# H
# energy
# Bessel & Brett 1988
14800. 0.000
15000. 0.444
15200. 0.869
15400. 0.949
15600. 0.990
15800. 0.960
16000. 1.000
16200. 1.000
16400. 1.000
16600. 1.000
16800. 1.000
17000. 1.000
17200. 0.960
17400. 0.879
17600. 0.848
17800. 0.717
18000. 0.525
18200. 0.020
18400. 0.000
# H_2mass
# photon
# 2MASS, Cohen et al. 2003
14620. 2.76582E-03
14780. 8.08827E-03
14860. 2.87356E-02
14930. 8.71147E-02
15040. 0.201449
15150. 0.438159
15280. 0.686357
15390. 0.818076
15460. 0.882073
15510. 0.911825
15560. 0.926872
15650. 0.929288
15720. 0.872747
15770. 0.856619
15830. 0.882556
15920. 0.918084
15970. 0.926654
16020. 0.907594
16130. 0.925974
16190. 0.920496
16280. 0.924198
16330. 0.923533
16420. 0.941788
16480. 0.949134
16570. 0.980658
16590. 0.993744
16710. 1.00000
16840. 0.956052
17010. 0.924116
17150. 0.982120
17270. 0.991589
17390. 0.988683
17460. 0.979168
17510. 0.968184
17530. 0.937040
17560. 0.918998
17640. 0.842264
17750. 0.667111
17850. 0.269402
17900. 0.451630
17960. 0.173062
18030. 0.107726
18100. 7.07003E-02
18130. 5.10945E-03
18180. 1.99705E-02
# IC
# energy
# I Cousins; Bessel 90
7000. 0.000
7100. 0.024
7200. 0.232
7300. 0.555
7400. 0.785
7500. 0.910
7600. 0.965
7700. 0.985
7800. 0.990
7900. 0.995
8000. 1.000
8100. 1.000
8200. 0.990
8300. 0.980
8400. 0.950
8500. 0.910
8600. 0.860
8700. 0.750
8800. 0.560
8900. 0.330
9000. 0.150
9100. 0.030
9200. 0.000
# IJ
# energy
# I Johnson; Johnson 1965
6800. 0.000
6900. 0.005
7000. 0.010
7100. 0.090
7200. 0.170
7300. 0.265
7400. 0.360
7500. 0.460
7600. 0.560
7700. 0.660
7800. 0.760
7900. 0.860
8000. 0.960
8100. 0.970
8200. 0.980
8300. 0.985
8400. 0.990
8500. 0.995
8600. 1.000
8700. 0.990
8800. 0.980
8900. 0.955
9000. 0.930
9100. 0.885
9200. 0.840
9300. 0.775
9400. 0.710
9500. 0.645
9600. 0.580
9700. 0.525
9800. 0.470
9900. 0.415
10000. 0.360
10100. 0.320
10200. 0.280
10300. 0.240
10400. 0.200
10500. 0.175
10600. 0.150
10700. 0.125
10800. 0.100
10900. 0.090
11000. 0.080
11100. 0.065
11200. 0.050
11300. 0.040
11400. 0.030
11500. 0.025
11600. 0.020
11700. 0.015
11800. 0.010
11900. 0.005
12000. 0.000
# IRAC1
# photon
# IRAC channel 1
29750 5.26e-04
30000 7.65e-04
30250 4.73e-04
30500 3.53e-04
30750 4.62e-04
31000 3.19e-04
31250 3.18e-03
31500 2.23e-02
31750 1.74e-01
32000 3.66e-01
32250 3.44e-01
32500 3.53e-01
32750 3.98e-01
33000 4.07e-01
33250 3.97e-01
33500 3.99e-01
33750 3.94e-01
34000 4.10e-01
34250 4.30e-01
34500 4.11e-01
34750 4.09e-01
35000 4.38e-01
35250 4.54e-01
35500 4.49e-01
35750 4.41e-01
36000 4.48e-01
36250 4.49e-01
36500 4.36e-01
36750 4.28e-01
37000 4.42e-01
37250 4.59e-01
37500 4.63e-01
37750 4.55e-01
38000 4.49e-01
38250 4.42e-01
38500 4.25e-01
38750 4.25e-01
39000 4.34e-01
39250 2.29e-01
39500 3.48e-02
39750 4.55e-03
40000 8.08e-04
40250 4.74e-04
40500 4.03e-04
40750 3.44e-04
41000 2.67e-04
41250 2.07e-04
41500 2.04e-04
# IRAC2
# photon
# IRAC channel 2
37000 4.76e-04
37300 4.91e-04
37600 4.82e-04
37900 2.15e-04
38200 1.84e-04
38500 2.54e-04
38800 5.25e-04
39100 2.75e-03
39400 1.27e-02
39700 5.01e-02
40000 2.28e-01
40300 3.95e-01
40600 3.69e-01
40900 3.33e-01
41200 3.39e-01
41500 3.90e-01
41800 4.51e-01
42100 4.83e-01
42400 4.86e-01
42700 4.66e-01
43000 4.66e-01
43300 4.88e-01
43600 5.01e-01
43900 5.13e-01
44200 5.29e-01
44500 5.35e-01
44800 5.30e-01
45100 5.16e-01
45400 5.01e-01
45700 4.93e-01
46000 4.83e-01
46300 4.63e-01
46600 4.62e-01
46900 4.75e-01
47200 4.84e-01
47500 4.75e-01
47800 4.57e-01
48100 4.41e-01
48400 4.36e-01
48700 4.35e-01
49000 4.35e-01
49300 4.28e-01
49600 3.80e-01
49900 3.69e-01
50200 2.21e-01
50500 1.81e-02
50800 1.79e-03
51100 2.61e-04
51400 1.82e-04
51700 1.20e-04
52000 7.75e-05
52300 5.81e-05
52600 4.58e-05
52900 2.37e-05
# IRAC3
# photon
# IRAC channel 3
46500 7.71e-05
47000 5.78e-05
47500 6.15e-05