Commit f5ebff9c authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Merge branch 'Fritz2006' of gitlab.oamp.dev:yannick/pcigale into develop

parents 42f4257a 16147565
...@@ -461,31 +461,67 @@ def build_dl2007(base): ...@@ -461,31 +461,67 @@ def build_dl2007(base):
def build_fritz2006(base): def build_fritz2006(base):
fritz2006_dir = os.path.join(os.path.dirname(__file__), 'fritz2006/') fritz2006_dir = os.path.join(os.path.dirname(__file__), 'fritz2006/')
model_list = np.genfromtxt(fritz2006_dir + "fritz.dat") # Parameters of Fritz+2006
psy = [0.001, 10.100, 20.100, 30.100, 40.100, 50.100, 60.100, 70.100,
for model_line in model_list: 80.100, 89.990] # Viewing angle in degrees
opening_angle = ["20", "40", "60"] # Theta = 2*(90 - opening_angle)
(model_nb, agn_type, r_ratio, tau, gamma = ["0.0", "2.0", "4.0", "6.0"]
beta, gamma, theta, psy) = model_line beta = ["-1.00", "-0.75", "-0.50", "-0.25", "0.00"]
tau = ["0.1", "0.3", "0.6", "1.0", "2.0", "3.0", "6.0", "10.0"]
# Convert some floats to int r_ratio = ["10", "30", "60", "100", "150"]
model_nb = int(model_nb)
agn_type = int(agn_type) # Read and convert the wavelength
datafile = open(fritz2006_dir + "ct{}al{}be{}ta{}rm{}.tot"
wave, lumin = np.genfromtxt("{}AGN_fritz{}.spec".format(fritz2006_dir, .format(opening_angle[0], gamma[0], beta[0], tau[0],
model_nb), r_ratio[0]))
skip_header=1).transpose() data = "".join(datafile.readlines()[-178:])
datafile.close()
# Convert the wavelength from Å to nm wave = np.genfromtxt(io.BytesIO(data.encode()), usecols=(0))
wave = wave * 0.1 wave *= 1e3
#Number of wavelength: 178; Number of comments lines: 28
# Convert the luminosity from erg/s^-1/Å to W/nm nskip = 28
lumin = lumin * 10 * 1.e-7 blocksize = 178
agn = Fritz2006(model_nb, agn_type, r_ratio, tau, beta, gamma, iter_params = ((oa, gam, be, ta, rm)
theta, psy, wave, lumin) for oa in opening_angle
for gam in gamma
base.add_fritz2006(agn) for be in beta
for ta in tau
for rm in r_ratio)
for params in iter_params:
filename = fritz2006_dir + "ct{}al{}be{}ta{}rm{}.tot".format(*params)
print("Importing {}...".format(filename))
try:
datafile = open(filename)
except IOError:
continue
data = datafile.readlines()
datafile.close()
for n in range(len(psy)):
block = data[nskip + blocksize * n + 4 * (n + 1) - 1:
nskip + blocksize * (n+1) + 4 * (n + 1) - 1]
lumin_therm, lumin_scatt, lumin_agn = np.genfromtxt(
io.BytesIO("".join(block).encode()), usecols=(2, 3, 4),
unpack=True)
# Remove NaN
lumin_therm = np.nan_to_num(lumin_therm)
lumin_scatt = np.nan_to_num(lumin_scatt)
lumin_agn = np.nan_to_num(lumin_agn)
# Conversion from erg/s/microns to W/nm
lumin_therm *= 1e-4
lumin_scatt *= 1e-4
lumin_agn *= 1e-4
# Normalization of the lumin_therm to 1W
norm = np.trapz(lumin_therm, x=wave)
lumin_therm = lumin_therm / norm
lumin_scatt = lumin_scatt / norm
lumin_agn = lumin_agn / norm
base.add_fritz2006(Fritz2006(params[4], params[3], params[2],
params[1], params[0], psy[n], wave,
lumin_therm, lumin_scatt, lumin_agn))
def build_nebular(base): def build_nebular(base):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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