diff options
author | Thomas White <taw@physics.org> | 2010-09-29 17:37:49 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:00 +0100 |
commit | 0da8b0efa29a1d581a15ffacafec5e1e5dec76ea (patch) | |
tree | ee465c0fe0710520882a16fe6328c12a12e22380 /src | |
parent | fb8fc1fab3792488e5f3ab0e2ef9ed89189c47d9 (diff) |
Move get_q() and get_tt() to detector.c
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 14 | ||||
-rw-r--r-- | src/Makefile.in | 31 | ||||
-rw-r--r-- | src/detector.c | 54 | ||||
-rw-r--r-- | src/detector.h | 5 | ||||
-rw-r--r-- | src/diffraction.c | 53 | ||||
-rw-r--r-- | src/diffraction.h | 4 |
6 files changed, 78 insertions, 83 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e147b78e..721c80f1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,22 +53,20 @@ render_hkl_SOURCES = render_hkl.c cell.c reflections.c utils.c povray.c \ render_hkl_LDADD = @LIBS@ calibrate_detector_SOURCES = calibrate_detector.c utils.c hdf5-file.c image.c \ - filters.c peaks.c detector.c cell.c diffraction.c \ - sfac.c + filters.c peaks.c detector.c cell.c calibrate_detector_LDADD = @LIBS@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \ - image.c diffraction.c sfac.c geometry.c reflections.c \ - stream.c + image.c geometry.c reflections.c stream.c facetron_LDADD = @LIBS@ -cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c diffraction.c \ - sfac.c render.c filters.c image.c symmetry.c stream.c +cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \ + filters.c image.c symmetry.c stream.c cubeit_LDADD = @LIBS@ reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \ - peaks.c image.c diffraction.c sfac.c geometry.c stream.c \ - index.c dirax.c templates.c symmetry.c + peaks.c image.c stream.c \ + index.c dirax.c templates.c geometry.c symmetry.c reintegrate_LDADD = @LIBS@ INCLUDES = "-I$(top_srcdir)/data" diff --git a/src/Makefile.in b/src/Makefile.in index 61fe86ac..348e112f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -56,7 +56,7 @@ PROGRAMS = $(bin_PROGRAMS) am_calibrate_detector_OBJECTS = calibrate_detector.$(OBJEXT) \ utils.$(OBJEXT) hdf5-file.$(OBJEXT) image.$(OBJEXT) \ filters.$(OBJEXT) peaks.$(OBJEXT) detector.$(OBJEXT) \ - cell.$(OBJEXT) diffraction.$(OBJEXT) sfac.$(OBJEXT) + cell.$(OBJEXT) calibrate_detector_OBJECTS = $(am_calibrate_detector_OBJECTS) calibrate_detector_DEPENDENCIES = am_compare_hkl_OBJECTS = compare_hkl.$(OBJEXT) sfac.$(OBJEXT) \ @@ -66,16 +66,14 @@ compare_hkl_OBJECTS = $(am_compare_hkl_OBJECTS) compare_hkl_DEPENDENCIES = am_cubeit_OBJECTS = cubeit.$(OBJEXT) cell.$(OBJEXT) \ hdf5-file.$(OBJEXT) utils.$(OBJEXT) detector.$(OBJEXT) \ - diffraction.$(OBJEXT) sfac.$(OBJEXT) render.$(OBJEXT) \ - filters.$(OBJEXT) image.$(OBJEXT) symmetry.$(OBJEXT) \ - stream.$(OBJEXT) + render.$(OBJEXT) filters.$(OBJEXT) image.$(OBJEXT) \ + symmetry.$(OBJEXT) stream.$(OBJEXT) cubeit_OBJECTS = $(am_cubeit_OBJECTS) cubeit_DEPENDENCIES = am_facetron_OBJECTS = facetron.$(OBJEXT) cell.$(OBJEXT) \ hdf5-file.$(OBJEXT) utils.$(OBJEXT) detector.$(OBJEXT) \ - peaks.$(OBJEXT) image.$(OBJEXT) diffraction.$(OBJEXT) \ - sfac.$(OBJEXT) geometry.$(OBJEXT) reflections.$(OBJEXT) \ - stream.$(OBJEXT) + peaks.$(OBJEXT) image.$(OBJEXT) geometry.$(OBJEXT) \ + reflections.$(OBJEXT) stream.$(OBJEXT) facetron_OBJECTS = $(am_facetron_OBJECTS) facetron_DEPENDENCIES = am_get_hkl_OBJECTS = get_hkl.$(OBJEXT) sfac.$(OBJEXT) cell.$(OBJEXT) \ @@ -125,10 +123,9 @@ process_hkl_OBJECTS = $(am_process_hkl_OBJECTS) process_hkl_DEPENDENCIES = am_reintegrate_OBJECTS = reintegrate.$(OBJEXT) cell.$(OBJEXT) \ hdf5-file.$(OBJEXT) utils.$(OBJEXT) detector.$(OBJEXT) \ - peaks.$(OBJEXT) image.$(OBJEXT) diffraction.$(OBJEXT) \ - sfac.$(OBJEXT) geometry.$(OBJEXT) stream.$(OBJEXT) \ + peaks.$(OBJEXT) image.$(OBJEXT) stream.$(OBJEXT) \ index.$(OBJEXT) dirax.$(OBJEXT) templates.$(OBJEXT) \ - symmetry.$(OBJEXT) + geometry.$(OBJEXT) symmetry.$(OBJEXT) reintegrate_OBJECTS = $(am_reintegrate_OBJECTS) reintegrate_DEPENDENCIES = am_render_hkl_OBJECTS = render_hkl.$(OBJEXT) cell.$(OBJEXT) \ @@ -296,22 +293,20 @@ render_hkl_SOURCES = render_hkl.c cell.c reflections.c utils.c povray.c \ render_hkl_LDADD = @LIBS@ calibrate_detector_SOURCES = calibrate_detector.c utils.c hdf5-file.c image.c \ - filters.c peaks.c detector.c cell.c diffraction.c \ - sfac.c + filters.c peaks.c detector.c cell.c calibrate_detector_LDADD = @LIBS@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \ - image.c diffraction.c sfac.c geometry.c reflections.c \ - stream.c + image.c geometry.c reflections.c stream.c facetron_LDADD = @LIBS@ -cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c diffraction.c \ - sfac.c render.c filters.c image.c symmetry.c stream.c +cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \ + filters.c image.c symmetry.c stream.c cubeit_LDADD = @LIBS@ reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \ - peaks.c image.c diffraction.c sfac.c geometry.c stream.c \ - index.c dirax.c templates.c symmetry.c + peaks.c image.c stream.c \ + index.c dirax.c templates.c geometry.c symmetry.c reintegrate_LDADD = @LIBS@ INCLUDES = "-I$(top_srcdir)/data" diff --git a/src/detector.c b/src/detector.c index ce5aa82e..e4c5a83e 100644 --- a/src/detector.c +++ b/src/detector.c @@ -14,6 +14,7 @@ #include <math.h> #include <stdio.h> #include <string.h> +#include <assert.h> #include "image.h" #include "utils.h" @@ -30,6 +31,59 @@ int atob(const char *a) } +struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, + unsigned int sampling, float *ttp, float k) +{ + struct rvec q; + float twotheta, r, az; + float rx; + float ry; + struct panel *p; + + const unsigned int x = xs / sampling; + const unsigned int y = ys / sampling; /* Integer part only */ + + p = find_panel(image->det, x, y); + assert(p != NULL); + + rx = ((float)xs - (sampling*p->cx)) / (sampling * p->res); + ry = ((float)ys - (sampling*p->cy)) / (sampling * p->res); + + /* Calculate q-vector for this sub-pixel */ + r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); + + twotheta = atan2(r, p->clen); + az = atan2(ry, rx); + if ( ttp != NULL ) *ttp = twotheta; + + q.u = k * sin(twotheta)*cos(az); + q.v = k * sin(twotheta)*sin(az); + q.w = k - k * cos(twotheta); + + return quat_rot(q, image->orientation); +} + + +double get_tt(struct image *image, unsigned int xs, unsigned int ys) +{ + float r, rx, ry; + struct panel *p; + + const unsigned int x = xs; + const unsigned int y = ys; /* Integer part only */ + + p = find_panel(image->det, x, y); + + rx = ((float)xs - p->cx) / p->res; + ry = ((float)ys - p->cy) / p->res; + + /* Calculate q-vector for this sub-pixel */ + r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); + + return atan2(r, p->clen); +} + + /* x,y in pixels relative to image origin */ int map_position(struct image *image, double dx, double dy, double *rx, double *ry, double *rz) diff --git a/src/detector.h b/src/detector.h index 128332fd..df40d05b 100644 --- a/src/detector.h +++ b/src/detector.h @@ -45,6 +45,11 @@ struct detector extern int map_position(struct image *image, double x, double y, double *rx, double *ry, double *rz); +extern struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, + unsigned int sampling, float *ttp, float k); + +extern double get_tt(struct image *image, unsigned int xs, unsigned int ys); + extern void record_image(struct image *image, int do_poisson); extern struct panel *find_panel(struct detector *det, int x, int y); diff --git a/src/diffraction.c b/src/diffraction.c index efc56231..5ffe94a8 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -294,59 +294,6 @@ double water_diffraction(struct rvec q, double en, } -struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, - unsigned int sampling, float *ttp, float k) -{ - struct rvec q; - float twotheta, r, az; - float rx; - float ry; - struct panel *p; - - const unsigned int x = xs / sampling; - const unsigned int y = ys / sampling; /* Integer part only */ - - p = find_panel(image->det, x, y); - assert(p != NULL); - - rx = ((float)xs - (sampling*p->cx)) / (sampling * p->res); - ry = ((float)ys - (sampling*p->cy)) / (sampling * p->res); - - /* Calculate q-vector for this sub-pixel */ - r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); - - twotheta = atan2(r, p->clen); - az = atan2(ry, rx); - if ( ttp != NULL ) *ttp = twotheta; - - q.u = k * sin(twotheta)*cos(az); - q.v = k * sin(twotheta)*sin(az); - q.w = k - k * cos(twotheta); - - return quat_rot(q, image->orientation); -} - - -double get_tt(struct image *image, unsigned int xs, unsigned int ys) -{ - float r, rx, ry; - struct panel *p; - - const unsigned int x = xs; - const unsigned int y = ys; /* Integer part only */ - - p = find_panel(image->det, x, y); - - rx = ((float)xs - p->cx) / p->res; - ry = ((float)ys - p->cy) / p->res; - - /* Calculate q-vector for this sub-pixel */ - r = sqrt(pow(rx, 2.0) + pow(ry, 2.0)); - - return atan2(r, p->clen); -} - - void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities, const double *phases, UnitCell *cell, int do_water, GradientMethod m) diff --git a/src/diffraction.h b/src/diffraction.h index ffe3a19d..5a88bff7 100644 --- a/src/diffraction.h +++ b/src/diffraction.h @@ -28,9 +28,5 @@ typedef enum { extern void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities,const double *phases, UnitCell *cell, int do_water, GradientMethod m); -extern struct rvec get_q(struct image *image, unsigned int xs, unsigned int ys, - unsigned int sampling, float *ttp, float k); - -extern double get_tt(struct image *image, unsigned int xs, unsigned int ys); #endif /* DIFFRACTION_H */ |