Commit 59052aaa authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Add back the possibility to read the redshifts from the input file. To do so,...

Add back the possibility to read the redshifts from the input file. To do so, do not give any redshift to the redshifting module. To avoid having too many redshifts, it is rounded to 2 decimals. This number can be changed in the analysis modules.
parent 4bfd4b4f
......@@ -122,14 +122,6 @@ class PdfAnalysis(AnalysisModule):
save = {key:config["save_{}".format(key)].lower() == "true"
for key in ["best_sed", "chi2", "pdf"]}
# 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
# nice goodies such as finding the index of the first parameter to
# have changed between two indices or the number of models.
params = ParametersHandler(creation_modules, creation_modules_params)
n_params = params.size
# Get the needed filters in the pcigale database. We use an ordered
# dictionary because we need the keys to always be returned in the
# same order. We also put the filters in the shared modules as they
......@@ -146,6 +138,21 @@ class PdfAnalysis(AnalysisModule):
filters, TOLERANCE)
n_obs = len(obs_table)
w_redshifting = creation_modules.index('redshifting')
if creation_modules_params[w_redshifting]['redshift'] == ['']:
z = np.unique(np.around(obs_table['redshift'],
decimals=REDSHIFT_DECIMALS))
creation_modules_params[w_redshifting]['redshift'] = z
del 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
# nice goodies such as finding the index of the first parameter to
# have changed between two indices or the number of models.
params = ParametersHandler(creation_modules, creation_modules_params)
n_params = params.size
# Retrieve an arbitrary SED to obtain the list of output parameters
warehouse = SedWarehouse(cache_type=config["storage_type"])
sed = warehouse.get_sed(creation_modules, params.from_index(0))
......
......@@ -23,13 +23,19 @@ import multiprocessing as mp
from multiprocessing.sharedctypes import RawArray
import time
import numpy as np
from . import AnalysisModule
from ..data import Database
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
# Limit the redshift to this number of decimals
REDSHIFT_DECIMALS = 2
class SaveFluxes(AnalysisModule):
"""Save fluxes analysis module
......@@ -90,13 +96,6 @@ class SaveFluxes(AnalysisModule):
out_file = parameters["output_file"]
out_format = parameters["output_format"]
# 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
# nice goodies such as finding the index of the first parameter to
# have changed between two indices or the number of models.
params = ParametersHandler(creation_modules, creation_modules_params)
n_params = params.size
# Get the needed filters in the pcigale database. We use an ordered
# dictionary because we need the keys to always be returned in the
......@@ -108,6 +107,22 @@ class SaveFluxes(AnalysisModule):
if not name.endswith('_err')])
n_filters = len(filters)
w_redshifting = creation_modules.index('redshifting')
if creation_modules_params[w_redshifting]['redshift'] == ['']:
obs_table = read_table(data_file)
z = np.unique(np.around(obs_table['redshift'],
decimals=REDSHIFT_DECIMALS))
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
# nice goodies such as finding the index of the first parameter to
# have changed between two indices or the number of models.
params = ParametersHandler(creation_modules, creation_modules_params)
n_params = params.size
# Retrieve an arbitrary SED to obtain the list of output parameters
warehouse = SedWarehouse(cache_type=parameters["storage_type"])
sed = warehouse.get_sed(creation_modules, params.from_index(0))
......@@ -115,7 +130,6 @@ class SaveFluxes(AnalysisModule):
n_info = len(sed.info)
del warehouse, sed
model_fluxes = (RawArray(ctypes.c_double,
n_params * n_filters),
(n_params, n_filters))
......
Supports Markdown
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