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

We rely on OrderedDict to keep the order of the parameters. However given the...

We rely on OrderedDict to keep the order of the parameters. However given the way the code is structured currently, there is really no reason for this. So let's just switch to the standard dictionary. This has two advantages. First the standard dictionary is much faster than OrderedDict (implemented in C rather than in pure python). Then, standard dictionaries are marshalable, which makes them usable as keys for other dictionaries.
parent f84db63e
...@@ -19,7 +19,6 @@ This module implements the radio emission of galaxies, taking into account only ...@@ -19,7 +19,6 @@ This module implements the radio emission of galaxies, taking into account only
import numpy as np import numpy as np
import scipy.constants as cst import scipy.constants as cst
from collections import OrderedDict
from . import CreationModule from . import CreationModule
...@@ -32,7 +31,7 @@ class Radio(CreationModule): ...@@ -32,7 +31,7 @@ class Radio(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("qir", ( ("qir", (
"float", "float",
"The value of the FIR/radio correlation coefficient.", "The value of the FIR/radio correlation coefficient.",
...@@ -45,7 +44,7 @@ class Radio(CreationModule): ...@@ -45,7 +44,7 @@ class Radio(CreationModule):
)) ))
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("qir", "The value of the FIR/radio correlation coefficient."), ("qir", "The value of the FIR/radio correlation coefficient."),
("alpha", "The slope of the power-law synchrotron emission.") ("alpha", "The slope of the power-law synchrotron emission.")
]) ])
......
...@@ -18,8 +18,6 @@ is changed, this module may need to be adapted. ...@@ -18,8 +18,6 @@ is changed, this module may need to be adapted.
""" """
from collections import OrderedDict
import numpy as np import numpy as np
from scipy.constants import parsec from scipy.constants import parsec
from scipy.misc import factorial from scipy.misc import factorial
...@@ -143,7 +141,7 @@ class Redshifting(CreationModule): ...@@ -143,7 +141,7 @@ class Redshifting(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("redshift", ( ("redshift", (
"float", "float",
"Redshift to apply to the galaxy. Leave empty to use the redshifts" "Redshift to apply to the galaxy. Leave empty to use the redshifts"
......
...@@ -13,7 +13,6 @@ decreasing exponentials. ...@@ -13,7 +13,6 @@ decreasing exponentials.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -29,7 +28,7 @@ class Sfh2Exp(CreationModule): ...@@ -29,7 +28,7 @@ class Sfh2Exp(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("tau_main", ( ("tau_main", (
"float", "float",
"e-folding time of the main stellar population model in Myr.", "e-folding time of the main stellar population model in Myr.",
...@@ -68,7 +67,7 @@ class Sfh2Exp(CreationModule): ...@@ -68,7 +67,7 @@ class Sfh2Exp(CreationModule):
)), )),
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("tau_main", "e-folding time of the main stellar population model " ("tau_main", "e-folding time of the main stellar population model "
"in Myr."), "in Myr."),
("tau_burst", "e-folding time of the late starburst population model " ("tau_burst", "e-folding time of the late starburst population model "
......
...@@ -22,7 +22,6 @@ and interpolate the values of a, b and c. ...@@ -22,7 +22,6 @@ and interpolate the values of a, b and c.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -39,7 +38,7 @@ class SfhBuat08(CreationModule): ...@@ -39,7 +38,7 @@ class SfhBuat08(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("velocity", ( ("velocity", (
"float", "float",
"Rotational velocity of the galaxy in km/s. Must be between 80 " "Rotational velocity of the galaxy in km/s. Must be between 80 "
...@@ -59,7 +58,7 @@ class SfhBuat08(CreationModule): ...@@ -59,7 +58,7 @@ class SfhBuat08(CreationModule):
)) ))
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("sfh.velocity", "Rotational velocity of the galaxy in km/s."), ("sfh.velocity", "Rotational velocity of the galaxy in km/s."),
("galaxy_mass", "Mass of the galaxy in solar mass.") ("galaxy_mass", "Mass of the galaxy in solar mass.")
]) ])
......
...@@ -15,7 +15,6 @@ constant. ...@@ -15,7 +15,6 @@ constant.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -30,7 +29,7 @@ class SfhQuench(CreationModule): ...@@ -30,7 +29,7 @@ class SfhQuench(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("quenching_age", ( ("quenching_age", (
"integer", "integer",
"Age of the galaxy at which the quenching happens in Myr.", "Age of the galaxy at which the quenching happens in Myr.",
...@@ -51,7 +50,7 @@ class SfhQuench(CreationModule): ...@@ -51,7 +50,7 @@ class SfhQuench(CreationModule):
)) ))
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("sfh.quenching_age", "Age of the galaxt when the quenching occurs " ("sfh.quenching_age", "Age of the galaxt when the quenching occurs "
"in Myr."), "in Myr."),
("sfh.quenching_factor", "Quenching factor applied.") ("sfh.quenching_factor", "Quenching factor applied.")
......
...@@ -13,7 +13,6 @@ regularly-spaced short constant SF events. ...@@ -13,7 +13,6 @@ regularly-spaced short constant SF events.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -29,7 +28,7 @@ class SfhComb(CreationModule): ...@@ -29,7 +28,7 @@ class SfhComb(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("N_events", ( ("N_events", (
"integer", "integer",
"Number of individual star formation events. ", "Number of individual star formation events. ",
...@@ -66,7 +65,7 @@ class SfhComb(CreationModule): ...@@ -66,7 +65,7 @@ class SfhComb(CreationModule):
)), )),
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("N_events", "Number of individual star formation events"), ("N_events", "Number of individual star formation events"),
("t_duration", "Length of each individual star formation event " ("t_duration", "Length of each individual star formation event "
"in Myr."), "in Myr."),
......
...@@ -13,7 +13,6 @@ regularly-spaced short regularly-spaced delayed-SFH SF events. ...@@ -13,7 +13,6 @@ regularly-spaced short regularly-spaced delayed-SFH SF events.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -29,7 +28,7 @@ class SfhComb(CreationModule): ...@@ -29,7 +28,7 @@ class SfhComb(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("N_events", ( ("N_events", (
"integer", "integer",
"Number of individual star formation events. ", "Number of individual star formation events. ",
...@@ -65,7 +64,7 @@ class SfhComb(CreationModule): ...@@ -65,7 +64,7 @@ class SfhComb(CreationModule):
)), )),
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("N_events", "Number of individual star formation events"), ("N_events", "Number of individual star formation events"),
("tau_events", "e-folding time of all short events in Myr.."), ("tau_events", "e-folding time of all short events in Myr.."),
("age", "Age of the stellar population in the galaxy in Myr."), ("age", "Age of the stellar population in the galaxy in Myr."),
......
...@@ -14,7 +14,6 @@ rise of the SFR up to a maximum, followed by an exponential decrease. ...@@ -14,7 +14,6 @@ rise of the SFR up to a maximum, followed by an exponential decrease.
""" """
import numpy as np import numpy as np
from collections import OrderedDict
from . import CreationModule from . import CreationModule
# Time lapse used in the age grid in Myr. If should be consistent with the # Time lapse used in the age grid in Myr. If should be consistent with the
...@@ -30,7 +29,7 @@ class SFHDelayed(CreationModule): ...@@ -30,7 +29,7 @@ class SFHDelayed(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("tau_main", ( ("tau_main", (
"float", "float",
"e-folding time of the main stellar population model in Myr.", "e-folding time of the main stellar population model in Myr.",
...@@ -54,7 +53,7 @@ class SFHDelayed(CreationModule): ...@@ -54,7 +53,7 @@ class SFHDelayed(CreationModule):
)) ))
]) ])
out_parameter_list = OrderedDict([ out_parameter_list = dict([
("tau_main", "e-folding time of the main stellar population model " ("tau_main", "e-folding time of the main stellar population model "
"in Myr."), "in Myr."),
("age", "Age of the oldest stars in the galaxy in Myr."), ("age", "Age of the oldest stars in the galaxy in Myr."),
......
...@@ -13,7 +13,6 @@ This module reads the star formation history in a file. ...@@ -13,7 +13,6 @@ This module reads the star formation history in a file.
from astropy.table import Table from astropy.table import Table
import numpy as np import numpy as np
from collections import OrderedDict
from ..utils import read_table from ..utils import read_table
from . import CreationModule from . import CreationModule
...@@ -29,7 +28,7 @@ class SfhFromFile(CreationModule): ...@@ -29,7 +28,7 @@ class SfhFromFile(CreationModule):
""" """
parameter_list = OrderedDict([ parameter_list = dict([
("filename", ( ("filename", (
"str", "str",
"Name of the file containing the SFH. The first column must be " "Name of the file containing the SFH. The first column must be "
......
...@@ -263,7 +263,7 @@ class Configuration(object): ...@@ -263,7 +263,7 @@ class Configuration(object):
# Parsing the SED modules parameters # Parsing the SED modules parameters
configuration['creation_modules_params'] = [] configuration['creation_modules_params'] = []
for module in self.config['creation_modules']: for module in self.config['creation_modules']:
module_params = collections.OrderedDict() module_params = {}
for key, value in \ for key, value in \
self.config['sed_creation_modules'][module].items(): self.config['sed_creation_modules'][module].items():
module_params[key] = evaluate_description(value) module_params[key] = evaluate_description(value)
......
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