diff options
-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 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 26 |
4 files changed, 53 insertions, 15 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); } diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index a73b4abf..4dd04940 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -8,7 +8,7 @@ * Copyright © 2012 Richard Kirian * * Authors: - * 2009-2013 Thomas White <taw@physics.org> + * 2009-2014 Thomas White <taw@physics.org> * 2014 Valerio Mariani * 2014 Takanori Nakane * 2012 Richard Kirian @@ -1017,7 +1017,6 @@ static void load_features_from_file(struct image *image, const char *filename) do { char line[1024]; float intensity, sigma, fs, ss; - float add_fs, add_ss; char phs[1024]; char pn[32]; int r; @@ -1029,24 +1028,28 @@ static void load_features_from_file(struct image *image, const char *filename) if ( rval == NULL ) continue; chomp(line); - /* Try long format (from stream) */ + /* Try long reflection format (from stream) */ r = sscanf(line, "%i %i %i %f %s %f %f %f %f %s", &h, &k, &l, &intensity, phs, &sigma, &cts, &fs, &ss, pn); if ( r == 10 ) { + char name[32]; snprintf(name, 31, "%i %i %i", h, k, l); - p = find_panel_by_name(image->det, pn); - add_fs = fs-p->orig_min_fs+p->min_fs; - add_ss = ss-p->orig_min_ss+p->min_ss; - image_add_feature(image->features, add_fs, add_ss, + /* 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, 1.0, strdup(name)); continue; } + /* Try long peak format from stream */ r = sscanf(line, "%f %f %f %f %s", &fs, &ss, &d, &intensity, pn); if ( r != 5 ) continue; @@ -1056,9 +1059,12 @@ static void load_features_from_file(struct image *image, const char *filename) ERROR("Unable to find panel %s\n", pn); } else { - add_fs = fs - p->orig_min_fs + p->min_fs; - add_ss = ss - p->orig_min_ss + p->min_ss; - image_add_feature(image->features, add_fs, add_ss, + /* 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, 1.0, "peak"); } |