aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-03-28 13:34:43 +0200
committerThomas White <taw@bitwiz.org.uk>2010-03-28 13:34:43 +0200
commitfede813224e32f690ba22c7f0a1f22d05b1de8a3 (patch)
tree95c50578e901d9cd3c4813828281db7ae28b23a7
parentf15dc3d8b88c7a4a7054309fbcd5756de8a7fc0b (diff)
Move contents of intensities.{c,h} to peaks.{c,h}
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rw-r--r--src/Makefile.am7
-rw-r--r--src/Makefile.in28
-rw-r--r--src/indexamajig.c1
-rw-r--r--src/intensities.c149
-rw-r--r--src/intensities.h24
-rw-r--r--src/pattern_sim.c2
-rw-r--r--src/peaks.c127
-rw-r--r--src/peaks.h1
10 files changed, 147 insertions, 196 deletions
diff --git a/Makefile.am b/Makefile.am
index 22f39ce1..cca1fbe9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h src/relrod.h \
src/utils.h src/diffraction.h src/detector.h src/ewald.h \
- src/sfac.h src/intensities.h src/reflections.h src/list_tmp.h \
+ src/sfac.h src/reflections.h src/list_tmp.h \
src/statistics.h src/displaywindow.h src/render.h src/hdfsee.h \
data/displaywindow.ui src/dirax.h src/peaks.h src/index.h \
src/filters.h src/diffraction-gpu.h src/cl-utils.h
diff --git a/Makefile.in b/Makefile.in
index 2244ddbf..47bcef1a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -197,7 +197,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h src/relrod.h \
src/utils.h src/diffraction.h src/detector.h src/ewald.h \
- src/sfac.h src/intensities.h src/reflections.h src/list_tmp.h \
+ src/sfac.h src/reflections.h src/list_tmp.h \
src/statistics.h src/displaywindow.h src/render.h src/hdfsee.h \
data/displaywindow.ui src/dirax.h src/peaks.h src/index.h \
src/filters.h src/diffraction-gpu.h src/cl-utils.h
diff --git a/src/Makefile.am b/src/Makefile.am
index ef9338c5..4041e1e2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,8 +9,7 @@ AM_CFLAGS = -Wall
AM_CPPFLAGS = -DDATADIR=\""$(datadir)"\"
pattern_sim_SOURCES = pattern_sim.c diffraction.c utils.c image.c cell.c \
- hdf5-file.c detector.c sfac.c intensities.c \
- reflections.c
+ hdf5-file.c detector.c sfac.c peaks.c reflections.c
if HAVE_OPENCL
pattern_sim_SOURCES += diffraction-gpu.c cl-utils.c
endif
@@ -22,8 +21,8 @@ process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \
process_hkl_LDADD = @LIBS@
indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \
- intensities.c peaks.c index.c filters.c \
- diffraction.c detector.c sfac.c dirax.c reflections.c
+ peaks.c index.c filters.c diffraction.c detector.c \
+ sfac.c dirax.c reflections.c
indexamajig_LDADD = @LIBS@
if HAVE_OPENCL
indexamajig_SOURCES += diffraction-gpu.c cl-utils.c
diff --git a/src/Makefile.in b/src/Makefile.in
index 4b59a13d..1d7547a0 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -68,26 +68,25 @@ am__hdfsee_SOURCES_DIST = hdfsee.c displaywindow.c render.c \
hdfsee_OBJECTS = $(am_hdfsee_OBJECTS)
hdfsee_DEPENDENCIES =
am__indexamajig_SOURCES_DIST = indexamajig.c hdf5-file.c utils.c \
- cell.c image.c intensities.c peaks.c index.c filters.c \
- diffraction.c detector.c sfac.c dirax.c reflections.c \
- diffraction-gpu.c cl-utils.c
+ cell.c image.c peaks.c index.c filters.c diffraction.c \
+ detector.c sfac.c dirax.c reflections.c diffraction-gpu.c \
+ cl-utils.c
@HAVE_OPENCL_TRUE@am__objects_1 = diffraction-gpu.$(OBJEXT) \
@HAVE_OPENCL_TRUE@ cl-utils.$(OBJEXT)
am_indexamajig_OBJECTS = indexamajig.$(OBJEXT) hdf5-file.$(OBJEXT) \
- utils.$(OBJEXT) cell.$(OBJEXT) image.$(OBJEXT) \
- intensities.$(OBJEXT) peaks.$(OBJEXT) index.$(OBJEXT) \
- filters.$(OBJEXT) diffraction.$(OBJEXT) detector.$(OBJEXT) \
- sfac.$(OBJEXT) dirax.$(OBJEXT) reflections.$(OBJEXT) \
- $(am__objects_1)
+ utils.$(OBJEXT) cell.$(OBJEXT) image.$(OBJEXT) peaks.$(OBJEXT) \
+ index.$(OBJEXT) filters.$(OBJEXT) diffraction.$(OBJEXT) \
+ detector.$(OBJEXT) sfac.$(OBJEXT) dirax.$(OBJEXT) \
+ reflections.$(OBJEXT) $(am__objects_1)
indexamajig_OBJECTS = $(am_indexamajig_OBJECTS)
indexamajig_DEPENDENCIES =
am__pattern_sim_SOURCES_DIST = pattern_sim.c diffraction.c utils.c \
- image.c cell.c hdf5-file.c detector.c sfac.c intensities.c \
+ image.c cell.c hdf5-file.c detector.c sfac.c peaks.c \
reflections.c diffraction-gpu.c cl-utils.c
am_pattern_sim_OBJECTS = pattern_sim.$(OBJEXT) diffraction.$(OBJEXT) \
utils.$(OBJEXT) image.$(OBJEXT) cell.$(OBJEXT) \
hdf5-file.$(OBJEXT) detector.$(OBJEXT) sfac.$(OBJEXT) \
- intensities.$(OBJEXT) reflections.$(OBJEXT) $(am__objects_1)
+ peaks.$(OBJEXT) reflections.$(OBJEXT) $(am__objects_1)
pattern_sim_OBJECTS = $(am_pattern_sim_OBJECTS)
pattern_sim_DEPENDENCIES =
am_powder_plot_OBJECTS = powder_plot.$(OBJEXT) cell.$(OBJEXT) \
@@ -223,16 +222,16 @@ top_srcdir = @top_srcdir@
AM_CFLAGS = -Wall
AM_CPPFLAGS = -DDATADIR=\""$(datadir)"\"
pattern_sim_SOURCES = pattern_sim.c diffraction.c utils.c image.c \
- cell.c hdf5-file.c detector.c sfac.c intensities.c \
- reflections.c $(am__append_2)
+ cell.c hdf5-file.c detector.c sfac.c peaks.c reflections.c \
+ $(am__append_2)
pattern_sim_LDADD = @LIBS@
process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \
reflections.c
process_hkl_LDADD = @LIBS@
indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \
- intensities.c peaks.c index.c filters.c diffraction.c \
- detector.c sfac.c dirax.c reflections.c $(am__append_3)
+ peaks.c index.c filters.c diffraction.c detector.c sfac.c \
+ dirax.c reflections.c $(am__append_3)
indexamajig_LDADD = @LIBS@
@HAVE_GTK_TRUE@hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \
@HAVE_GTK_TRUE@ filters.c
@@ -361,7 +360,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/image.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/index.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indexamajig.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intensities.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pattern_sim.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peaks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/powder_plot.Po@am__quote@
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 1ffae789..03711d56 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -25,7 +25,6 @@
#include "utils.h"
#include "hdf5-file.h"
#include "index.h"
-#include "intensities.h"
#include "peaks.h"
#include "diffraction.h"
#include "diffraction-gpu.h"
diff --git a/src/intensities.c b/src/intensities.c
deleted file mode 100644
index b0eef542..00000000
--- a/src/intensities.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * intensities.c
- *
- * Extract intensities from patterns
- *
- * (c) 2006-2010 Thomas White <taw@physics.org>
- *
- * Part of CrystFEL - crystallography with a FEL
- *
- */
-
-
-#include <stdlib.h>
-#include <math.h>
-#include <stdio.h>
-#include <assert.h>
-
-#include "image.h"
-#include "intensities.h"
-#include "cell.h"
-#include "sfac.h"
-#include "diffraction.h"
-
-
-#define MAX_HITS (1024)
-
-
-struct reflhit {
- signed int h;
- signed int k;
- signed int l;
- double min_distance;
- int x;
- int y;
-};
-
-
-static double sum_nearby_points(float *data, int width, int x, int y)
-{
- int dx, dy;
- double intensity = 0;
-
- for ( dx=-3; dx<=3; dx++ ) {
- for ( dy=-3; dy<=3; dy++ ) {
- intensity += data[(x+dx) + width*(y+dy)];
- }
- }
-
- return intensity;
-}
-
-
-void output_intensities(struct image *image, UnitCell *cell)
-{
- int x, y;
- double ax, ay, az;
- double bx, by, bz;
- double cx, cy, cz;
- struct reflhit hits[MAX_HITS];
- int n_hits = 0;
- int i;
-
- cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
-
- for ( x=0; x<image->width; x++ ) {
- for ( y=0; y<image->height; y++ ) {
-
- double hd, kd, ld; /* Indices with decimal places */
- double dh, dk, dl; /* Distances in h,k,l directions */
- signed int h, k, l;
- struct rvec q;
- double dist;
- int found = 0;
- int j;
-
- q = get_q(image, x, y, 1, NULL, 1.0/image->lambda);
-
- hd = q.u * ax + q.v * ay + q.w * az;
- kd = q.u * bx + q.v * by + q.w * bz;
- ld = q.u * cx + q.v * cy + q.w * cz;
-
- h = (signed int)rint(hd);
- k = (signed int)rint(kd);
- l = (signed int)rint(ld);
-
- dh = hd - h;
- dk = kd - k;
- dl = ld - l;
- dist = sqrt(pow(dh, 2.0) + pow(dk, 2.0) + pow(dl, 2.0));
- if ( dist > 0.1 ) continue;
-
- for ( j=0; j<n_hits; j++ ) {
- if ( (hits[j].h == h) && (hits[j].k == k)
- && (hits[j].l == l) ) {
-
- if ( dist < hits[j].min_distance ) {
- hits[j].min_distance = dist;
- hits[j].x = x;
- hits[j].y = y;
- }
-
- found = 1;
-
- }
- }
-
- if ( !found ) {
- hits[n_hits].min_distance = dist;
- hits[n_hits].x = x;
- hits[n_hits].y = y;
- hits[n_hits].h = h;
- hits[n_hits].k = k;
- hits[n_hits].l = l;
- n_hits++;
- assert(n_hits < MAX_HITS);
- }
-
- }
- }
-
- STATUS("Found %i reflections\n", n_hits);
-
- /* Explicit printf() used here (not normally allowed) because
- * we really want to output to stdout */
- printf("New pattern: %7.5f %7.5f %7.5f %7.5f\n",
- image->orientation.w, image->orientation.x,
- image->orientation.y, image->orientation.z);
- for ( i=0; i<n_hits; i++ ) {
-
- double intensity;
-
- /* Bounds check */
- if ( hits[i].x + 3 >= image->width ) continue;
- if ( hits[i].x - 3 < 0 ) continue;
- if ( hits[i].y + 3 >= image->height ) continue;
- if ( hits[i].y - 3 < 0 ) continue;
-
- intensity = sum_nearby_points(image->data, image->width,
- hits[i].x, hits[i].y);
-
- printf("%3i %3i %3i %6f (at %i,%i)\n",
- hits[i].h, hits[i].k, hits[i].l, intensity,
- hits[i].x, hits[i].y);
-
- }
-
- /* Blank line at end */
- printf("\n");
-}
diff --git a/src/intensities.h b/src/intensities.h
deleted file mode 100644
index 10664ab2..00000000
--- a/src/intensities.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * intensities.h
- *
- * Extract intensities from patterns
- *
- * (c) 2006-2010 Thomas White <taw@physics.org>
- *
- * Part of CrystFEL - crystallography with a FEL
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef INTENSITIES_H
-#define INTENSITIES_H
-
-#include "image.h"
-#include "cell.h"
-
-extern void output_intensities(struct image *image, UnitCell *cell);
-
-#endif /* INTENSITIES_H */
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 3593e4b4..0e8c60e2 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -28,7 +28,7 @@
#include "utils.h"
#include "hdf5-file.h"
#include "detector.h"
-#include "intensities.h"
+#include "peaks.h"
#include "sfac.h"
#include "reflections.h"
diff --git a/src/peaks.c b/src/peaks.c
index d146ce24..a76ed78f 100644
--- a/src/peaks.c
+++ b/src/peaks.c
@@ -27,6 +27,19 @@
#include "peaks.h"
#include "detector.h"
#include "filters.h"
+#include "diffraction.h"
+
+
+#define MAX_HITS (1024)
+
+struct reflhit {
+ signed int h;
+ signed int k;
+ signed int l;
+ double min_distance;
+ int x;
+ int y;
+};
#define PEAK_WINDOW_SIZE (10)
@@ -461,3 +474,117 @@ void dump_peaks(struct image *image)
}
}
+
+
+static double sum_nearby_points(float *data, int width, int x, int y)
+{
+ int dx, dy;
+ double intensity = 0;
+
+ for ( dx=-3; dx<=3; dx++ ) {
+ for ( dy=-3; dy<=3; dy++ ) {
+ intensity += data[(x+dx) + width*(y+dy)];
+ }
+ }
+
+ return intensity;
+}
+
+
+void output_intensities(struct image *image, UnitCell *cell)
+{
+ int x, y;
+ double ax, ay, az;
+ double bx, by, bz;
+ double cx, cy, cz;
+ struct reflhit hits[MAX_HITS];
+ int n_hits = 0;
+ int i;
+
+ cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
+
+ for ( x=0; x<image->width; x++ ) {
+ for ( y=0; y<image->height; y++ ) {
+
+ double hd, kd, ld; /* Indices with decimal places */
+ double dh, dk, dl; /* Distances in h,k,l directions */
+ signed int h, k, l;
+ struct rvec q;
+ double dist;
+ int found = 0;
+ int j;
+
+ q = get_q(image, x, y, 1, NULL, 1.0/image->lambda);
+
+ hd = q.u * ax + q.v * ay + q.w * az;
+ kd = q.u * bx + q.v * by + q.w * bz;
+ ld = q.u * cx + q.v * cy + q.w * cz;
+
+ h = (signed int)rint(hd);
+ k = (signed int)rint(kd);
+ l = (signed int)rint(ld);
+
+ dh = hd - h;
+ dk = kd - k;
+ dl = ld - l;
+ dist = sqrt(pow(dh, 2.0) + pow(dk, 2.0) + pow(dl, 2.0));
+ if ( dist > 0.1 ) continue;
+
+ for ( j=0; j<n_hits; j++ ) {
+ if ( (hits[j].h == h) && (hits[j].k == k)
+ && (hits[j].l == l) ) {
+
+ if ( dist < hits[j].min_distance ) {
+ hits[j].min_distance = dist;
+ hits[j].x = x;
+ hits[j].y = y;
+ }
+
+ found = 1;
+
+ }
+ }
+
+ if ( !found ) {
+ hits[n_hits].min_distance = dist;
+ hits[n_hits].x = x;
+ hits[n_hits].y = y;
+ hits[n_hits].h = h;
+ hits[n_hits].k = k;
+ hits[n_hits].l = l;
+ n_hits++;
+ assert(n_hits < MAX_HITS);
+ }
+
+ }
+ }
+
+ STATUS("Found %i reflections\n", n_hits);
+
+ /* Explicit printf() used here (not normally allowed) because
+ * we really want to output to stdout */
+ printf("New pattern: %7.5f %7.5f %7.5f %7.5f\n",
+ image->orientation.w, image->orientation.x,
+ image->orientation.y, image->orientation.z);
+ for ( i=0; i<n_hits; i++ ) {
+
+ double intensity;
+
+ /* Bounds check */
+ if ( hits[i].x + 3 >= image->width ) continue;
+ if ( hits[i].x - 3 < 0 ) continue;
+ if ( hits[i].y + 3 >= image->height ) continue;
+ if ( hits[i].y - 3 < 0 ) continue;
+
+ intensity = sum_nearby_points(image->data, image->width,
+ hits[i].x, hits[i].y);
+
+ printf("%3i %3i %3i %6f (at %i,%i)\n",
+ hits[i].h, hits[i].k, hits[i].l, intensity,
+ hits[i].x, hits[i].y);
+
+ }
+
+ /* Blank line at end */
+ printf("\n");
+}
diff --git a/src/peaks.h b/src/peaks.h
index 2e868342..ba85f0f5 100644
--- a/src/peaks.h
+++ b/src/peaks.h
@@ -21,5 +21,6 @@
extern int image_fom(struct image *image);
extern void search_peaks(struct image *image);
extern void dump_peaks(struct image *image);
+extern void output_intensities(struct image *image, UnitCell *cell);
#endif /* PEAKS_H */