aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-11-22 16:19:21 +0100
committerThomas White <taw@physics.org>2018-11-22 16:20:40 +0100
commita166b0ae68b99bea3f2e08cc508a863a0f36073b (patch)
treed05946d0dd112ea30116f631250519b6bcffd7af /src
parentf30cc81c78493b3e0299f15a2ebf38aad2ba8e28 (diff)
Count crystals with no reflections in various FoMs
This is the most common cause of NaN residuals, so it seems better to report that there weren't enough reflections than to report a NaN.
Diffstat (limited to 'src')
-rw-r--r--src/partialator.c55
-rw-r--r--src/rejection.c16
2 files changed, 59 insertions, 12 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 86431e4c..10befba8 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -716,6 +716,10 @@ static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
int n_nan_linear_free = 0;
int n_nan_log = 0;
int n_nan_log_free = 0;
+ int n_non_linear = 0;
+ int n_non_linear_free = 0;
+ int n_non_log = 0;
+ int n_non_log_free = 0;
*presidual = 0.0;
*pfree_residual = 0.0;
@@ -725,19 +729,35 @@ static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
for ( i=0; i<n_crystals; i++ ) {
double r, free_r, log_r, free_log_r;
+ int n;
if ( crystal_get_user_flag(crystals[i]) ) continue;
/* Scaling should have been done right before calling this */
- r = residual(crystals[i], full, 0, NULL, NULL);
- free_r = residual(crystals[i], full, 1, NULL, NULL);
- log_r = log_residual(crystals[i], full, 0, NULL, NULL);
- free_log_r = log_residual(crystals[i], full, 1, NULL, NULL);
-
- if ( isnan(r) ) n_nan_linear++;
- if ( isnan(free_r) ) n_nan_linear_free++;
- if ( isnan(log_r) ) n_nan_log++;
- if ( isnan(free_log_r) ) n_nan_log_free++;
+ r = residual(crystals[i], full, 0, &n, NULL);
+ if ( n == 0 ) {
+ n_non_linear++;
+ } else if ( isnan(r) ) {
+ n_nan_linear++;
+ }
+ free_r = residual(crystals[i], full, 1, &n, NULL);
+ if ( n == 0 ) {
+ n_non_linear_free++;
+ } else if ( isnan(free_r) ) {
+ n_nan_linear_free++;
+ }
+ log_r = log_residual(crystals[i], full, 0, &n, NULL);
+ if ( n == 0 ) {
+ n_non_log++;
+ } else if ( isnan(log_r) ) {
+ n_nan_log++;
+ }
+ free_log_r = log_residual(crystals[i], full, 1, &n, NULL);
+ if ( n == 0 ) {
+ n_non_log_free++;
+ } else if ( isnan(free_log_r) ) {
+ n_nan_log_free++;
+ }
if ( isnan(r) || isnan(free_r)
|| isnan(log_r) || isnan(free_log_r) ) continue;
@@ -750,6 +770,23 @@ static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
n_used++;
}
+ if ( n_non_linear ) {
+ ERROR("WARNING: %i crystals had no reflections in linear "
+ "residual calculation\n", n_non_linear);
+ }
+ if ( n_non_linear_free ) {
+ ERROR("WARNING: %i crystals had no reflections in linear free "
+ "residual calculation\n", n_non_linear_free);
+ }
+ if ( n_non_log ) {
+ ERROR("WARNING: %i crystals had no reflections in log "
+ "residual calculation\n", n_non_log);
+ }
+ if ( n_non_log_free ) {
+ ERROR("WARNING: %i crystals had no reflections in log free "
+ "residual calculation\n", n_non_log_free);
+ }
+
if ( n_nan_linear ) {
ERROR("WARNING: %i crystals had NaN linear residuals\n",
n_nan_linear);
diff --git a/src/rejection.c b/src/rejection.c
index b3a3cb67..6ec59151 100644
--- a/src/rejection.c
+++ b/src/rejection.c
@@ -289,6 +289,7 @@ static void check_deltacchalf(Crystal **crystals, int n, RefList *full)
double mean, sd;
int nref = 0;
int nnan = 0;
+ int nnon = 0;
if ( calculate_refl_mean_var(full) ) {
STATUS("No reflection contributions for deltaCChalf "
@@ -315,13 +316,22 @@ static void check_deltacchalf(Crystal **crystals, int n, RefList *full)
//STATUS("Without = %f", cchalfi*100.0);
//STATUS(" Delta = %f ", (cchalf - cchalfi)*100.0);
//STATUS("(nref = %i)\n", nref);
- vals[i] = cchalf - cchalfi;
- if ( isnan(vals[i]) || isinf(vals[i]) ) {
+ if ( nref == 0 ) {
vals[i] = 0.0;
- nnan++;
+ nnon++;
+ } else {
+ vals[i] = cchalf - cchalfi;
+ if ( isnan(vals[i]) || isinf(vals[i]) ) {
+ vals[i] = 0.0;
+ nnan++;
+ }
}
progress_bar(i, n-1, "Calculating deltaCChalf");
}
+ if ( nnon > 0 ) {
+ STATUS("WARNING: %i patterns had no reflections in deltaCChalf "
+ "calculation (I set deltaCChalf=zero for them)\n", nnon);
+ }
if ( nnan > 0 ) {
STATUS("WARNING: %i NaN or inf deltaCChalf values were "
"replaced with zero\n", nnan);