aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/hdf5-file.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-10-24 16:51:51 +0200
committerThomas White <taw@physics.org>2014-10-24 17:05:19 +0200
commit8ca1b8127f53088e04a046a93d10a07d2dc5e2d0 (patch)
treebbc8d9966a3b9c8670d21076af8dd4f46f674efd /libcrystfel/src/hdf5-file.c
parent3ad117acb65ac707acc11ac32a50e6755203d590 (diff)
Fix/clarify peak coordinates for rearranged panels
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r--libcrystfel/src/hdf5-file.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index fac07c43..42408fa1 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -191,6 +191,26 @@ int hdfile_set_image(struct hdfile *f, const char *path,
}
+/* Like find_panel(), but uses the original panel bounds, i.e. referring to
+ * what's in the HDF5 file */
+struct panel *find_orig_panel(struct detector *det, double fs, double ss)
+{
+ int p;
+
+ for ( p=0; p<det->n_panels; p++ ) {
+ if ( (fs >= det->panels[p].orig_min_fs)
+ && (fs < det->panels[p].orig_max_fs+1)
+ && (ss >= det->panels[p].orig_min_ss)
+ && (ss < det->panels[p].orig_max_ss+1) )
+ {
+ return &det->panels[p];
+ }
+ }
+
+ return NULL;
+}
+
+
int get_peaks(struct image *image, struct hdfile *f, const char *p)
{
hid_t dh, sh;
@@ -260,10 +280,14 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p)
ss = buf[tw*i+1];
val = buf[tw*i+2];
- p = find_panel(image->det, fs, ss);
+ p = find_orig_panel(image->det, fs, ss);
if ( p == NULL ) continue;
if ( p->no_index ) continue;
+ /* Convert coordinates to match rearranged panels in memory */
+ fs = fs - p->orig_min_fs + p->min_fs;
+ ss = ss - p->orig_min_ss + p->min_ss;
+
image_add_feature(image->features, fs, ss, image, val, NULL);
}