Commit 5373a4b9 authored by Yannick Roehlly's avatar Yannick Roehlly
Browse files

Better parameter handling for analysis module

For redshift and analysis module, we don't need to evaluate each
parameter as an array as we don't expect arrays here (and that force us
to use parameter[0] to get the value).

Configobj return strings, to evaluate the booleans on their "string"
content.
parent 5a86f3b0
......@@ -138,17 +138,17 @@ class Module(common.AnalysisModule):
sys.exit()
# Open the warehouse
# TODO Why is parameters["storage_type"] an array?
sed_warehouse = SedWarehouse(
cache_type=parameters["storage_type"][0])
cache_type=parameters["storage_type"])
# Get the parameters
analysed_variables = parameters["analysed_variables"]
save_best_sed = parameters["save_best_sed"]
plot_best_sed = parameters["plot_best_sed"]
plot_chi2_distribution = parameters["plot_chi2_distribution"]
save_pdf = parameters["save_pdf"]
plot_pdf = parameters["plot_pdf"]
save_best_sed = (parameters["save_best_sed"].lower() == "true")
plot_best_sed = (parameters["plot_best_sed"].lower() == "true")
plot_chi2_distribution = (
parameters["plot_chi2_distribution"].lower() == "true")
save_pdf = (parameters["save_pdf"].lower() == "true")
plot_pdf = (parameters["plot_pdf"].lower() == "true")
pdf_max_bin_number = int(parameters["pdf_max_bin_number"])
results = {'galaxy_mass': [], 'galaxy_mass_err': []}
......
......@@ -78,8 +78,8 @@ class Module(common.AnalysisModule):
"""
out_file = parameters["output_file"][0]
out_format = parameters["output_format"][0]
out_file = parameters["output_file"]
out_format = parameters["output_format"]
# If the output file already exists make a copy.
if os.path.isfile(out_file):
......
......@@ -48,8 +48,11 @@ class Module(common.SEDCreationModule):
Dictionary with the module parameters (redshift and rtau)
"""
redshift = float(self.parameters["redshift"])
dimming = (self.parameters['dimming'].lower() == "true")
rtau = float(self.parameters["rtau"])
if self.parameters['redshift'] == 0:
if redshift == 0:
# If redshift is 0, we do nothing
pass
else:
......@@ -57,14 +60,14 @@ class Module(common.SEDCreationModule):
lsstSed = lsst.Sed()
# First, we get the redshifted spectrum of the galaxy
wavelen, flambda = lsstSed.redshiftSED(self.parameters['redshift'],
self.parameters['dimming'],
wavelen, flambda = lsstSed.redshiftSED(redshift,
dimming,
sed.wavelength_grid,
sed.luminosity)
wavelen, red_l_lambda = lsstSed.addIGMattenuation(
self.parameters['redshift'],
self.parameters['rtau'],
redshift,
rtau,
wavelen=wavelen,
flambda=flambda
)
......@@ -82,9 +85,8 @@ class Module(common.SEDCreationModule):
sed.add_module(self.name, self.parameters)
sed.add_info("redshift" + self.postfix,
self.parameters['redshift'])
sed.add_info('rtau' + self.postfix, self.parameters['rtau'])
sed.add_info("redshift" + self.postfix, redshift)
sed.add_info('rtau' + self.postfix, rtau)
sed.add_contribution(
self.name,
......
......@@ -265,16 +265,12 @@ class Configuration(object):
self.config['sed_creation_modules'][module].items():
module_params[key] = evaluate_description(value)
configuration['sed_modules_params'].append(module_params)
# Parsing the redshift module parameters
configuration['redshift_configuration'] = {}
for key, value in self.config['redshift_configuration'].items():
configuration['redshift_configuration'][key] = \
evaluate_description(value)
# Parsing the statistical analysis parameters
configuration['analysis_method_params'] = {}
for key, value in self.config['analysis_configuration'].items():
configuration['analysis_method_params'][key] = \
evaluate_description(value)
# We don't need to "evaluate" the configuration values for the
# redshit and analysis modules as we don't expect multiple values here.
configuration['redshift_configuration'] = \
self.config['redshift_configuration']
configuration['analysis_method_params'] = \
self.config['analysis_configuration']
return configuration
......
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