diff options
author | Thomas White <taw@bitwiz.org.uk> | 2012-01-22 16:03:48 -0800 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:44 +0100 |
commit | 77d007d51024787ec6eb06fad022dde275bd33ac (patch) | |
tree | 9b3e5e428d37884662ffabcc2262590bd4bbb212 /libcrystfel/src/peaks.c | |
parent | a5ce505f6fa79ab4d11fff5b7ada0b5ca078b15d (diff) |
More ReAx improvements
Diffstat (limited to 'libcrystfel/src/peaks.c')
-rw-r--r-- | libcrystfel/src/peaks.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 0cbce55f..713dd0a6 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -473,9 +473,8 @@ void search_peaks(struct image *image, float threshold, float min_gradient, } -int peak_sanity_check(struct image *image) +double peak_lattice_agreement(struct image *image, UnitCell *cell, double *pst) { - int i; int n_feat = 0; int n_sane = 0; @@ -483,14 +482,13 @@ int peak_sanity_check(struct image *image) double bx, by, bz; double cx, cy, cz; double min_dist = 0.25; + double stot = 0.0; /* Round towards nearest */ fesetround(1); /* Cell basis vectors for this image */ - cell_get_cartesian(image->indexed_cell, &ax, &ay, &az, - &bx, &by, &bz, - &cx, &cy, &cz); + cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); /* Loop over peaks, checking proximity to nearest reflection */ for ( i=0; i<image_feature_count(image->features); i++ ) { @@ -520,17 +518,25 @@ int peak_sanity_check(struct image *image) if ( (fabs(h - hd) < min_dist) && (fabs(k - kd) < min_dist) && (fabs(l - ld) < min_dist) ) { + double sval; n_sane++; + sval = pow(h-hd, 2.0) + pow(k-kd, 2.0) + pow(l-ld, 2.0); + stot += 1.0 - sval; continue; } } - /* return 0 means fail test, return 1 means pass test */ - // printf("%d out of %d peaks are \"sane\"\n",n_sane,n_feat); - if ( (float)n_sane / (float)n_feat < 0.5 ) return 0; + *pst = stot; + return (double)n_sane / (float)n_feat; +} + - return 1; +int peak_sanity_check(struct image *image) +{ + double stot; + /* 0 means failed test, 1 means passed test */ + return peak_lattice_agreement(image, image->indexed_cell, &stot) >= 0.5; } |