diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ed2a2ab2d33ca70198152d6b14908fdf3d562f..1682c518d0963560b010a88ea1d6b3ac8c3144d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased ### Added - When using the savefluxes module, all the output parameters were saved. This is not efficient when the user is only interested in some of the output parameters but not all. We introduce the "variables" configuration parameter for savefluxes to list the output parameters the user wants to save. If the list is left empty, all parameters are saved, preserving the current behaviour. This should increase the speed substantially when saving memory. (Médéric Boquien) +- Similarly to the savefluxes module, in the pdf_analysis module if the list of physical properties is left empty, all physical parameters are now analysed. (Médéric Boquien) ### Changed - The estimates of the physical parameters from the analysis of the PDF and from the best fit were recorded in separate files. This can be bothersome when trying to compare quantities from different files. Rather, we generate a single file containing all quantities. The ones estimated from the analysis of the PDF are prefixed with "bayes" and the ones from the best fit with "best". (Médéric Boquien) diff --git a/pcigale/analysis_modules/pdf_analysis/__init__.py b/pcigale/analysis_modules/pdf_analysis/__init__.py index 96af87da72c062881949afbc65c4fb602d1559ac..bbd00e07c2d8149b99a8946816f891910110fc92 100644 --- a/pcigale/analysis_modules/pdf_analysis/__init__.py +++ b/pcigale/analysis_modules/pdf_analysis/__init__.py @@ -53,8 +53,9 @@ class PdfAnalysis(AnalysisModule): parameter_list = dict([ ("analysed_variables", ( "array of strings", - "List of the variables (in the SEDs info dictionaries) for which " - "the statistical analysis will be done.", + "List of the physical properties to estimate. Leave empty to " + "analyse all the physical properties (not recommended when there " + "are many models).", ["sfh.sfr", "sfh.sfr10Myrs", "sfh.sfr100Myrs"] )), ("save_best_sed", ( diff --git a/pcigale/analysis_modules/savefluxes/__init__.py b/pcigale/analysis_modules/savefluxes/__init__.py index 291b885719d883e8e0a65d5ab1c3890746e229df..d886b27e6a76c22e4c158a42473f9edc84e3ca27 100644 --- a/pcigale/analysis_modules/savefluxes/__init__.py +++ b/pcigale/analysis_modules/savefluxes/__init__.py @@ -24,7 +24,6 @@ import numpy as np from .. import AnalysisModule from ..utils import ParametersHandler, backup_dir, save_fluxes from ...utils import read_table -from ...warehouse import SedWarehouse from .workers import init_fluxes as init_worker_fluxes from .workers import fluxes as worker_fluxes @@ -40,9 +39,10 @@ class SaveFluxes(AnalysisModule): parameter_list = dict([ ("variables", ( "array of strings", - "List of variables to be saved. If the list is left empty, all" - "variables will be saved.", - [''] + "List of the physical properties to save. Leave empty to save all " + "the physical properties (not recommended when there are many " + "models).", + None )), ("output_file", ( "string", @@ -80,9 +80,9 @@ class SaveFluxes(AnalysisModule): backup_dir() creation_modules = conf['creation_modules'] creation_modules_params = conf['creation_modules_params'] - out_file = conf['analysis_method_params']["output_file"] - out_format = conf['analysis_method_params']["output_format"] - save_sed = conf['analysis_method_params']["save_sed"].lower() == "true" + out_file = conf['analysis_method_params']['output_file'] + out_format = conf['analysis_method_params']['output_format'] + save_sed = conf['analysis_method_params']['save_sed'].lower() == "true" filters = [name for name in conf['column_list'] if not name.endswith('_err')] @@ -96,16 +96,7 @@ class SaveFluxes(AnalysisModule): params = ParametersHandler(creation_modules, creation_modules_params) n_params = params.size - if conf['analysis_method_params']["variables"] == '': - # Retrieve an arbitrary SED to obtain the list of output parameters - warehouse = SedWarehouse() - sed = warehouse.get_sed(creation_modules, params.from_index(0)) - info = list(sed.info.keys()) - del warehouse, sed - else: - info = conf['analysis_method_params']["variables"] - n_info = len(info) - info.sort() + info = conf['analysis_method_params']['variables'] n_info = len(info) model_fluxes = (RawArray(ctypes.c_double, n_params * n_filters), diff --git a/pcigale/session/configuration.py b/pcigale/session/configuration.py index 726217a7cc25e9adfa4a46074fdebf1cc2a24e2b..c85139ee6e6d3d6ecd43670b1de4a5b1d122cca7 100644 --- a/pcigale/session/configuration.py +++ b/pcigale/session/configuration.py @@ -13,10 +13,13 @@ from glob import glob # To allow the use of glob() in "eval..." import pkg_resources import numpy as np +from ..analysis_modules.utils import ParametersHandler from ..data import Database from ..utils import read_table from .. import creation_modules from .. import analysis_modules +from ..warehouse import SedWarehouse + # Limit the redshift to this number of decimals REDSHIFT_DECIMALS = 2 @@ -264,7 +267,7 @@ class Configuration(object): # Before building the configuration dictionary, we ensure that all the # fields are filled - self.complete_conf() + self.complete_redshifts() for section in ['data_file', 'column_list', 'creation_modules', 'analysis_method']: @@ -280,6 +283,31 @@ class Configuration(object): module_params[key] = evaluate_description(value) configuration['creation_modules_params'].append(module_params) + if (self.config['analysis_method'] == 'savefluxes' and + not self.config['analysis_configuration']['variables']): + warehouse = SedWarehouse() + params = ParametersHandler(configuration['creation_modules'], + configuration['creation_modules_params']) + sed = warehouse.get_sed(configuration['creation_modules'], + params.from_index(0)) + info = list(sed.info.keys()) + info.sort() + self.config['analysis_configuration']['variables'] = info + elif (self.config['analysis_method'] == 'pdf_analysis' and + not self.config['analysis_configuration']['analysed_variables']): + warehouse = SedWarehouse() + params = ParametersHandler(configuration['creation_modules'], + configuration['creation_modules_params']) + sed = warehouse.get_sed(configuration['creation_modules'], + params.from_index(0)) + info = list(sed.info.keys()) + info.sort() + self.config['analysis_configuration']['analysed_variables'] = info + else: + raise Exception("Cannot determine which physical variables are to" + "be computed with the {} module.").format( + configuration['analysis_method']) + # Analysis method parameters configuration['analysis_method_params'] = \ self.config['analysis_configuration'] @@ -322,10 +350,9 @@ 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) + def complete_redshifts(self): + """Complete the configuration when the redshifts are missing from the + configuration file and must be extracted from the input flux file. """ z_mod = self.config['sed_creation_modules']['redshifting']['redshift']