Commit fede8132 authored by Thomas White's avatar Thomas White
Browse files

Move contents of intensities.{c,h} to peaks.{c,h}

parent f15dc3d8
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
......
......@@ -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
......
......@@ -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
......
......@@ -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@
......
......@@ -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"
......
/*
* 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");
}
/*
* 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 */
......@@ -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"
......
......@@ -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");
}
......@@ -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 */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment