aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-08 15:25:40 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:18 +0100
commit9bf9a358475082f10e9c18c44adc9551fe20747b (patch)
treea6c88fc90de34766321ad30f8ffc653a61e43a30
parent8cb16f40549e2235ed1518a303313d67c90b2db7 (diff)
Do peak integration in double precision
This avoids some integer overflow problems
-rw-r--r--src/geometry.c2
-rw-r--r--src/peaks.c26
-rw-r--r--src/peaks.h2
3 files changed, 15 insertions, 15 deletions
diff --git a/src/geometry.c b/src/geometry.c
index 6a970400..717f5725 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -276,7 +276,7 @@ double integrate_all(struct image *image, RefList *reflections)
refl != NULL;
refl = next_refl(refl, iter) ) {
- float x, y, intensity;
+ double x, y, intensity;
double xp, yp;
get_detector_pos(refl, &xp, &yp);
diff --git a/src/peaks.c b/src/peaks.c
index 65bf01fb..f9288c23 100644
--- a/src/peaks.c
+++ b/src/peaks.c
@@ -166,15 +166,15 @@ static int cull_peaks(struct image *image)
/* Returns non-zero if peak has been vetoed.
* i.e. don't use result if return value is not zero. */
int integrate_peak(struct image *image, int xp, int yp,
- float *xc, float *yc, float *intensity,
+ double *xc, double *yc, double *intensity,
double *pbg, double *pmax,
int do_polar, int centroid)
{
signed int x, y;
int lim, out_lim;
double total = 0.0;
- int xct = 0;
- int yct = 0;
+ double xct = 0.0;
+ double yct = 0.0;
double noise = 0.0;
int noise_counts = 0;
double max = 0.0;
@@ -184,14 +184,14 @@ int integrate_peak(struct image *image, int xp, int yp,
if ( p == NULL ) return 1;
if ( p->no_index ) return 1;
- lim = p->peak_sep/2;
+ lim = p->peak_sep/4.0;
out_lim = lim + 1;
for ( x=-out_lim; x<+out_lim; x++ ) {
for ( y=-out_lim; y<+out_lim; y++ ) {
double val;
- float tt = 0.0;
+ double tt = 0.0;
double phi, pa, pb, pol;
uint16_t flags;
struct panel *p2;
@@ -247,12 +247,12 @@ int integrate_peak(struct image *image, int xp, int yp,
/* The centroid is excitingly undefined if there is no intensity */
if ( centroid && (total != 0) ) {
- *xc = (float)xct / total;
- *yc = (float)yct / total;
+ *xc = (double)xct / total;
+ *yc = (double)yct / total;
*intensity = total;
} else {
- *xc = (float)xp;
- *yc = (float)yp;
+ *xc = (double)xp;
+ *yc = (double)yp;
*intensity = total;
}
@@ -274,9 +274,9 @@ static void search_peaks_in_panel(struct image *image, float threshold,
float *data;
double d;
int idx;
- float f_fs = 0.0;
- float f_ss = 0.0;
- float intensity = 0.0;
+ double f_fs = 0.0;
+ double f_ss = 0.0;
+ double intensity = 0.0;
int nrej_dis = 0;
int nrej_hot = 0;
int nrej_pro = 0;
@@ -685,7 +685,7 @@ void output_intensities(struct image *image, UnitCell *cell,
refl != NULL;
refl = next_refl(refl, iter) ) {
- float x, y, intensity;
+ double x, y, intensity;
double d;
int idx;
double bg, max;
diff --git a/src/peaks.h b/src/peaks.h
index 2801153d..2acb249b 100644
--- a/src/peaks.h
+++ b/src/peaks.h
@@ -39,7 +39,7 @@ extern int peak_sanity_check(struct image *image, UnitCell *cell,
extern RefList *find_projected_peaks(struct image *image, UnitCell *cell,
int circular_domain, double domain_r);
extern int integrate_peak(struct image *image, int xp, int yp,
- float *xc, float *yc, float *intensity,
+ double *xc, double *yc, double *intensity,
double *pbg, double *pmax,
int do_polar, int centroid);