aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-08-13 17:16:46 +0200
committerThomas White <taw@physics.org>2014-08-13 17:16:46 +0200
commitd4a727a2ef2b07bbea24452001209fa42d851f64 (patch)
treecb86be2e394879aee4b1fb55d33394e5049d108b
parentea852d0ab4944a5b63f764207c742b6791a9154c (diff)
Remove old bad region tests and use dp instead of data for integration of peaks
-rw-r--r--libcrystfel/src/peaks.c48
-rw-r--r--tests/ring_check.c26
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; fs<image->width; fs++ ) {
for ( ss=0; ss<image->height; 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; fs<image->width; fs++ ) {
for ( ss=0; ss<image->height; 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<image.width; fs++ ) {
for ( ss=0; ss<image.height; ss++ ) {
if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 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<image.width; fs++ ) {
for ( ss=0; ss<image.height; ss++ ) {
- image.data[fs+image.width*ss] = 1000.0;
+ image.dp[0][fs+image.width*ss] = 1000.0;
if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 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;