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

Introduce "libcrystfel"

parent 404c6122
......@@ -10,8 +10,16 @@ config.h
config.log
config.status
stamp-h1
libcrystfel/libcrystfel.la
libcrystfel/src/*.o
libcrystfel/src/*.lo
libcrystfel/src/.dirstamp
libcrystfel/src/*.deps
libcrystfel/*.libs
libcrystfel/src/*.libs
src/*.o
src/.deps
src/.libs
src/pattern_sim
src/process_hkl
src/get_hkl
......@@ -28,8 +36,3 @@ src/partial_sim
src/.dirstamp
*~
doc/reference/*
contrib/.deps
contrib/*.o
contrib/.dirstamp
contrib/alter_stream
contrib/cubeit
EXTRA_DIST = configure m4/gnulib-cache.m4
SUBDIRS = lib doc/reference
SUBDIRS = lib doc/reference libcrystfel
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = src/pattern_sim src/process_hkl src/get_hkl src/indexamajig \
src/compare_hkl src/powder_plot src/render_hkl \
src/calibrate_detector src/partialator \
src/check_hkl src/sum_stack src/partial_sim \
contrib/alter_stream
src/check_hkl src/sum_stack src/partial_sim
noinst_PROGRAMS = tests/list_check tests/integration_check \
tests/pr_gradient_check tests/symmetry_check
......@@ -25,149 +24,89 @@ if BUILD_HDFSEE
bin_PROGRAMS += src/hdfsee
endif
if BUILD_CUBEIT
bin_PROGRAMS += contrib/cubeit
endif
AM_CFLAGS = -Wall
AM_CPPFLAGS = -DDATADIR=\""$(datadir)"\" -I$(top_builddir)/lib
AM_CPPFLAGS += -I$(top_srcdir)/lib
LDADD = $(top_builddir)/lib/libgnu.a @IGNORE_UNUSED_LIBRARIES_CFLAGS@
LDADD += $(top_builddir)/libcrystfel/libcrystfel.la
src_partial_sim_SOURCES = src/partial_sim.c src/cell.c src/detector.c \
src/beam-parameters.c src/thread-pool.c src/utils.c \
src/reflist-utils.c src/reflist.c src/symmetry.c \
src/hdf5-file.c src/image.c src/geometry.c \
src/peaks.c src/stream.c
src_pattern_sim_SOURCES = src/pattern_sim.c src/diffraction.c src/utils.c \
src/image.c src/cell.c src/hdf5-file.c \
src/detector.c src/peaks.c \
src/reflist-utils.c src/beam-parameters.c \
src/symmetry.c src/thread-pool.c src/reflist.c
src_partial_sim_SOURCES = src/partial_sim.c src/reflist-utils.c src/symmetry.c \
src/geometry.c src/peaks.c src/stream.c
src_pattern_sim_SOURCES = src/pattern_sim.c src/diffraction.c src/peaks.c \
src/reflist-utils.c src/symmetry.c
if HAVE_OPENCL
src_pattern_sim_SOURCES += src/diffraction-gpu.c src/cl-utils.c
TESTS += tests/gpu_sim_check
noinst_PROGRAMS += tests/gpu_sim_check
tests_gpu_sim_check_SOURCES = tests/gpu_sim_check.c src/utils.c \
src/diffraction.c src/diffraction-gpu.c \
src/thread-pool.c src/cell.c src/cl-utils.c \
src/symmetry.c src/detector.c src/hdf5-file.c \
src/image.c
tests_gpu_sim_check_SOURCES = tests/gpu_sim_check.c src/diffraction.c \
src/diffraction-gpu.c src/cl-utils.c \
src/symmetry.c
endif
src_process_hkl_SOURCES = src/process_hkl.c src/statistics.c \
src/cell.c src/utils.c \
src/symmetry.c src/stream.c src/beam-parameters.c \
src/thread-pool.c src/image.c src/detector.c \
src/hdf5-file.c src/reflist.c src/reflist-utils.c
src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c src/utils.c \
src/cell.c src/image.c src/peaks.c src/index.c \
src/filters.c src/diffraction.c src/detector.c \
src/dirax.c src/mosflm.c \
src/reflist-utils.c src/symmetry.c \
src/geometry.c src/thread-pool.c \
src/beam-parameters.c src/reflist.c src/stream.c \
src/reax.c
if HAVE_OPENCL
src_indexamajig_SOURCES += src/diffraction-gpu.c src/cl-utils.c
endif
src_process_hkl_SOURCES = src/process_hkl.c src/statistics.c src/symmetry.c \
src/stream.c src/reflist-utils.c
src_indexamajig_SOURCES = src/indexamajig.c src/peaks.c src/index.c \
src/filters.c src/diffraction.c src/dirax.c \
src/mosflm.c src/reflist-utils.c src/symmetry.c \
src/geometry.c src/stream.c src/reax.c
if BUILD_HDFSEE
src_hdfsee_SOURCES = src/hdfsee.c src/dw-hdfsee.c src/render.c \
src/hdf5-file.c src/utils.c src/image.c src/filters.c \
src/thread-pool.c src/detector.c
src_hdfsee_SOURCES = src/hdfsee.c src/dw-hdfsee.c src/render.c src/filters.c
endif
src_get_hkl_SOURCES = src/get_hkl.c src/cell.c src/utils.c \
src/reflist-utils.c src/symmetry.c src/beam-parameters.c \
src/thread-pool.c src/reflist.c
src_compare_hkl_SOURCES = src/compare_hkl.c src/cell.c src/utils.c \
src/reflist-utils.c src/statistics.c src/symmetry.c \
src/thread-pool.c src/reflist.c
src_check_hkl_SOURCES = src/check_hkl.c src/cell.c src/utils.c \
src/reflist-utils.c src/statistics.c src/symmetry.c \
src/thread-pool.c src/reflist.c
src_powder_plot_SOURCES = src/powder_plot.c src/cell.c src/utils.c src/image.c \
src/hdf5-file.c src/detector.c src/thread-pool.c \
src/reflist-utils.c src/beam-parameters.c src/stream.c \
src/reflist.c src/symmetry.c
src_render_hkl_SOURCES = src/render_hkl.c src/cell.c src/reflist-utils.c \
src/utils.c src/povray.c src/symmetry.c src/render.c \
src/hdf5-file.c src/image.c src/filters.c \
src/thread-pool.c src/reflist.c src/detector.c
src_sum_stack_SOURCES = src/sum_stack.c src/utils.c src/hdf5-file.c \
src/image.c src/filters.c src/peaks.c src/detector.c \
src/cell.c src/thread-pool.c src/reflist.c
src_calibrate_detector_SOURCES = src/calibrate_detector.c src/utils.c \
src/hdf5-file.c src/image.c src/thread-pool.c \
src/detector.c src/stream.c src/cell.c \
src/reflist-utils.c src/reflist.c \
src/symmetry.c src/peaks.c
src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
src/utils.c src/detector.c src/peaks.c src/image.c \
src/geometry.c src/reflist-utils.c src/stream.c \
src/thread-pool.c src/beam-parameters.c \
src/symmetry.c src/post-refinement.c \
src/hrs-scaling.c src/reflist.c
src_get_hkl_SOURCES = src/get_hkl.c src/reflist-utils.c src/symmetry.c
src_compare_hkl_SOURCES = src/compare_hkl.c src/reflist-utils.c \
src/statistics.c src/symmetry.c
src_check_hkl_SOURCES = src/check_hkl.c src/reflist-utils.c src/statistics.c \
src/symmetry.c
src_powder_plot_SOURCES = src/powder_plot.c src/reflist-utils.c src/stream.c \
src/symmetry.c
src_render_hkl_SOURCES = src/render_hkl.c src/reflist-utils.c src/povray.c \
src/symmetry.c src/render.c src/filters.c
src_sum_stack_SOURCES = src/sum_stack.c src/filters.c src/peaks.c
src_calibrate_detector_SOURCES = src/calibrate_detector.c src/stream.c \
src/reflist-utils.c src/symmetry.c \
src/peaks.c
src_partialator_SOURCES = src/partialator.c src/peaks.c src/geometry.c \
src/reflist-utils.c src/stream.c \
src/symmetry.c \
src/post-refinement.c src/hrs-scaling.c
if HAVE_CAIRO
src_partialator_SOURCES += src/scaling-report.c
endif
if BUILD_CUBEIT
contrib_cubeit_SOURCES = contrib/cubeit.c src/cell.c src/hdf5-file.c \
src/utils.c src/detector.c src/render.c src/filters.c \
src/image.c src/symmetry.c src/stream.c src/thread-pool.c \
src/reflist.c src/reflist-utils.c
endif
contrib_alter_stream_SOURCES = contrib/alter_stream.c src/stream.c src/image.c \
src/thread-pool.c src/detector.c src/utils.c \
src/cell.c src/reflist-utils.c src/reflist.c \
src/symmetry.c src/hdf5-file.c \
src/beam-parameters.c src/geometry.c src/peaks.c
tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \
src/utils.c
tests_list_check_SOURCES = tests/list_check.c
tests_integration_check_SOURCES = tests/integration_check.c src/peaks.c \
src/reflist.c src/cell.c src/detector.c \
src/thread-pool.c src/utils.c src/image.c \
src/hdf5-file.c
tests_integration_check_SOURCES = tests/integration_check.c src/peaks.c
tests_symmetry_check_SOURCES = tests/symmetry_check.c src/symmetry.c \
src/utils.c src/thread-pool.c
tests_symmetry_check_SOURCES = tests/symmetry_check.c src/symmetry.c
tests_pr_gradient_check_SOURCES = tests/pr_gradient_check.c src/detector.c \
src/cell.c src/geometry.c src/reflist.c \
src/thread-pool.c src/utils.c src/peaks.c \
src/symmetry.c src/image.c src/hdf5-file.c \
src/post-refinement.c
tests_pr_gradient_check_SOURCES = tests/pr_gradient_check.c src/peaks.c \
src/symmetry.c src/post-refinement.c \
src/geometry.c
INCLUDES = "-I$(top_srcdir)/data"
INCLUDES = -I$(top_srcdir)/libcrystfel/src -I$(top_srcdir)/data
EXTRA_DIST += src/cell.h src/hdf5-file.h src/image.h src/utils.h \
src/diffraction.h src/detector.h src/reflist-utils.h \
src/list_tmp.h src/statistics.h src/dw-hdfsee.h \
EXTRA_DIST += src/diffraction.h src/reflist-utils.h \
src/statistics.h src/dw-hdfsee.h \
src/render.h src/hdfsee.h src/dirax.h src/mosflm.h src/peaks.h \
src/index.h src/filters.h src/diffraction-gpu.h src/cl-utils.h \
src/symmetry.h src/povray.h src/index-priv.h src/geometry.h \
src/render_hkl.h src/stream.h src/thread-pool.h \
src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h \
src/render_hkl.h src/stream.h \
src/post-refinement.h src/hrs-scaling.h \
src/reflist.h src/scaling-report.h src/reax.h
crystfeldir = $(datadir)/crystfel
......
This diff is collapsed.
......@@ -1385,6 +1385,11 @@ m4_include([m4/gnulib-comp.m4])
m4_include([m4/gtk-doc.m4])
m4_include([m4/include_next.m4])
m4_include([m4/lib-ignore.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])
m4_include([m4/ltversion.m4])
m4_include([m4/lt~obsolete.m4])
m4_include([m4/memchr.m4])
m4_include([m4/mmap-anon.m4])
m4_include([m4/onceonly.m4])
......
This diff is collapsed.
......@@ -35,6 +35,9 @@
don't. */
#undef HAVE_DECL_STRNLEN
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
......@@ -172,6 +175,10 @@
/* Define if you have the 'wchar_t' type. */
#undef HAVE_WCHAR_T
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to a substitute value for mmap()'s MAP_ANONYMOUS flag. */
#undef MAP_ANONYMOUS
......
This diff is collapsed.
......@@ -11,7 +11,7 @@ AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_RANLIB
AC_PROG_LIBTOOL
AM_SILENT_RULES([yes])
AC_HEADER_STDC
......@@ -269,5 +269,5 @@ GTK_DOC_CHECK([1.11],[--flavour no-tmpl])
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_FILES(Makefile lib/Makefile doc/reference/Makefile)
AC_CONFIG_FILES(Makefile lib/Makefile doc/reference/Makefile libcrystfel/Makefile)
AC_OUTPUT
/*
* alter_stream.c
*
* Do transformations on a stream
*
* (c) 2006-2011 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <assert.h>
#include "../src/utils.h"
#include "../src/stream.h"
#include "../src/cell.h"
#include "../src/image.h"
#include "../src/beam-parameters.h"
#include "../src/geometry.h"
#include "../src/peaks.h"
static void mess_up_cell(UnitCell *cell)
{
double ax, ay, az;
double bx, by, bz;
double cx, cy, cz;
/* Cell noise in percent */
const double cnoise = 0.5;
//STATUS("Real:\n");
//cell_print(cell);
cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
ax = gaussian_noise(ax, cnoise*fabs(ax)/100.0);
ay = gaussian_noise(ay, cnoise*fabs(ay)/100.0);
az = gaussian_noise(az, cnoise*fabs(az)/100.0);
bx = gaussian_noise(bx, cnoise*fabs(bx)/100.0);
by = gaussian_noise(by, cnoise*fabs(by)/100.0);
bz = gaussian_noise(bz, cnoise*fabs(bz)/100.0);
cx = gaussian_noise(cx, cnoise*fabs(cx)/100.0);
cy = gaussian_noise(cy, cnoise*fabs(cy)/100.0);
cz = gaussian_noise(cz, cnoise*fabs(cz)/100.0);
cell_set_reciprocal(cell, ax, ay, az, bx, by, bz, cx, cy, cz);
//STATUS("Changed:\n");
//cell_print(cell);
}
static void show_help(const char *s)
{
printf("Syntax: %s [options]\n\n", s);
printf(
"Alter a stream.\n"
"\n"
" -h, --help Display this help message.\n"
"\n"
"You need to provide the following basic options:\n"
" -i, --input=<file> Read reflections from <file>.\n"
" -o, --output=<file> Write partials in stream format to <file>.\n"
);
}
int main(int argc, char *argv[])
{
int c;
char *input_file = NULL;
char *output_file = NULL;
struct image image;
struct detector *det = NULL;
struct beam_params *beam = NULL;
char *beamfile = NULL;
char *geomfile = NULL;
FILE *ifh;
FILE *ofh;
int v;
/* Long options */
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"output", 1, NULL, 'o'},
{"input", 1, NULL, 'i'},
{"beam", 1, NULL, 'b'},
{"geometry", 1, NULL, 'g'},
{0, 0, NULL, 0}
};
/* Short options */
while ((c = getopt_long(argc, argv, "hi:o:b:g:",
longopts, NULL)) != -1) {
switch (c) {
case 'h' :
show_help(argv[0]);
return 0;
case 'o' :
output_file = strdup(optarg);
break;
case 'i' :
input_file = strdup(optarg);
break;
case 'b' :
beamfile = strdup(optarg);
break;
case 'g' :
geomfile = strdup(optarg);
break;
case 0 :
break;
default :
return 1;
}
}
if ( input_file == NULL ) {
ERROR("You must pgive a filename for the output.\n");
return 1;
}
ifh = fopen(input_file, "r");
if ( ifh == NULL ) {
ERROR("Couldn't open input file '%s'\n", input_file);
return 1;
}
free(input_file);
if ( output_file == NULL ) {
ERROR("You must pgive a filename for the output.\n");
return 1;
}
ofh = fopen(output_file, "w");
if ( ofh == NULL ) {
ERROR("Couldn't open output file '%s'\n", output_file);
return 1;
}
free(output_file);
/* Load beam */
if ( beamfile == NULL ) {
ERROR("You need to provide a beam parameters file.\n");
return 1;
}
beam = get_beam_parameters(beamfile);
if ( beam == NULL ) {
ERROR("Failed to load beam parameters from '%s'\n", beamfile);
return 1;
}
free(beamfile);
/* Load geometry */
if ( geomfile == NULL ) {
ERROR("You need to give a geometry file.\n");
return 1;
}
det = get_detector_geometry(geomfile);
if ( det == NULL ) {
ERROR("Failed to read geometry from '%s'\n", geomfile);
return 1;
}
free(geomfile);
write_stream_header(ofh, argc, argv);
image.det = det;
image.width = det->max_fs;
image.height = det->max_ss;
image.lambda = 0.0;
image.div = beam->divergence;
image.bw = beam->bandwidth;
image.profile_radius = 0.0001e9;
image.i0_available = 0;
do {
image.indexed_cell = NULL;
v = read_chunk(ifh, &image);
if ( (v == 0) && (image.indexed_cell != NULL) ) {
mess_up_cell(image.indexed_cell);
image.reflections = find_intersections(&image,
image.indexed_cell);
write_chunk(ofh, &image, NULL, STREAM_INTEGRATED);
}
} while ( v == 0 );
fclose(ofh);
fclose(ifh);
return 0;
}
/*
* cubeit.c
*
* "Full integration" of diffraction data
*
* (c) 2006-2011 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <assert.h>
#include <png.h>
#include <fenv.h>
#include <pthread.h>
#include <libgen.h>
#include <cairo.h>
#include "../src/utils.h"
#include "../src/hdf5-file.h"
#include "../src/diffraction.h"
#include "../src/render.h"
#include "../src/symmetry.h"
#include "../src/stream.h"
#include "../src/thread-pool.h"
struct static_sum_args
{
pthread_mutex_t *vals_mutex; /* Protects "vals" */
double *vals;
int xs;
int ys;
int zs;
int config_angles;
pthread_mutex_t *angles_mutex; /* Protects "angles" */
unsigned int *angles;
pthread_mutex_t *cell_mutex; /* Protects "angles" */
double *as;
double *bs;
double *cs;
double *als;
double *bes;
double *gas;
struct detector *det;
char *element;
signed int ht;
signed int kt;
signed int lt;
SymOpList *sym;
};
struct sum_args
{
char *filename;
UnitCell *cell;
struct static_sum_args static_args;
};
struct queue_args
{
FILE *fh;
char *prefix;
int config_basename;
struct static_sum_args static_args;
};
static void show_help(const char *s)
{
printf("Syntax: %s [options]\n\n", s);
printf(
"'Full integration' of diffraction data.\n"
"\n"
" -h, --help Display this help message.\n"
"\n"
" -i, --input=<filename> Specify the name of the input stream.\n"
" Can be '-' for stdin.\n"
" -g. --geometry=<file> Get detector geometry from file.\n"
" -x, --prefix=<p> Prefix filenames from input file with <p>.\n"
" --basename Remove the directory parts of the filenames.\n"
" --no-check-prefix Don't attempt to correct the --prefix.\n"
" -j <n> Run <n> analyses in parallel.\n"
" -e, --image=<element> Use this image from the HDF5 file.\n"
" Example: /data/data0.\n"
" Default: The first one found.\n");
}
static void add_to_mean(UnitCell *cell, double *ast, double *bst, double *cst,
double *alst, double *best, double *gast)
{
double asx, asy, asz;
double bsx, bsy, bsz;
double csx, csy, csz;
cell_get_reciprocal(cell, &asx, &asy, &asz, &bsx, &bsy, &bsz,
&csx, &csy, &csz);
*ast += modulus(asx, asy, asz);
*bst += modulus(bsx, bsy, bsz);
*cst += modulus(csx, csy, csz);
*alst += angle_between(bsx, bsy, bsz, csx, csy, csz);
*best += angle_between(asx, asy, asz, csx, csy, csz);
*gast += angle_between(asx, asy, asz, bsx, bsy, bsz);
}
static void interpolate_linear(double *vals, double v,