Commit eabdd39f authored by Médéric Boquien's avatar Médéric Boquien

When the redshifts are not indicated in pcigale.ini, compute them from the...

When the redshifts are not indicated in pcigale.ini, compute them from the input flux file when the configuration dictionary is returned rather than in the analysis module, which should not have to change the configuration.
parent e0e09b8c
......@@ -12,6 +12,7 @@
- The pcigale-mock tool has been merged into pcigale-plots; the mock plots can be obtained with the "mock" command.
- The sfhdelayed module is now initialised with _init_code() to be consistent with the way things are done in other modules. This should give a slight speedup under some sircumstances too. (Médéric Boquien)
- In sfhfromfile, the specification of the time grid was vague and therefore could lead to incorrect results if it was not properly formatted by the end user. The description has been clarified and we now check that the time starts from 0 and that the time step is always 1 Myr. If it is not the case we raise an exception. (Médéric Boquien)
- When the redshift is not indicated in pcigale.ini, the analysis module fills the list of redshifts from the redshifts indicated in the input flux file. This is inefficient as analysis modules should have have to modify the configuration. Now this is done when interpreting pcigale.ini before calling the relevant analysis module. As a side effect, "pigale check" now returns the total number of models that cigale will compute rather than the number of models per redshift bin. (Médéric Boquien)
### Fixed
- To estimate parameters in log, pcigale determines which variables end with the "_log" string and removed it to compute the models. However in some circumstances, it was overzealous. This has been fixed. (Médéric Boquien)
......@@ -36,18 +36,19 @@ def check(config):
# TODO: Check if all the parameters that don't have default values are
# given for each module.
print("With this configuration, pcigale must compute {} "
configuration = config.configuration
print("With this configuration cigale will compute {} "
def run(config):
"""Run the analysis.
analysis_module = get_module(config.configuration['analysis_method'])
configuration = config.configuration
analysis_module = get_module(configuration['analysis_method'])
def main():
......@@ -45,8 +45,6 @@ from ..utils import ParametersHandler, backup_dir
# Tolerance threshold under which any flux or error is considered as 0.
# Limit the redshift to this number of decimals
class PdfAnalysis(AnalysisModule):
......@@ -137,11 +135,6 @@ class PdfAnalysis(AnalysisModule):
n_obs = len(obs_table)
w_redshifting = creation_modules.index('redshifting')
if list(creation_modules_params[w_redshifting]['redshift']) == ['']:
z = np.unique(np.around(obs_table['redshift'],
creation_modules_params[w_redshifting]['redshift'] = z
z = np.array(creation_modules_params[w_redshifting]['redshift'])
# The parameters handler allows us to retrieve the models parameters
......@@ -29,10 +29,6 @@ from .workers import init_fluxes as init_worker_fluxes
from .workers import fluxes as worker_fluxes
# Limit the redshift to this number of decimals
class SaveFluxes(AnalysisModule):
"""Save fluxes analysis module
......@@ -92,14 +88,6 @@ class SaveFluxes(AnalysisModule):
n_filters = len(filters)
w_redshifting = creation_modules.index('redshifting')
if list(creation_modules_params[w_redshifting]['redshift']) == ['']:
obs_table = read_table(conf['data_file'])
z = np.unique(np.around(obs_table['redshift'],
creation_modules_params[w_redshifting]['redshift'] = z
del obs_table, z
# The parameters handler allows us to retrieve the models parameters
# from a 1D index. This is useful in that we do not have to create
# a list of parameters as they are computed on-the-fly. It also has
......@@ -18,6 +18,9 @@ from ..utils import read_table
from .. import creation_modules
from .. import analysis_modules
# Limit the redshift to this number of decimals
def list_modules(package_name):
"""Lists the modules available in a package
......@@ -259,6 +262,10 @@ class Configuration(object):
configuration = {}
# Before building the configuration dictionary, we ensure that all the
# fields are filled
for section in ['data_file', 'column_list', 'creation_modules',
configuration[section] = self.config[section]
......@@ -314,3 +321,20 @@ class Configuration(object):
print("{} Options are: {}.".
format(comments[module], ', '.join(modules[module])))
def complete_conf(self):
"""Complete the configuration when there is missing information that is
to be extracted from other sources such as the input file (redshifts)
or the output parameters (single run)
z_mod = self.config['sed_creation_modules']['redshifting']['redshift']
if type(z_mod) is str and not z_mod:
if self.config['data_file']:
obs_table = read_table(self.config['data_file'])
z = np.unique(np.around(obs_table['redshift'],
self.config['sed_creation_modules']['redshifting']['redshift'] = z
raise Exception("No flux file and no redshift indicated. "
"The spectra cannot be computed. Aborting.")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment