Commit f6b35601 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 χ²
parent 1ffcabcb
......@@ -6,6 +6,9 @@
### 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)
### 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)
......
......@@ -83,7 +83,7 @@ def save_pdf(obsid, name, model_variable, likelihood):
table.write(OUT_DIR + "{}_{}_pdf.fits".format(obsid, name))
def save_chi2(obsid, name, model_variable, chi2):
def _save_chi2(obsid, name, model_variable, chi2):
"""Save the best reduced χ² versus an analysed variable
Parameters
......@@ -103,6 +103,37 @@ def save_chi2(obsid, name, model_variable, chi2):
table.write(OUT_DIR + "{}_{}_chi2.fits".format(obsid, name))
def save_chi2(obsid, names, mass_proportional, model_variables, scaling, chi2):
"""Save the best reduced χ² versus analysed variables
Parameters
----------
obsid: string
Name of the object. Used to prepend the output file name
name: list of strings
Analysed variables names
model_variables: array
Values of the model variables
scaling: array
Scaling factors of the models
chi2:
Reduced χ²
"""
for i, name in enumerate(names):
if name.endswith('_log'):
if name[:-4] in mass_proportional:
model_variable = np.log10(model_variables[:, i] * scaling)
else:
model_variable = np.log10(model_variables[:, i])
else:
if name in mass_proportional:
model_variable = model_variables[:, i] * scaling
else:
model_variable = model_variables
_save_chi2(obsid, name, model_variable, chi2)
def save_table_analysis(filename, obsid, analysed_variables, analysed_averages,
analysed_std):
"""Save the estimated values derived from the analysis of the PDF
......
......@@ -287,13 +287,9 @@ def analysis(idx, obs):
if gbl_save['best_sed']:
save_best_sed(obs['id'], sed, scaling[best_index_z])
if gbl_save['chi2']:
for i, variable in enumerate(gbl_analysed_variables):
if variable in sed.mass_proportional_info:
save_chi2(obs['id'], variable, gbl_model_variables[wz, i] *
scaling, chi2 / (nobs - 1))
else:
save_chi2(obs['id'], variable, gbl_model_variables[wz, i],
chi2 / (nobs - 1))
save_chi2(obs['id'], gbl_analysed_variables,
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:
......
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