Commit 5917743b authored by Médéric Boquien's avatar Médéric Boquien

Do not crash when all χ² are extremely large.

parent 7439507e
......@@ -13,6 +13,7 @@
- The histogram bin width was not computed optimally when some models were invalid. (David Corre & Médéric Boquien)
- Missing import in the `m2005` module. (Médéric Boquien, reported by Dominika Wylezalek)
- The plot of the PDF could not be generated for physical properties estimated in log (Médéric Boquien)
- We do not attempt anymore to estimate the physical properties of galaxies with insanely large χ² that lead to an underflow in the computation of the likelihood. (Médéric Boquien)
### Optimised
- The estimation of the physical properties is made a bit faster when all the models are valid. (Médéric Boquien)
......
......@@ -178,7 +178,7 @@ def analysis(idx, obs):
chi2, scaling = compute_chi2(gbl_models, obs, corr_dz, wz,
gbl_models.conf['analysis_params']['lim_flag'])
if np.any(np.isfinite(chi2)):
if np.any(chi2 < -np.log(np.finfo(np.float64).tiny) * 2.):
# We use the exponential probability associated with the χ² as
# likelihood function.
likelihood = np.exp(-chi2 / 2.)
......@@ -222,11 +222,11 @@ def analysis(idx, obs):
gbl_results.best.scaling[idx] = scaling[best_idx_z]
gbl_results.best.index[idx] = (wz.start + best_idx_z*wz.step +
gbl_models.block.start)
else:
# It sometimes happens because models are older than the Universe's age
print("No suitable model found for the object {}. One possible origin "
"is that models are older than the Universe.".format(obs.id))
print("No suitable model found for the object {}. It may be that "
"models are older than the Universe or that your chi² are very "
"large.".format(obs.id))
with gbl_ncomputed.get_lock():
gbl_ncomputed.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