aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-11-07 20:39:04 +0100
committerThomas White <taw@physics.org>2022-11-07 20:39:04 +0100
commit6f55de63b6aa64481db0e294844f39a1ca7fffee (patch)
treef1143967fedef275241919874d3931d851c02d7e
parentb5625226829615fa5e7979a81c6770bd116349ce (diff)
check_hkl: Make --wilson more robust against invalid data
-rw-r--r--src/check_hkl.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/check_hkl.c b/src/check_hkl.c
index aa972a7f..d01303d4 100644
--- a/src/check_hkl.c
+++ b/src/check_hkl.c
@@ -359,17 +359,25 @@ static void wilson_plot(RefList *list, UnitCell *cell, const SymOpList *sym,
double *s2fit;
double *lnifit;
int nbfit = 0;
+ int ndisc = 0;
s2fit = malloc(nbins*sizeof(double));
lnifit = malloc(nbins*sizeof(double));
if ( (s2fit==NULL) || (lnifit==NULL) ) return;
for ( i=0; i<nbins-bs; i++ ) {
- if ( isnan(plot_i[bs+i]) ) continue;
- s2fit[i] = s2[bs+i];
- lnifit[i] = plot_i[bs+i];
+ if ( isnan(plot_i[bs+i]) ) {
+ ndisc++;
+ continue;
+ }
+ s2fit[nbfit] = s2[bs+i];
+ lnifit[nbfit] = plot_i[bs+i];
nbfit++;
}
+ if ( ndisc > 0 ) {
+ ERROR("%i bins contained invalid values "
+ "and were ignored.\n", ndisc);
+ }
if ( nbfit < 3 ) {
- ERROR("Too many bits had invalid values.\n");
+ ERROR("Not enough bins left.\n");
return;
}
gsl_fit_linear(s2fit, 1, lnifit, 1, nbfit,