aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/hdf5-file.c13
-rw-r--r--libcrystfel/src/image.c8
-rw-r--r--libcrystfel/src/image.h6
-rw-r--r--libcrystfel/src/index.c6
-rw-r--r--libcrystfel/src/peakfinder8.c4
-rw-r--r--libcrystfel/src/peaks.c37
-rw-r--r--libcrystfel/src/peaks.h4
-rw-r--r--libcrystfel/src/predict-refine.c4
-rw-r--r--libcrystfel/src/stream.c30
-rw-r--r--src/geoptimiser.c5
-rw-r--r--src/process_image.c3
-rw-r--r--tests/ring_check.c10
12 files changed, 75 insertions, 55 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index e2738a8b..ec0d77f2 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -400,6 +400,7 @@ int get_peaks_cxi_2(struct image *image, struct hdfile *f, const char *p,
float fs, ss, val;
struct panel *p;
+ int pn;
fs = buf_x[pk] + peak_offset;
ss = buf_y[pk] + peak_offset;
@@ -413,7 +414,10 @@ int get_peaks_cxi_2(struct image *image, struct hdfile *f, const char *p,
fs = fs - p->orig_min_fs;
ss = ss - p->orig_min_ss;
- image_add_feature(image->features, fs, ss, p, image, val, NULL);
+ pn = panel_number(image->det, p);
+
+ image_add_feature(image->features, fs, ss, pn,
+ image, val, NULL);
}
@@ -543,6 +547,7 @@ int get_peaks_2(struct image *image, struct hdfile *f, const char *p,
float fs, ss, val;
struct panel *p;
+ int pn;
fs = buf[tw*i+0] + peak_offset;
ss = buf[tw*i+1] + peak_offset;
@@ -556,8 +561,10 @@ int get_peaks_2(struct image *image, struct hdfile *f, const char *p,
fs = fs - p->orig_min_fs;
ss = ss - p->orig_min_ss;
- image_add_feature(image->features, fs, ss, p, image, val,
- NULL);
+ pn = panel_number(image->det, p);
+
+ image_add_feature(image->features, fs, ss, pn,
+ image, val, NULL);
}
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index b0f23871..63050a40 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -65,7 +65,7 @@ struct _imagefeaturelist
void image_add_feature(ImageFeatureList *flist, double fs, double ss,
- struct panel *p,
+ int pn,
struct image *parent, double intensity, const char *name)
{
if ( flist->n_features == flist->max_features ) {
@@ -79,7 +79,7 @@ void image_add_feature(ImageFeatureList *flist, double fs, double ss,
flist->features[flist->n_features].fs = fs;
flist->features[flist->n_features].ss = ss;
- flist->features[flist->n_features].p = p;
+ flist->features[flist->n_features].pn = pn;
flist->features[flist->n_features].intensity = intensity;
flist->features[flist->n_features].parent = parent;
flist->features[flist->n_features].name = name;
@@ -155,7 +155,7 @@ void image_feature_list_free(ImageFeatureList *flist)
struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double fs, double ss,
- struct panel *p, double *d, int *idx)
+ int pn, double *d, int *idx)
{
int i;
double dmin = +HUGE_VAL;
@@ -165,7 +165,7 @@ struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double ds;
- if ( p != flist->features[i].p ) continue;
+ if ( pn != flist->features[i].pn ) continue;
ds = distance(flist->features[i].fs, flist->features[i].ss,
fs, ss);
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index f9257560..a7d7165f 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -78,7 +78,7 @@ struct imagefeature {
double ss;
/**@}*/
- struct panel *p; /**< Pointer to panel */
+ int pn; /**< Panel number */
double intensity; /**< Intensity */
/** \name Reciprocal space coordinates (m^-1) of this feature */
@@ -203,7 +203,7 @@ extern ImageFeatureList *image_feature_list_new(void);
extern void image_feature_list_free(ImageFeatureList *flist);
extern void image_add_feature(ImageFeatureList *flist, double x, double y,
- struct panel *p,
+ int pn,
struct image *parent, double intensity,
const char *name);
@@ -211,7 +211,7 @@ extern void image_remove_feature(ImageFeatureList *flist, int idx);
extern struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double fs, double ss,
- struct panel *p,
+ int pn,
double *d, int *idx);
extern Reflection *image_reflection_closest(RefList *rlist,
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index dc689df2..7e0dd9a9 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -565,7 +565,8 @@ void map_all_peaks(struct image *image)
f = image_get_feature(image->features, i);
if ( f == NULL ) continue;
- r = get_q_for_panel(f->p, f->fs, f->ss,
+ r = get_q_for_panel(&image->det->panels[f->pn],
+ f->fs, f->ss,
NULL, 1.0/image->lambda);
f->rx = r.u; f->ry = r.v; f->rz = r.w;
@@ -819,7 +820,8 @@ static int delete_explained_peaks(struct image *image, Crystal *cr)
nspots++;
/* Reciprocal space position of found peak */
- q = get_q_for_panel(f->p, f->fs, f->ss,
+ q = get_q_for_panel(&image->det->panels[f->pn],
+ f->fs, f->ss,
NULL, 1.0/image->lambda);
/* Decimal and fractional Miller indices of nearest
diff --git a/libcrystfel/src/peakfinder8.c b/libcrystfel/src/peakfinder8.c
index c3f7c391..492f5741 100644
--- a/libcrystfel/src/peakfinder8.c
+++ b/libcrystfel/src/peakfinder8.c
@@ -1205,9 +1205,7 @@ int peakfinder8(struct image *img, int max_n_peaks,
image_add_feature(img->features,
pkdata->com_fs[pki]+0.5,
pkdata->com_ss[pki]+0.5,
- p,
- img,
- pkdata->tot_i[pki],
+ pi, img, pkdata->tot_i[pki],
NULL);
}
}
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index 7f2526bc..ed6c8995 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -219,7 +219,7 @@ int *make_BgMask(struct image *image, struct panel *p, double ir_inn)
/* Returns non-zero if peak has been vetoed.
* i.e. don't use result if return value is not zero. */
static int integrate_peak(struct image *image,
- int p_cfs, int p_css, struct panel *p,
+ int p_cfs, int p_css, int pn,
double *pfs, double *pss,
double *intensity, double *sigma,
double ir_inn, double ir_mid, double ir_out,
@@ -236,22 +236,18 @@ static int integrate_peak(struct image *image,
double bg_tot_sq = 0.0;
double var;
double aduph;
- int pn;
+ struct detgeom_panel *p;
if ( saturated != NULL ) *saturated = 0;
+ p = &image->detgeom->panels[pn];
+
aduph = p->adu_per_photon;
lim_sq = pow(ir_inn, 2.0);
mid_lim_sq = pow(ir_mid, 2.0);
out_lim_sq = pow(ir_out, 2.0);
- pn = panel_number(image->det, p);
- if ( pn == image->det->n_panels ) {
- ERROR("Couldn't find panel %p\n", p);
- return 20;
- }
-
/* Estimate the background */
for ( dss=-ir_out; dss<=+ir_out; dss++ ) {
for ( dfs=-ir_out; dfs<=+ir_out; dfs++ ) {
@@ -456,7 +452,7 @@ static void search_peaks_in_panel(struct image *image, float threshold,
assert(mask_ss >= 0);
/* Centroid peak and get better coordinates. */
- r = integrate_peak(image, mask_fs, mask_ss, p,
+ r = integrate_peak(image, mask_fs, mask_ss, pn,
&f_fs, &f_ss, &intensity, &sigma,
ir_inn, ir_mid, ir_out, &saturated);
@@ -479,7 +475,8 @@ static void search_peaks_in_panel(struct image *image, float threshold,
}
/* Check for a nearby feature */
- image_feature_closest(image->features, f_fs, f_ss, p, &d, &idx);
+ image_feature_closest(image->features, f_fs, f_ss, pn,
+ &d, &idx);
if ( d < 2.0*ir_inn ) {
nrej_pro++;
continue;
@@ -491,7 +488,7 @@ static void search_peaks_in_panel(struct image *image, float threshold,
}
/* Add using "better" coordinates */
- image_add_feature(image->features, f_fs, f_ss, p,
+ image_add_feature(image->features, f_fs, f_ss, pn,
image, intensity, NULL);
nacc++;
@@ -648,8 +645,7 @@ int search_peaks_peakfinder9(struct image *image, float min_snr_biggest_pix,
image_add_feature(image->features,
peakList.centerOfMass_rawX[peak_number],
peakList.centerOfMass_rawY[peak_number],
- &image->det->panels[panel_number],
- image,
+ panel_number, image,
peakList.totalIntensity[peak_number],
NULL);
}
@@ -709,7 +705,8 @@ int indexing_peak_check(struct image *image, Crystal **crystals, int n_cryst,
n_feat++;
/* Reciprocal space position of found peak */
- q = get_q_for_panel(f->p, f->fs, f->ss,
+ q = get_q_for_panel(&image->det->panels[f->pn],
+ f->fs, f->ss,
NULL, 1.0/image->lambda);
for ( j=0; j<n_cryst; j++ ) {
@@ -797,7 +794,7 @@ void validate_peaks(struct image *image, double min_snr,
continue;
}
- r = integrate_peak(image, f->fs, f->ss, f->p,
+ r = integrate_peak(image, f->fs, f->ss, f->pn,
&f_fs, &f_ss, &intensity, &sigma,
ir_inn, ir_mid, ir_out, &saturated);
if ( r ) {
@@ -818,8 +815,8 @@ void validate_peaks(struct image *image, double min_snr,
}
/* Add using "better" coordinates */
- image_add_feature(flist, f->fs, f->ss, f->p, image, intensity,
- NULL);
+ image_add_feature(flist, f->fs, f->ss, f->pn, image,
+ intensity, NULL);
}
@@ -841,7 +838,8 @@ static int compare_double(const void *av, const void *bv)
}
-double estimate_peak_resolution(ImageFeatureList *peaks, double lambda)
+double estimate_peak_resolution(ImageFeatureList *peaks, double lambda,
+ struct detector *det)
{
int i, npk, ncut;
double *rns;
@@ -863,7 +861,8 @@ double estimate_peak_resolution(ImageFeatureList *peaks, double lambda)
f = image_get_feature(peaks, i);
- r = get_q_for_panel(f->p, f->fs, f->ss, NULL, 1.0/lambda);
+ r = get_q_for_panel(&det->panels[f->pn],
+ f->fs, f->ss, NULL, 1.0/lambda);
rns[i] = modulus(r.u, r.v, r.w);
}
diff --git a/libcrystfel/src/peaks.h b/libcrystfel/src/peaks.h
index 89388652..5a143d2a 100644
--- a/libcrystfel/src/peaks.h
+++ b/libcrystfel/src/peaks.h
@@ -79,7 +79,9 @@ extern void validate_peaks(struct image *image, double min_snr,
int ir_inn, int ir_mid, int ir_out,
int use_saturated, int check_snr);
-extern double estimate_peak_resolution(ImageFeatureList *peaks, double lambda);
+extern double estimate_peak_resolution(ImageFeatureList *peaks,
+ double lambda,
+ struct detector *det);
#ifdef __cplusplus
}
diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c
index aff5fc22..0b33c211 100644
--- a/libcrystfel/src/predict-refine.c
+++ b/libcrystfel/src/predict-refine.c
@@ -267,11 +267,11 @@ static int pair_peaks(struct image *image, Crystal *cr,
* in how far away it is from the peak location.
* The predicted position and excitation errors will be
* filled in by update_predictions(). */
- set_panel(refl, f->p);
+ set_panel(refl, &image->det->panels[f->pn]);
rps[n].refl = refl;
rps[n].peak = f;
- rps[n].panel = f->p;
+ rps[n].panel = &image->det->panels[f->pn];
n++;
}
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index bfe4a50a..875285e5 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -99,7 +99,6 @@ static int read_peaks(Stream *st, struct image *image)
char line[1024];
float x, y, d, intensity;
int r;
- struct panel *p = NULL;
float add_x, add_y;
rval = fgets(line, 1023, st->fh);
@@ -121,6 +120,8 @@ static int read_peaks(Stream *st, struct image *image)
if ( image->det != NULL ) {
+ int pn;
+ struct panel *p = NULL;
p = find_orig_panel(image->det, x, y);
if ( p == NULL ) {
ERROR("Panel not found\n");
@@ -129,14 +130,15 @@ static int read_peaks(Stream *st, struct image *image)
add_x = x-p->orig_min_fs;
add_y = y-p->orig_min_ss;
+ pn = panel_number(image->det, p);
image_add_feature(image->features, add_x, add_y,
- p, image, intensity, NULL);
+ pn, image, intensity, NULL);
} else {
image_add_feature(image->features, x, y,
- p, image, intensity, NULL);
+ 0, image, intensity, NULL);
}
}
@@ -160,7 +162,6 @@ static int read_peaks_2_3(Stream *st, struct image *image)
char pn[32];
float x, y, d, intensity;
int r;
- struct panel *p = NULL;
float add_x, add_y;
rval = fgets(line, 1023, st->fh);
@@ -181,6 +182,8 @@ static int read_peaks_2_3(Stream *st, struct image *image)
if ( r == 5 ) {
+ int pnum;
+ struct panel *p;
p = find_panel_by_name(image->det, pn);
if ( p == NULL ) {
ERROR("Panel not found: %s\n", pn);
@@ -190,7 +193,10 @@ static int read_peaks_2_3(Stream *st, struct image *image)
add_x = x-p->orig_min_fs;
add_y = y-p->orig_min_ss;
- image_add_feature(image->features, add_x, add_y, p,
+ pnum = panel_number(image->det, p);
+
+ image_add_feature(image->features,
+ add_x, add_y, pnum,
image, intensity, NULL);
}
@@ -218,7 +224,8 @@ static int write_peaks(struct image *image, FILE *ofh)
f = image_get_feature(image->features, i);
if ( f == NULL ) continue;
- r = get_q_for_panel(f->p, f->fs, f->ss,
+ r = get_q_for_panel(&image->det->panels[f->pn],
+ f->fs, f->ss,
NULL, 1.0/image->lambda);
q = modulus(r.u, r.v, r.w);
@@ -268,21 +275,24 @@ static int write_peaks_2_3(struct image *image, FILE *ofh)
struct rvec r;
double q;
double write_fs, write_ss;
+ struct panel *p;
f = image_get_feature(image->features, i);
if ( f == NULL ) continue;
- r = get_q_for_panel(f->p, f->fs, f->ss,
+ p = &image->det->panels[f->pn];
+ r = get_q_for_panel(p, f->fs, f->ss,
NULL, 1.0/image->lambda);
q = modulus(r.u, r.v, r.w);
/* Convert coordinates to match arrangement of panels in HDF5
* file */
- write_fs = f->fs + f->p->orig_min_fs;
- write_ss = f->ss + f->p->orig_min_ss;
+ write_fs = f->fs + p->orig_min_fs;
+ write_ss = f->ss + p->orig_min_ss;
fprintf(ofh, "%7.2f %7.2f %10.2f %10.2f %s\n",
- write_fs, write_ss, q/1.0e9, f->intensity, f->p->name);
+ write_fs, write_ss, q/1.0e9, f->intensity,
+ p->name);
}
diff --git a/src/geoptimiser.c b/src/geoptimiser.c
index 136cca39..73e37249 100644
--- a/src/geoptimiser.c
+++ b/src/geoptimiser.c
@@ -768,7 +768,8 @@ static int compute_pixel_displacements(struct image *images, int n_images,
imfe = image_get_feature(flist, fi);
if ( imfe == NULL ) continue;
- compute_x_y(imfe->fs, imfe->ss, imfe->p, &fx, &fy);
+ compute_x_y(imfe->fs, imfe->ss,
+ &det->panels[imfe->pn], &fx, &fy);
/* Find the closest reflection (from all crystals) */
refl = find_closest_reflection(&images[cp], fx, fy,
@@ -779,7 +780,7 @@ static int compute_pixel_displacements(struct image *images, int n_images,
struct gpanel *gp;
int r;
- gp = &gpanels[panel_number(det, imfe->p)];
+ gp = &gpanels[imfe->pn];
r = add_distance_to_list(gp, imfe, refl, fx, fy,
det_shift);
diff --git a/src/process_image.c b/src/process_image.c
index 1e6bb814..930052c4 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -359,7 +359,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
}
image.peak_resolution = estimate_peak_resolution(image.features,
- image.lambda);
+ image.lambda,
+ image.det);
restore_image_data(image.dp, image.det, prefilter);
diff --git a/tests/ring_check.c b/tests/ring_check.c
index e0667e37..f286d5e7 100644
--- a/tests/ring_check.c
+++ b/tests/ring_check.c
@@ -67,7 +67,7 @@ static void third_integration_check(struct image *image, int n_trials,
}
}
- r = integrate_peak(image, 64, 64, &image->det->panels[0],
+ r = integrate_peak(image, 64, 64, 0,
&fsp, &ssp, &intensity, &sigma,
10.0, 15.0, 17.0, NULL);
@@ -129,7 +129,7 @@ static void fourth_integration_check(struct image *image, int n_trials,
}
}
- r = integrate_peak(image, 64, 64, &image->det->panels[0],
+ r = integrate_peak(image, 64, 64, 0,
&fsp, &ssp, &intensity, &sigma,
10.0, 15.0, 17.0, NULL);
@@ -219,7 +219,7 @@ int main(int argc, char *argv[])
image.crystals = NULL;
/* First check: no intensity -> no peak, or very low intensity */
- r = integrate_peak(&image, 64, 64, &image.det->panels[0],
+ r = integrate_peak(&image, 64, 64, 0,
&fsp, &ssp, &intensity, &sigma,
10.0, 15.0, 17.0, NULL);
STATUS(" First check: integrate_peak() returned %i", r);
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
}
}
- r = integrate_peak(&image, 64, 64, &image.det->panels[0],
+ r = integrate_peak(&image, 64, 64, 0,
&fsp, &ssp, &intensity, &sigma,
10.0, 15.0, 17.0, NULL);
if ( r ) {
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
}
}
- r = integrate_peak(&image, 64, 64, &image.det->panels[0],
+ r = integrate_peak(&image, 64, 64, 0,
&fsp, &ssp, &intensity, &sigma,
10.0, 15.0, 17.0, NULL);
if ( r ) {