From 225f2f78c0f0606ec3b1d305ff084df950b0c6f5 Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Wed, 19 Nov 2014 16:39:48 +0100 Subject: Moved fs ss rerrangement to get_detector_geometry --- libcrystfel/src/detector.c | 28 +++++++++++++++++++++++----- libcrystfel/src/hdf5-file.c | 18 ++++-------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 513d08f1..09eb964d 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -919,6 +919,7 @@ struct detector *get_detector_geometry(const char *filename, int reject = 0; int path_dim; int dim_dim; + int curr_ss; int x, y, max_fs, max_ss; int dim_reject = 0; int dim_dim_reject = 0; @@ -1186,8 +1187,16 @@ struct detector *get_detector_geometry(const char *filename, det->dim_dim = dim_dim; + curr_ss = 0; + for ( i=0; in_panels; i++ ) { + if ( det->panels[i].max_fs-det->panels[i].min_fs+1 != + det->panels[0].max_fs-det->panels[0].min_fs+1 ) { + ERROR("All panels should have the same fs extent\n"); + reject = 1; + } + if ( det->panels[i ].min_fs < 0 ) { ERROR("Please specify the minimum FS coordinate for" " panel %s\n", det->panels[i].name); @@ -1239,6 +1248,20 @@ struct detector *get_detector_geometry(const char *filename, /* It's not a problem if "no_index" is still zero */ /* The default transformation matrix is at least valid */ + det->panels[i].orig_max_fs = det->panels[i].max_fs; + det->panels[i].orig_min_fs = det->panels[i].min_fs; + det->panels[i].orig_max_ss = det->panels[i].max_ss; + det->panels[i].orig_min_ss = det->panels[i].min_ss; + + det->panels[i].w = det->panels[i].max_fs-det->panels[i].min_fs+1; + det->panels[i].h = det->panels[i].max_ss-det->panels[i].min_ss+1; + + det->panels[i].min_fs = 0; + det->panels[i].max_fs = det->panels[i].w-1; + det->panels[i].min_ss = curr_ss; + det->panels[i].max_ss = curr_ss+det->panels[i].h-1; + curr_ss += det->panels[i].h; + if ( det->panels[i].max_fs > max_fs ) { max_fs = det->panels[i].max_fs; } @@ -1246,11 +1269,6 @@ struct detector *get_detector_geometry(const char *filename, max_ss = det->panels[i].max_ss; } - det->panels[i].orig_max_fs = det->panels[i].max_fs; - det->panels[i].orig_min_fs = det->panels[i].min_fs; - det->panels[i].orig_max_ss = det->panels[i].max_ss; - det->panels[i].orig_min_ss = det->panels[i].min_ss; - } for ( i=0; in_bad; i++ ) { diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 88bd61c4..b2e355e4 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -1084,7 +1084,6 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, float *buf; int sum_p_h; int p_w; - int m_min_fs, curr_ss, m_max_fs; int pi; if ( image->det == NULL ) { @@ -1120,9 +1119,6 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, return 1; } - m_min_fs = 0; - m_max_fs = p_w-1; - curr_ss = 0; for ( pi=0; pidet->n_panels; pi++ ) { @@ -1230,10 +1226,10 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, return 1; } - m_offset[0] = curr_ss; - m_offset[1] = 0; - m_count[0] = p->orig_max_ss - p->orig_min_ss +1; - m_count[1] = m_max_fs - m_min_fs +1; + m_offset[0] = p->min_ss; + m_offset[1] = p->min_fs; + m_count[0] = p->max_ss - p->min_ss +1; + m_count[1] = p->max_fs - p->min_fs +1; dimsm[0] = sum_p_h; dimsm[1] = p_w; memspace = H5Screate_simple(2, dimsm, NULL); @@ -1264,12 +1260,6 @@ int hdf5_read2(struct hdfile *f, struct image *image, struct event *ev, f_offset, f_count, m_offset, m_count); } - p->min_fs = m_min_fs; - p->max_fs = m_max_fs; - p->min_ss = curr_ss; - p->max_ss = curr_ss + p->h-1; - curr_ss += p->h; - free(f_offset); free(f_count); -- cgit v1.2.3