Commit 0907b7e5 authored by Médéric Boquien's avatar Médéric Boquien

If the list of analysed/saved physical properties is left empty in...

If the list of analysed/saved physical properties is left empty in pcigale.ini, savefluxes saved all physical properties. This has been moved to the Configuration class and easily extended to the pdf_analysis module.
parent eabdd39f
......@@ -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)
......
......@@ -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", (
......
......@@ -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),
......
......@@ -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']
......
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