diff options
author | Thomas White <taw@physics.org> | 2010-01-13 10:46:44 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-01-13 10:46:44 +0100 |
commit | f7d118ec0bc9e7dd964bbb9a8bc4fad46b8412d7 (patch) | |
tree | c4e3da3218d1f8c61a3e0e6147a260245018d9e0 /src/index.c | |
parent | 26dc86b5b6624177591909ae3d2c8d7d8bae9159 (diff) |
Make DirAx use optional
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/index.c b/src/index.c new file mode 100644 index 00000000..c8d5dbe6 --- /dev/null +++ b/src/index.c @@ -0,0 +1,98 @@ +/* + * index.c + * + * Perform indexing (somehow) + * + * (c) 2006-2009 Thomas White <taw@physics.org> + * + * Part of CrystFEL - crystallography with a FEL + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <string.h> +#include <assert.h> + +#include "image.h" +#include "utils.h" +#include "peaks.h" +#include "dirax.h" + + +static int map_position(struct image *image, double x, double y, + double *rx, double *ry, double *rz) +{ + /* "Input" space */ + double d; + + /* Angular description of reflection */ + double theta, psi, k; + + x -= image->x_centre; + y -= image->y_centre; + k = 1.0 / image->lambda; + + /* FIXME: Don't process lower CCD for now */ + if ( y < 0 ) return 0; + + if ( image->fmode == FORMULATION_CLEN ) { + + /* Convert pixels to metres */ + x /= image->resolution; + y /= image->resolution; /* Convert pixels to metres */ + d = sqrt((x*x) + (y*y)); + theta = atan2(d, image->camera_len); + + } else if (image->fmode == FORMULATION_PIXELSIZE ) { + + /* Convert pixels to metres^-1 */ + x *= image->pixel_size; + y *= image->pixel_size; /* Convert pixels to metres^-1 */ + d = sqrt((x*x) + (y*y)); + theta = atan2(d, k); + + } else { + ERROR("Unrecognised formulation mode in mapping_scale.\n"); + return -1; + } + + psi = atan2(y, x); + + *rx = k*sin(theta)*cos(psi); + *ry = k*sin(theta)*sin(psi); + *rz = k - k*cos(theta); + + return 0; +} + + +void index_pattern(struct image *image, int no_index, int dump_peaks, + int use_dirax) +{ + int i; + + /* Perform 'fine' peak search */ + search_peaks(image, dump_peaks); + + /* Map positions to 3D. FIXME: Handle lower detector */ + for ( i=0; i<image_feature_count(image->features); i++ ) { + + struct imagefeature *f; + + f = image_get_feature(image->features, i); + map_position(image, f->x, f->y, &f->rx, &f->ry, &f->rz); + + } + + if ( use_dirax ) { + run_dirax(image, no_index); + return; + } +} |