diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/calibrate_detector.c | 8 | ||||
-rw-r--r-- | src/detector.c | 97 | ||||
-rw-r--r-- | src/detector.h | 14 | ||||
-rw-r--r-- | src/dw-geomatic.c | 4 | ||||
-rw-r--r-- | src/geometry.c | 8 | ||||
-rw-r--r-- | src/indexamajig.c | 16 | ||||
-rw-r--r-- | src/pattern_sim.c | 4 | ||||
-rw-r--r-- | src/peaks.c | 8 |
8 files changed, 84 insertions, 75 deletions
diff --git a/src/calibrate_detector.c b/src/calibrate_detector.c index 78872bad..20503388 100644 --- a/src/calibrate_detector.c +++ b/src/calibrate_detector.c @@ -58,8 +58,8 @@ static void split_image(struct image *image) p = &det->panels[i]; - width = 1 + p->max_x - p->min_x; - height = 1 + p->max_y - p->min_y; + width = 1 + p->max_fs - p->min_fs; + height = 1 + p->max_ss - p->min_ss; data = malloc(width*height*sizeof(float)); snprintf(filename, 1023, "%s-%i.h5", image->filename, i); @@ -71,8 +71,8 @@ static void split_image(struct image *image) int im_x, im_y; - im_x = x+p->min_x; - im_y = y+p->min_y; + im_x = x+p->min_fs; + im_y = y+p->min_ss; data[x+width*y] = image->data[im_x+image->width*im_y]; diff --git a/src/detector.c b/src/detector.c index 368e5797..209958b1 100644 --- a/src/detector.c +++ b/src/detector.c @@ -78,8 +78,8 @@ struct rvec get_q(struct image *image, double fs, double ss, /* Convert xs and ys, which are in fast scan/slow scan coordinates, * to x and y */ - xs = (fs-p->min_x)*p->fsx + (ss-p->min_y)*p->ssx; - ys = (fs-p->min_x)*p->fsy + (ss-p->min_y)*p->ssy; + xs = (fs-p->min_fs)*p->fsx + (ss-p->min_ss)*p->ssx; + ys = (fs-p->min_fs)*p->fsy + (ss-p->min_ss)*p->ssy; rx = (xs + p->cx) / p->res; ry = (ys + p->cy) / p->res; @@ -99,15 +99,24 @@ struct rvec get_q(struct image *image, double fs, double ss, } -double get_tt(struct image *image, double xs, double ys) +double get_tt(struct image *image, double fs, double ss) { - float r, rx, ry; + double r, rx, ry; struct panel *p; + double xs, ys; - p = find_panel(image->det, xs, ys); + p = find_panel(image->det, fs, ss); - rx = ((float)xs - p->cx) / p->res; - ry = ((float)ys - p->cy) / p->res; + /* Convert xs and ys, which are in fast scan/slow scan coordinates, + * to x and y */ + xs = (fs-p->min_fs)*p->fsx + (ss-p->min_ss)*p->ssx; + ys = (fs-p->min_fs)*p->fsy + (ss-p->min_ss)*p->ssy; + + rx = (xs + p->cx) / p->res; + ry = (ys + p->cy) / p->res; + + /* Calculate q-vector for this sub-pixel */ + r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); @@ -218,10 +227,10 @@ struct panel *find_panel(struct detector *det, int x, int y) int p; for ( p=0; p<det->n_panels; p++ ) { - if ( (x >= det->panels[p].min_x) - && (x <= det->panels[p].max_x) - && (y >= det->panels[p].min_y) - && (y <= det->panels[p].max_y) ) { + if ( (x >= det->panels[p].min_fs) + && (x <= det->panels[p].max_fs) + && (y >= det->panels[p].min_ss) + && (y <= det->panels[p].max_ss) ) { return &det->panels[p]; } } @@ -239,7 +248,7 @@ struct detector *get_detector_geometry(const char *filename) char **bits; int i; int reject = 0; - int x, y, max_x, max_y; + int x, y, max_fs, max_ss; fh = fopen(filename, "r"); if ( fh == NULL ) return NULL; @@ -292,10 +301,10 @@ struct detector *get_detector_geometry(const char *filename) free(bits); for ( i=0; i<det->n_panels; i++ ) { - det->panels[i].min_x = -1; - det->panels[i].min_y = -1; - det->panels[i].max_x = -1; - det->panels[i].max_y = -1; + det->panels[i].min_fs = -1; + det->panels[i].min_ss = -1; + det->panels[i].max_fs = -1; + det->panels[i].max_ss = -1; det->panels[i].cx = -1; det->panels[i].cy = -1; det->panels[i].clen = -1; @@ -337,14 +346,14 @@ struct detector *get_detector_geometry(const char *filename) return NULL; } - if ( strcmp(path[1], "min_x") == 0 ) { - det->panels[np].min_x = atof(bits[2]); - } else if ( strcmp(path[1], "max_x") == 0 ) { - det->panels[np].max_x = atof(bits[2]); - } else if ( strcmp(path[1], "min_y") == 0 ) { - det->panels[np].min_y = atof(bits[2]); - } else if ( strcmp(path[1], "max_y") == 0 ) { - det->panels[np].max_y = atof(bits[2]); + if ( strcmp(path[1], "min_fs") == 0 ) { + det->panels[np].min_fs = atof(bits[2]); + } else if ( strcmp(path[1], "max_fs") == 0 ) { + det->panels[np].max_fs = atof(bits[2]); + } else if ( strcmp(path[1], "min_ss") == 0 ) { + det->panels[np].min_ss = atof(bits[2]); + } else if ( strcmp(path[1], "max_ss") == 0 ) { + det->panels[np].max_ss = atof(bits[2]); } else if ( strcmp(path[1], "corner_x") == 0 ) { det->panels[np].cx = atof(bits[2]); } else if ( strcmp(path[1], "corner_y") == 0 ) { @@ -399,37 +408,37 @@ struct detector *get_detector_geometry(const char *filename) return NULL; } - max_x = 0; - max_y = 0; + max_fs = 0; + max_ss = 0; for ( i=0; i<det->n_panels; i++ ) { - if ( det->panels[i].min_x == -1 ) { - ERROR("Please specify the minimum x coordinate for" + if ( det->panels[i].min_fs == -1 ) { + ERROR("Please specify the minimum FS coordinate for" " panel %i\n", i); reject = 1; } - if ( det->panels[i].max_x == -1 ) { - ERROR("Please specify the maximum x coordinate for" + if ( det->panels[i].max_fs == -1 ) { + ERROR("Please specify the maximum FS coordinate for" " panel %i\n", i); reject = 1; } - if ( det->panels[i].min_y == -1 ) { - ERROR("Please specify the minimum y coordinate for" + if ( det->panels[i].min_ss == -1 ) { + ERROR("Please specify the minimum SS coordinate for" " panel %i\n", i); reject = 1; } - if ( det->panels[i].max_y == -1 ) { - ERROR("Please specify the maximum y coordinate for" + if ( det->panels[i].max_ss == -1 ) { + ERROR("Please specify the maximum SS coordinate for" " panel %i\n", i); reject = 1; } if ( det->panels[i].cx == -1 ) { - ERROR("Please specify the centre x coordinate for" + ERROR("Please specify the corner X coordinate for" " panel %i\n", i); reject = 1; } if ( det->panels[i].cy == -1 ) { - ERROR("Please specify the centre y coordinate for" + ERROR("Please specify the corner Y coordinate for" " panel %i\n", i); reject = 1; } @@ -447,17 +456,17 @@ struct detector *get_detector_geometry(const char *filename) /* It's not a problem if "no_index" is still zero */ /* The default peak_sep is OK (maybe) */ - if ( det->panels[i].max_x > max_x ) { - max_x = det->panels[i].max_x; + if ( det->panels[i].max_fs > max_fs ) { + max_fs = det->panels[i].max_fs; } - if ( det->panels[i].max_y > max_y ) { - max_y = det->panels[i].max_y; + if ( det->panels[i].max_ss > max_ss ) { + max_ss = det->panels[i].max_ss; } } - for ( x=0; x<=max_x; x++ ) { - for ( y=0; y<=max_y; y++ ) { + for ( x=0; x<=max_fs; x++ ) { + for ( y=0; y<=max_ss; y++ ) { if ( find_panel(det, x, y) == NULL ) { ERROR("Detector geometry invalid: contains gaps.\n"); reject = 1; @@ -466,8 +475,8 @@ struct detector *get_detector_geometry(const char *filename) } } out: - det->max_x = max_x; - det->max_y = max_y; + det->max_fs = max_fs; + det->max_ss = max_ss; if ( reject ) return NULL; diff --git a/src/detector.h b/src/detector.h index 281db57a..c32fd07b 100644 --- a/src/detector.h +++ b/src/detector.h @@ -22,11 +22,11 @@ struct image; struct panel { - int min_x; /* Smallest x value considered to be in this panel */ - int max_x; /* Largest x value considered to be in this panel */ - int min_y; /* ... and so on */ - int max_y; - float cx; /* Location of centre in pixels */ + 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; + float cx; /* Location of corner (min_fs,min_ss) in pixels */ float cy; float clen; /* Camera length in metres */ float res; /* Resolution in pixels per metre */ @@ -44,8 +44,8 @@ struct detector { struct panel *panels; int n_panels; - int max_x; - int max_y; /* Size of overall array needed, minus 1 */ + int max_fs; + int max_ss; /* Size of overall array needed, minus 1 */ }; extern struct rvec get_q(struct image *image, double xs, double ys, diff --git a/src/dw-geomatic.c b/src/dw-geomatic.c index c5137e43..a2809cb0 100644 --- a/src/dw-geomatic.c +++ b/src/dw-geomatic.c @@ -367,8 +367,8 @@ static gint displaywindow_loadgeom_response(GtkWidget *d, gint response, } /* Validate geometry */ - if ( (1+det->max_x != dw->image->width) - || (1+det->max_y != dw->image->height) ) { + if ( (1+det->max_fs != dw->image->width) + || (1+det->max_ss != dw->image->height) ) { displaywindow_error(dw, "Geometry does not match image size"); diff --git a/src/geometry.c b/src/geometry.c index ae0e643d..33527f71 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -58,10 +58,10 @@ static signed int locate_peak(double x, double y, double z, double k, yda = yd + det->panels[p].cy; /* Now, is this on this panel? */ - if ( xda < det->panels[p].min_x ) continue; - if ( xda > det->panels[p].max_x ) continue; - if ( yda < det->panels[p].min_y ) continue; - if ( yda > det->panels[p].max_y ) continue; + if ( xda < det->panels[p].min_fs ) continue; + if ( xda > det->panels[p].max_fs ) continue; + if ( yda < det->panels[p].min_ss ) continue; + if ( yda > det->panels[p].max_ss ) continue; /* If peak appears on multiple panels, reject it */ if ( found != -1 ) return -1; diff --git a/src/indexamajig.c b/src/indexamajig.c index 6112066c..7fae3ea6 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -229,20 +229,20 @@ static struct image *get_simage(struct image *template, int alternate) if ( alternate ) { /* Upper */ - panels[0].min_x = 0; - panels[0].max_x = 1023; - panels[0].min_y = 512; - panels[0].max_y = 1023; + panels[0].min_fs = 0; + panels[0].max_fs = 1023; + panels[0].min_ss = 512; + panels[0].max_ss = 1023; panels[0].cx = 523.6; panels[0].cy = 502.5; panels[0].clen = 56.4e-2; /* 56.4 cm */ panels[0].res = 13333.3; /* 75 microns/pixel */ /* Lower */ - panels[1].min_x = 0; - panels[1].max_x = 1023; - panels[1].min_y = 0; - panels[1].max_y = 511; + panels[1].min_fs = 0; + panels[1].max_fs = 1023; + panels[1].min_ss = 0; + panels[1].max_ss = 511; panels[1].cx = 520.8; panels[1].cy = 525.0; panels[1].clen = 56.7e-2; /* 56.7 cm */ diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 326ce362..fe6a8f0d 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -471,8 +471,8 @@ int main(int argc, char *argv[]) free(beamfile); /* Define image parameters */ - image.width = image.det->max_x + 1; - image.height = image.det->max_y + 1; + image.width = image.det->max_fs + 1; + image.height = image.det->max_ss + 1; image.lambda = ph_en_to_lambda(eV_to_J(image.beam->photon_energy)); /* Load unit cell */ diff --git a/src/peaks.c b/src/peaks.c index 99c82323..d158f064 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -95,10 +95,10 @@ static int cull_peaks_in_panel(struct image *image, struct panel *p) f = image_get_feature(image->features, i); if ( f == NULL ) continue; - if ( f->x < p->min_x ) continue; - if ( f->x > p->max_x ) continue; - if ( f->y < p->min_y ) continue; - if ( f->y > p->max_y ) continue; + if ( f->x < p->min_fs ) continue; + if ( f->x > p->max_fs ) continue; + if ( f->y < p->min_ss ) continue; + if ( f->y > p->max_ss ) continue; /* How many peaks are in the same column? */ ncol = 0; |