htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 64c1ede5e8d0bee78bbb4aba58702a05f7515152
parent 2cb70129989336c923efb80362998da62ba084e4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri,  5 Jun 2020 09:09:58 +0200

Remove a FATAL in the CIE XYZ sampling function:

The function samples a wavelength by first selecting a sub-band into the
CIE XYZ spectral range and then by continuously sampling the CIE
tristimulus curve into this sub-band. Due to numerical imprecisions,
this latter computation can find a wavelength that is actually not
included into the sampled sub-band, leading to an error that previously
was handled by a FATAL.

This commit replaces it by a warning message and a fallback procedure
that in such unforeseen situation selects the wavelength and the center
of the sampled sub-band.

Diffstat:
Msrc/htrdr_cie_xyz.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/htrdr_cie_xyz.c b/src/htrdr_cie_xyz.c @@ -164,7 +164,12 @@ sample_cie_xyz } else if(lambda_min <= lambda_2 && lambda_2 < lambda_max) { lambda = lambda_2; } else { - FATAL("Unexpected error.\n"); + htrdr_log_warn(cie->htrdr, + "%s: cannot sample a wavelength in [%g, %g[. The possible wavelengths" + "were %g and %g.\n", + FUNC_NAME, lambda_min, lambda_max, lambda_1, lambda_2); + /* Arbitrarly choose the wavelength at the center of the sampled band */ + lambda = (lambda_min + lambda_max)*0.5; } return lambda;