diff options
author | Thomas White <taw@physics.org> | 2010-02-17 15:04:14 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-02-17 15:04:14 +0100 |
commit | c7c73d91c8eb909ecd2e8911ee2dd051d398412b (patch) | |
tree | 5cab7031505bcc95806930e110e45bf1057d94fc | |
parent | ae76664c17533d29555aeef41b7534c78407825f (diff) |
Fix obvious mapping bugs
-rw-r--r-- | src/detector.c | 1 | ||||
-rw-r--r-- | src/index.c | 13 | ||||
-rw-r--r-- | src/pattern_sim.c | 4 | ||||
-rw-r--r-- | src/peaks.c | 32 |
4 files changed, 16 insertions, 34 deletions
diff --git a/src/detector.c b/src/detector.c index 94e11a9e..5a7407c9 100644 --- a/src/detector.c +++ b/src/detector.c @@ -183,6 +183,7 @@ void record_image(struct image *image, int do_water, int do_poisson, && (y >= image->det.panels[p].min_y) && (y <= image->det.panels[p].max_y) ) { found = 1; + break; } } if ( !found ) { diff --git a/src/index.c b/src/index.c index 4e8460f6..49e21bb7 100644 --- a/src/index.c +++ b/src/index.c @@ -50,11 +50,13 @@ int map_position(struct image *image, double dx, double dy, x = ((double)dx - image->det.panels[p].cx); y = ((double)dy - image->det.panels[p].cy); found = 1; + break; } } if ( !found ) { - ERROR("No mapping found for %f,%f\n", dx, dy); - return 0; + ERROR("No mapping found for %f,%f (map_position)\n", dx, dy); + *rx = 0.0; *ry = 0.0; *rz = 0.0; + return 1; } /* Convert pixels to metres */ @@ -113,13 +115,14 @@ void index_pattern(struct image *image, IndexingMethod indm, int no_match) for ( i=0; i<image_feature_count(image->features); i++ ) { struct imagefeature *f; + int c; f = image_get_feature(image->features, i); if ( f == NULL ) continue; - if ( map_position(image, f->x, f->y, &f->rx, &f->ry, &f->rz) ) { - nc++; - } + c = map_position(image, f->x, f->y, &f->rx, &f->ry, &f->rz); + if ( c != 0 ) nc++; + } if ( nc ) { ERROR("Failed to map %i reflections\n", nc); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 340acd8b..a64c754b 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -236,6 +236,8 @@ int main(int argc, char *argv[]) image.det.panels[0].max_y = 1023; image.det.panels[0].cx = 491.9; image.det.panels[0].cy = 440.7; + image.det.panels[0].clen = 67.0e-3; + image.det.panels[0].res = 13333.3; /* 75 micron pixel size */ /* Lower panel */ image.det.panels[1].min_x = 0; image.det.panels[1].max_x = 1023; @@ -243,6 +245,8 @@ int main(int argc, char *argv[]) image.det.panels[1].max_y = 511; image.det.panels[1].cx = 492.0; image.det.panels[1].cy = 779.7; + image.det.panels[1].clen = 75.0e-3; + image.det.panels[1].res = 13333.3; /* 75 micron pixel size */ powder = calloc(image.width*image.height, sizeof(*powder)); diff --git a/src/peaks.c b/src/peaks.c index fafbe696..8e757c40 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -426,46 +426,20 @@ void dump_peaks(struct image *image) { int i; - printf("x/px\ty/px\t(1/d)/nm^-1\tIntegrated I\n"); + printf("x/px\ty/px\t(1/d)/nm^-1\n"); for ( i=0; i<image_feature_count(image->features); i++ ) { double q, rx, ry, rz; - int x, y; - double rcx = 0.0; - double rcy = 0.0; - int found = 0; struct imagefeature *f; - int p; f = image_get_feature(image->features, i); if ( f == NULL ) continue; - x = f->x; - y = f->y; - - for ( p=0; p<image->det.n_panels; p++ ) { - if ( (x >= image->det.panels[p].min_x) - && (x <= image->det.panels[p].max_x) - && (y >= image->det.panels[p].min_y) - && (y <= image->det.panels[p].max_y) ) { - rcx = ((double)x - image->det.panels[p].cx) - / image->det.panels[p].res; - rcy = ((double)y - image->det.panels[p].cy) - / image->det.panels[p].res; - found = 1; - } - } - if ( !found ) { - ERROR("No mapping found for %i,%i\n", x, y); - continue; - } - - map_position(image, rcx, rcy, &rx, &ry, &rz); + map_position(image, f->x, f->y, &rx, &ry, &rz); q = modulus(rx, ry, rz); - printf("%i\t%i\t%f\t%i\n", x, y, q/1.0e9, - image->data[x+image->width*y]); + printf("%7.3f\t%7.3f\t%7.3f\t%7.3f\n", f->x, f->y, q/1.0e9, 1.0); } } |