From d4a727a2ef2b07bbea24452001209fa42d851f64 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Aug 2014 17:16:46 +0200 Subject: Remove old bad region tests and use dp instead of data for integration of peaks --- libcrystfel/src/peaks.c | 48 ++++++------------------------------------------ tests/ring_check.c | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 15f37a4e..b6b5b957 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -269,8 +269,6 @@ static int integrate_peak(struct image *image, int cfs, int css, for ( dss=-ir_out; dss<=+ir_out; dss++ ) { double val; - uint16_t flags; - int idx; /* Restrict to annulus */ if ( dfs*dfs + dss*dss > out_lim_sq ) continue; @@ -285,23 +283,7 @@ static int integrate_peak(struct image *image, int cfs, int css, return 14; } - idx = dfs+cfs+image->width*(dss+css); - - /* Veto this peak if we tried to integrate in a bad region */ - if ( image->flags != NULL ) { - - flags = image->flags[idx]; - - /* It must have all the "good" bits to be valid */ - if ( !((flags & image->det->mask_good) - == image->det->mask_good) ) return 5; - - /* If it has any of the "bad" bits, reject */ - if ( flags & image->det->mask_bad ) return 6; - - } - - val = image->data[idx]; + val = image->dp[pn][p_cfs+dfs + p->w*(p_css+dss)]; /* Check if peak contains saturation in bg region */ if ( (saturated != NULL) && (val > p->max_adu) ) *saturated = 1; @@ -325,8 +307,6 @@ static int integrate_peak(struct image *image, int cfs, int css, for ( dss=-ir_inn; dss<=+ir_inn; dss++ ) { double val; - uint16_t flags; - int idx; /* Inner mask radius */ if ( dfs*dfs + dss*dss > lim_sq ) continue; @@ -336,33 +316,17 @@ static int integrate_peak(struct image *image, int cfs, int css, || (p_cfs+dfs < 0 ) || (p_css+dss < 0) ) return 8; /* Wandered into a bad region? */ - if ( in_bad_region(image->det, p->min_fs+p_cfs+dfs, - p->min_ss+p_css+dss) ) - { - return 13; - } - - idx = dfs+cfs+image->width*(dss+css); - - /* Veto this peak if we tried to integrate in a bad region */ - if ( image->flags != NULL ) { - - flags = image->flags[idx]; - - /* It must have all the "good" bits to be valid */ - if ( !((flags & image->det->mask_good) - == image->det->mask_good) ) return 9; - - /* If it has any of the "bad" bits, reject */ - if ( flags & image->det->mask_bad ) return 10; - + if ( image->bad[pn][p_cfs+dfs + p->w*(p_css+dss)] ) { + return 15; } - val = image->data[idx] - bg_mean; + val = image->dp[pn][p_cfs+dfs + p->w*(p_css+dss)]; /* Check if peak contains saturation */ if ( (saturated != NULL) && (val > p->max_adu) ) *saturated = 1; + val -= bg_mean; + pk_counts++; pk_total += val; diff --git a/tests/ring_check.c b/tests/ring_check.c index 2581f248..9e70801a 100644 --- a/tests/ring_check.c +++ b/tests/ring_check.c @@ -63,7 +63,7 @@ static void third_integration_check(struct image *image, int n_trials, for ( fs=0; fswidth; fs++ ) { for ( ss=0; ssheight; ss++ ) { - image->data[fs+image->width*ss] + image->dp[0][fs+image->width*ss] = poisson_noise(rng, 1000.0); } } @@ -122,9 +122,9 @@ static void fourth_integration_check(struct image *image, int n_trials, for ( fs=0; fswidth; fs++ ) { for ( ss=0; ssheight; ss++ ) { int idx = fs+image->width*ss; - image->data[idx] = poisson_noise(rng, 1000.0); + image->dp[0][idx] = poisson_noise(rng, 1000.0); if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 9*9 ) continue; - image->data[idx] += 1000.0; + image->dp[0][idx] += 1000.0; pcount++; } } @@ -171,6 +171,8 @@ int main(int argc, char *argv[]) int r, npx; double ex; gsl_rng *rng; + float *dp; + int *bad; rng = gsl_rng_alloc(gsl_rng_mt19937); @@ -179,7 +181,10 @@ int main(int argc, char *argv[]) fclose(fh); gsl_rng_set(rng, seed); - image.data = malloc(128*128*sizeof(float)); + dp = calloc(128*128, sizeof(float)); + image.dp = &dp; + bad = calloc(128*128, sizeof(int)); + image.bad = &bad; image.flags = NULL; image.beam = NULL; image.lambda = ph_eV_to_lambda(1000.0); @@ -192,6 +197,8 @@ int main(int argc, char *argv[]) image.det->panels[0].max_fs = 128; image.det->panels[0].min_ss = 0; image.det->panels[0].max_ss = 128; + image.det->panels[0].w = 128; + image.det->panels[0].h = 128; image.det->panels[0].fsx = 1.0; image.det->panels[0].fsy = 0.0; image.det->panels[0].ssx = 0.0; @@ -209,7 +216,6 @@ int main(int argc, char *argv[]) image.width = 128; image.height = 128; - memset(image.data, 0, 128*128*sizeof(float)); image.n_crystals = 0; image.crystals = NULL; @@ -236,7 +242,7 @@ int main(int argc, char *argv[]) for ( fs=0; fs 9*9 ) continue; - image.data[fs+image.width*ss] = 1000.0; + image.dp[0][fs+image.width*ss] = 1000.0; npx++; } } @@ -276,9 +282,9 @@ int main(int argc, char *argv[]) npx = 0; for ( fs=0; fs 9*9 ) continue; - image.data[fs+image.width*ss] += 1000.0; + image.dp[0][fs+image.width*ss] += 1000.0; npx++; } } @@ -308,11 +314,11 @@ int main(int argc, char *argv[]) } - free(image.beam); free(image.det->panels); free(image.det); - free(image.data); + free(image.dp[0]); + free(image.bad[0]); gsl_rng_free(rng); if ( fail ) return 1; -- cgit v1.2.3