Commit 10165bcc authored by Yannick Roehlly's avatar Yannick Roehlly

Cast numeric parameters to their correct type

To avoid problems that might occur when, for instance, using an integer
instead of a float, we now cast the module parameters to their expected
type. This will also have the advantage to raise an error when a
parameter can't be interpreted with its expected type.

Also, use integer for age parameters as we are now using Myr as unit.
parent fea97ceb
......@@ -35,7 +35,7 @@ class Module(common.SEDCreationModule):
None
),
"separation_age": (
"float",
"integer",
"Age [Myr] of the separation between the young and the old star "
"populations. The default value in 10^7 years (10 Myr). Set "
"to 0 not to differentiate ages (only an old population).",
......@@ -71,8 +71,8 @@ class Module(common.SEDCreationModule):
"""
imf = self.parameters["imf"]
metallicity = self.parameters["metallicity"]
separation_age = self.parameters["separation_age"]
metallicity = float(self.parameters["metallicity"])
separation_age = int(self.parameters["separation_age"])
sfh_time, sfh_sfr = sed.sfh
# Age of the galaxy at each time of the SFH
......
......@@ -51,7 +51,7 @@ class Module(common.SEDCreationModule):
parameters : dictionary containing the parameters
"""
alpha = parameters["alpha"]
alpha = float(parameters["alpha"])
attenuation_value_names = parameters["attenuation_value_names"]
# Get the template set out of the database
......
......@@ -258,14 +258,14 @@ class Module(common.SEDCreationModule):
name = self.name or 'dustatt_calzleit_'
wavelength = sed.wavelength_grid
ebvs_young = parameters["E_BVs_young"]
ebvs_old = parameters["E_BVs_old_factor"] * ebvs_young
ebvs_young = float(parameters["E_BVs_young"])
ebvs_old = float(parameters["E_BVs_old_factor"]) * ebvs_young
young_contrib = parameters["young_contribution_name"]
old_contrib = parameters["old_contribution_name"]
uv_bump_wavelength = parameters["uv_bump_wavelength"]
uv_bump_width = parameters["uv_bump_wavelength"]
uv_bump_amplitude = parameters["uv_bump_amplitude"]
powerlaw_slope = parameters["powerlaw_slope"]
uv_bump_wavelength = float(parameters["uv_bump_wavelength"])
uv_bump_width = float(parameters["uv_bump_wavelength"])
uv_bump_amplitude = float(parameters["uv_bump_amplitude"])
powerlaw_slope = float(parameters["powerlaw_slope"])
filter_list = parameters["filters"]
# Fλ fluxes in each filter before attenuation.
......
......@@ -179,14 +179,14 @@ class Module(common.SEDCreationModule):
name = self.name or 'dustatt_powerlaw_'
wavelength = sed.wavelength_grid
av_young = parameters["Av_young"]
av_old = parameters["Av_old_factor"] * av_young
av_young = float(parameters["Av_young"])
av_old = float(parameters["Av_old_factor"] * av_young)
young_contrib = parameters["young_contribution_name"]
old_contrib = parameters["old_contribution_name"]
uv_bump_wavelength = parameters["uv_bump_wavelength"]
uv_bump_width = parameters["uv_bump_wavelength"]
uv_bump_amplitude = parameters["uv_bump_amplitude"]
powerlaw_slope = parameters["powerlaw_slope"]
uv_bump_wavelength = float(parameters["uv_bump_wavelength"])
uv_bump_width = float(parameters["uv_bump_wavelength"])
uv_bump_amplitude = float(parameters["uv_bump_amplitude"])
powerlaw_slope = float(parameters["powerlaw_slope"])
filter_list = parameters["filters"]
# Fλ fluxes in each filter before attenuation.
......
......@@ -57,7 +57,7 @@ class Module(common.SEDCreationModule):
None
),
'separation_age': (
'float',
'integer',
"Age [Myr] of the separation between the young and the old star "
"populations. The default value in 10^7 years (10 Myr). Set to "
"0 not to differentiate ages (only an old population).",
......@@ -118,8 +118,8 @@ class Module(common.SEDCreationModule):
"""
imf = self.parameters["imf"]
metallicity = self.parameters["metallicity"]
separation_age = self.parameters["separation_age"]
metallicity = float(self.parameters["metallicity"])
separation_age = int(self.parameters["separation_age"])
sfh_time, sfh_sfr = sed.sfh
# Age of the galaxy at each time of the SFH
......
......@@ -41,13 +41,13 @@ class Module(common.SEDCreationModule):
None
),
"age": (
"float",
"integer",
"Age of the oldest stars in the galaxy in Myr. The precision "
"is 1 Myr.",
None
),
"burst_age": (
"float",
"integer",
"Age of the late burst in Myr. Precision is 1 Myr.",
None
)
......@@ -73,11 +73,11 @@ class Module(common.SEDCreationModule):
"""
tau_main = parameters["tau_main"]
tau_burst = parameters["tau_burst"]
f_burst = parameters["f_burst"]
age = parameters["age"]
burst_age = parameters["burst_age"]
tau_main = float(parameters["tau_main"])
tau_burst = float(parameters["tau_burst"])
f_burst = float(parameters["f_burst"])
age = int(parameters["age"])
burst_age = int(parameters["burst_age"])
# Time grid and age. If needed, the age is rounded to the inferior Myr
time_grid = np.arange(AGE_LAPSE, age + AGE_LAPSE, AGE_LAPSE)
......
......@@ -32,14 +32,14 @@ class Module(common.SEDCreationModule):
None
),
"sfr_column": (
"int",
"integer",
"List of column numbers where the star formation rates will "
"be read..",
None
),
"age": (
"float",
"List of ages [Myr] where each SFH will be looked at.",
"integer",
"Age [Myr] where each SFH will be looked at.",
None
)
}
......@@ -64,7 +64,7 @@ class Module(common.SEDCreationModule):
sfr_column_name = table.columns.keys[sfr_column_number]
sfr = table[sfr_column_name]
age = parameters['age']
age = int(parameters['age'])
# We cut the SFH to the desired age.
sfr = sfr[time_grid <= age]
......
......@@ -150,7 +150,7 @@ class Module(common.AnalysisModule):
plot_chi2_distribution = parameters["plot_chi2_distribution"]
save_pdf = parameters["save_pdf"]
plot_pdf = parameters["plot_pdf"]
pdf_max_bin_number = parameters["pdf_max_bin_number"]
pdf_max_bin_number = int(parameters["pdf_max_bin_number"])
results = {'galaxy_mass': [], 'galaxy_mass_err': []}
for variable in analysed_variables:
......
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