diff options
author | Thomas White <taw@physics.org> | 2014-10-24 16:51:51 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-10-24 17:05:19 +0200 |
commit | 8ca1b8127f53088e04a046a93d10a07d2dc5e2d0 (patch) | |
tree | bbc8d9966a3b9c8670d21076af8dd4f46f674efd /libcrystfel/src | |
parent | 3ad117acb65ac707acc11ac32a50e6755203d590 (diff) |
Fix/clarify peak coordinates for rearranged panels
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/detector.h | 5 | ||||
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 26 | ||||
-rw-r--r-- | libcrystfel/src/stream.c | 11 |
3 files changed, 37 insertions, 5 deletions
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index 519de050..276dd268 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -75,10 +75,12 @@ struct panel { char name[1024]; /* Name for this panel */ + /* Position of panel in the data block in memory (see below) */ int min_fs; /* Smallest FS value considered to be in the panel */ int max_fs; /* Largest FS value considered to be in this panel */ int min_ss; /* ... and so on */ int max_ss; + double cnx; /* Location of corner (min_fs,min_ss) in pixels */ double cny; double coffset; @@ -105,6 +107,9 @@ struct panel double xss; double yss; + /* Position of the panel in the data block in the file. The panels may + * get moved around when the file is loaded (see hdf5_read2()), + * especially if the panels come from different HDF5 elements. */ int orig_min_fs; int orig_max_fs; int orig_min_ss; 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); } diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index cb152088..cf891f96 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -210,12 +210,15 @@ static void write_peaks_2_3(struct image *image, FILE *ofh) r = get_q(image, f->fs, f->ss, NULL, 1.0/image->lambda); q = modulus(r.u, r.v, r.w); - p = find_panel(image->det,f->fs,f->ss); - write_fs = f->fs-p->min_fs+p->orig_min_fs; - write_ss = f->ss-p->min_ss+p->orig_min_ss; + p = find_panel(image->det, f->fs, f->ss); + + /* Convert coordinates to match arrangement of panels in HDF5 + * file */ + write_fs = f->fs - p->min_fs + p->orig_min_fs; + write_ss = f->ss - p->min_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, p->name); + write_fs, write_ss, q/1.0e9, f->intensity, p->name); } |