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

When estimating a parameter in log, these were not scaled appropriately and...

When estimating a parameter in log, these were not scaled appropriately and taken in log when saving the related PDF
parent f6b35601
......@@ -7,7 +7,7 @@
### Changed
### 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)
- When estimating a parameter in log, these were not scaled appropriately and taken in log when saving the related χ². (Médéric Boquien)
- When estimating a parameter in log, these were not scaled appropriately and taken in log when saving the related χ² and PDF. (Médéric Boquien)
### Optimised
- Prior to version 0.7.0, we needed to maintain the list of redshifts for all the computed models. Past 0.7.0 we just infer the redshift from a list unique redshifts. This means that we can now discard the list of redshifts for all the models and only keep the list of unique redshifts. This saves ~8 MB of memory for every 10⁶ models. the models should be computed slightly faster but it is in the measurement noise. (Médéric Boquien)
......
......@@ -32,7 +32,7 @@ def save_best_sed(obsid, sed, norm):
sed.to_votable(OUT_DIR + "{}_best_model.xml".format(obsid), mass=norm)
def save_pdf(obsid, name, model_variable, likelihood):
def _save_pdf(obsid, name, model_variable, likelihood):
"""Compute and save the PDF to a FITS file
We estimate the probability density functions (PDF) of the parameter from
......@@ -83,6 +83,39 @@ def save_pdf(obsid, name, model_variable, likelihood):
table.write(OUT_DIR + "{}_{}_pdf.fits".format(obsid, name))
def save_pdf(obsid, names, mass_proportional, model_variables, scaling,
likelihood, wlikely):
"""Compute and save the PDF of analysed variables
Parameters
----------
obsid: string
Name of the object. Used to prepend the output file name
names: list of strings
Analysed variables names
model_variables: array
Values of the model variables
likelihood: 1D array
Likelihood of the "likely" models
"""
for i, name in enumerate(names):
if name.endswith('_log'):
if name[:-4] in mass_proportional:
model_variable = np.log10(model_variables[:, i][wlikely] *
scaling[wlikely])
else:
model_variable = np.log10(model_variables[:, i][wlikely])
else:
if name in mass_proportional:
model_variable = (model_variables[:, i][wlikely] *
scaling[wlikely])
else:
model_variable = model_variables[:, i][wlikely]
_save_pdf(obsid, name, model_variable, likelihood)
def _save_chi2(obsid, name, model_variable, chi2):
"""Save the best reduced χ² versus an analysed variable
......
......@@ -291,14 +291,9 @@ def analysis(idx, obs):
sed.mass_proportional_info, gbl_model_variables[wz, :],
scaling, chi2 / (nobs - 1))
if gbl_save['pdf']:
for i, variable in enumerate(gbl_analysed_variables):
if variable in sed.mass_proportional_info:
save_pdf(obs['id'], variable,
gbl_model_variables[wz, i][wlikely] *
scaling[wlikely], likelihood)
else:
save_pdf(obs['id'], variable,
gbl_model_variables[wz, i][wlikely], likelihood)
save_pdf(obs['id'], gbl_analysed_variables,
sed.mass_proportional_info, gbl_model_variables[wz, :],
scaling, likelihood, wlikely)
with gbl_n_computed.get_lock():
gbl_n_computed.value += 1
......
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