star-schiff

Library for estimating radiative properties
git clone git://git.meso-star.com/star-schiff.git
Log | Files | Refs | README | LICENSE

commit a73ff32c13bb5340a80f7b11cd72dd3a4ff7b884
parent eaa9194d11c094b4c0dfaea078a3a25cc9ce1cf7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 29 Mar 2016 11:59:25 +0200

Handle the uncomputable [cumulative] phase functions

Set the estimated result to -1 when they cannot be computed. If one
wants to retrieve this data, use this value to return a RES_BAD_OP error
code.

Diffstat:
Msrc/sschiff_estimator.c | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c @@ -854,6 +854,7 @@ compute_phase_function "angles. The phase function is thus not computed.\n" "Wavelength = %g micron\n", estimator->wavelengths[iwlen]); + goto error; } @@ -954,8 +955,14 @@ compute_phase_function exit: return res; error: - memset(estimator->phase_functions[iwlen].values, 0, nangles); - memset(estimator->phase_functions[iwlen].cumulative, 0, nangles); + FOR_EACH(iangle, 0, nangles) { + estimator->phase_functions[iwlen].values[iangle].E = -1; + estimator->phase_functions[iwlen].values[iangle].V = -1; + estimator->phase_functions[iwlen].values[iangle].SE = -1; + estimator->phase_functions[iwlen].cumulative[iangle].E = -1; + estimator->phase_functions[iwlen].cumulative[iangle].V = -1; + estimator->phase_functions[iwlen].cumulative[iangle].SE = -1; + } goto exit; } @@ -1694,6 +1701,9 @@ sschiff_estimator_get_phase_function /* No phase function was computed */ if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE) return RES_BAD_OP; + /* Invalid phase function */ + if(estimator->phase_functions[iwlen].values[0].V < 0) + return RES_BAD_OP; *states = estimator->phase_functions[iwlen].values; return RES_OK; } @@ -1710,6 +1720,9 @@ sschiff_estimator_get_phase_function_cumulative /* No phase function cumulative was computed */ if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE) return RES_BAD_OP; + /* Invalid cumulative phase function */ + if(estimator->phase_functions[iwlen].cumulative[0].V < 0) + return RES_BAD_OP; *states = estimator->phase_functions[iwlen].cumulative; return RES_OK; }