Commit cf3fceb4 authored by Yannick Roehlly's avatar Yannick Roehlly

Use & to enter a list as one parameter value

When one value for a parameter is a list (for instance the list of
attenuation keys for re-emission modules) we had to use the "eval [["a",
"b"]]" notation. Convert these module to use a single string with items
separated by a & ("a & b").

WARNING we must still change the way parameters are evaluated not to
return everytime a list.
parent 4fcb6311
......@@ -28,10 +28,12 @@ class Module(common.SEDCreationModule):
"Alpha slope.",
None
)),
('attenuation_value_names', (
'array of strings',
"List of attenuation value names (in the SED's info dictionary). "
"A new re-emission contribution will be added for each one.",
('attenuation_value_keys', (
'string',
"Keys of the SED information dictionary where the module will "
"look for the attenuation (in W) to re-emit. You can give several "
"keys separated with a & (don't use commas), a re-emission "
"contribution will be added for each key.",
None
))
])
......@@ -53,7 +55,9 @@ class Module(common.SEDCreationModule):
"""
alpha = float(self.parameters["alpha"])
attenuation_value_names = self.parameters["attenuation_value_names"]
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
ir_template = self.dh2002.get_template(alpha)
......@@ -63,7 +67,7 @@ class Module(common.SEDCreationModule):
sed.add_module(name, self.parameters)
sed.add_info(name + '_alpha', alpha)
for attenuation in attenuation_value_names:
for attenuation in attenuation_value_keys:
sed.add_contribution(
name + '_' + attenuation,
self.dh2002.wavelength_grid,
......
......@@ -44,10 +44,12 @@ class Module(common.SEDCreationModule):
"Fraction illuminated from Umin to Umax",
None
)),
('attenuation_value_names', (
'list of strings',
"List of attenuation value names (in the SED's info dictionary). "
"A new re-emission contribution will be added for each one.",
('attenuation_value_keys', (
'string',
"Keys of the SED information dictionary where the module will "
"look for the attenuation (in W) to re-emit. You can give several "
"keys separated with a & (don't use commas), a re-emission "
"contribution will be added for each key.",
None
))
])
......@@ -96,6 +98,9 @@ class Module(common.SEDCreationModule):
parameters : dictionary containing the parameters
"""
attenuation_value_keys = [
item.strip() for item in
self.parameters["attenuation_value_keys"].split("&")]
# Base name for adding information to the SED.
name = self.name or 'dl2007'
......@@ -106,7 +111,7 @@ class Module(common.SEDCreationModule):
sed.add_info(name + '_umax', self.parameters["umax"])
sed.add_info(name + '_gamma', self.parameters["gamma"])
for attenuation in self.parameters['attenuation_value_names']:
for attenuation in attenuation_value_keys:
sed.add_contribution(
name + '_Umin_Umin_' + attenuation,
self.model_minmin.wave,
......
......@@ -215,9 +215,11 @@ class Module(common.SEDCreationModule):
None
)),
("filters", (
"list of strings",
"List of the filters for which the attenuation will be computed.",
['V_B90', 'FUV']
"string",
"Filters for which the attenuation will be computed and added to "
"the SED information dictionary. You can give several filter "
"names separated by a & (don't use commas).",
"V_B90 & FUV"
))
])
......@@ -242,9 +244,11 @@ class Module(common.SEDCreationModule):
def _init_code(self):
"""Get the filters from the database"""
filter_list = [item.strip() for item in
self.parameters["filters"].split("&")]
self.filters = {}
base = Database()
for filter_name in self.parameters["filters"]:
for filter_name in filter_list:
self.filters[filter_name] = base.get_filter(filter_name)
base.close()
......
......@@ -141,9 +141,11 @@ class Module(common.SEDCreationModule):
-0.7
)),
("filters", (
"list of strings",
"List of the filters for which the attenuation will be computed.",
['V_B90', 'FUV']
"string",
"Filters for which the attenuation will be computed and added to "
"the SED information dictionary. You can give several filter "
"names separated by a & (don't use commas).",
"V_B90 & FUV"
))
])
......@@ -167,9 +169,11 @@ class Module(common.SEDCreationModule):
def _init_code(self):
"""Get the filters from the database"""
filter_list = [item.strip() for item in
self.parameters["filters"].split("&")]
self.filters = {}
base = Database()
for filter_name in self.parameters["filters"]:
for filter_name in filter_list:
self.filters[filter_name] = base.get_filter(filter_name)
base.close()
......
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