aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile.am9
-rw-r--r--Makefile.in69
-rw-r--r--contrib/alter_stream.c215
4 files changed, 278 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index a29b27ee..d60f8cdc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,7 @@ src/partial_sim
src/.dirstamp
*~
doc/reference/*
+contrib/.deps
+contrib/*.o
+contrib/.dirstamp
+contrib/alter_stream
diff --git a/Makefile.am b/Makefile.am
index 2c4672ce..489a5dd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,8 @@ 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
+ src/check_hkl src/sum_stack src/partial_sim \
+ contrib/alter_stream
noinst_PROGRAMS = tests/list_check tests/integration_check \
tests/pr_gradient_check
@@ -127,6 +128,12 @@ src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.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
diff --git a/Makefile.in b/Makefile.in
index 1413d922..2ca908cd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -41,7 +41,7 @@ bin_PROGRAMS = src/pattern_sim$(EXEEXT) src/process_hkl$(EXEEXT) \
src/render_hkl$(EXEEXT) src/calibrate_detector$(EXEEXT) \
src/partialator$(EXEEXT) src/check_hkl$(EXEEXT) \
src/sum_stack$(EXEEXT) src/partial_sim$(EXEEXT) \
- $(am__EXEEXT_1) $(am__EXEEXT_2)
+ contrib/alter_stream$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
noinst_PROGRAMS = tests/list_check$(EXEEXT) \
tests/integration_check$(EXEEXT) \
tests/pr_gradient_check$(EXEEXT) $(am__EXEEXT_3)
@@ -89,6 +89,17 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
@HAVE_OPENCL_TRUE@am__EXEEXT_3 = tests/gpu_sim_check$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am__dirstamp = $(am__leading_dot)dirstamp
+am_contrib_alter_stream_OBJECTS = contrib/alter_stream.$(OBJEXT) \
+ src/stream.$(OBJEXT) src/image.$(OBJEXT) \
+ src/thread-pool.$(OBJEXT) src/detector.$(OBJEXT) \
+ src/utils.$(OBJEXT) src/cell.$(OBJEXT) \
+ src/reflist-utils.$(OBJEXT) src/reflist.$(OBJEXT) \
+ src/symmetry.$(OBJEXT) src/hdf5-file.$(OBJEXT) \
+ src/beam-parameters.$(OBJEXT) src/geometry.$(OBJEXT) \
+ src/peaks.$(OBJEXT)
+contrib_alter_stream_OBJECTS = $(am_contrib_alter_stream_OBJECTS)
+contrib_alter_stream_LDADD = $(LDADD)
+contrib_alter_stream_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
am_src_calibrate_detector_OBJECTS = src/calibrate_detector.$(OBJEXT) \
src/utils.$(OBJEXT) src/hdf5-file.$(OBJEXT) \
src/image.$(OBJEXT) src/thread-pool.$(OBJEXT) \
@@ -307,7 +318,8 @@ am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \
+SOURCES = $(contrib_alter_stream_SOURCES) \
+ $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \
$(src_compare_hkl_SOURCES) $(src_cubeit_SOURCES) \
$(src_get_hkl_SOURCES) $(src_hdfsee_SOURCES) \
$(src_indexamajig_SOURCES) $(src_partial_sim_SOURCES) \
@@ -317,10 +329,10 @@ SOURCES = $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \
$(tests_gpu_sim_check_SOURCES) \
$(tests_integration_check_SOURCES) $(tests_list_check_SOURCES) \
$(tests_pr_gradient_check_SOURCES)
-DIST_SOURCES = $(src_calibrate_detector_SOURCES) \
- $(src_check_hkl_SOURCES) $(src_compare_hkl_SOURCES) \
- $(am__src_cubeit_SOURCES_DIST) $(src_get_hkl_SOURCES) \
- $(am__src_hdfsee_SOURCES_DIST) \
+DIST_SOURCES = $(contrib_alter_stream_SOURCES) \
+ $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \
+ $(src_compare_hkl_SOURCES) $(am__src_cubeit_SOURCES_DIST) \
+ $(src_get_hkl_SOURCES) $(am__src_hdfsee_SOURCES_DIST) \
$(am__src_indexamajig_SOURCES_DIST) $(src_partial_sim_SOURCES) \
$(src_partialator_SOURCES) $(am__src_pattern_sim_SOURCES_DIST) \
$(src_powder_plot_SOURCES) $(src_process_hkl_SOURCES) \
@@ -717,6 +729,12 @@ src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
@BUILD_CUBEIT_TRUE@ src/symmetry.c src/stream.c src/thread-pool.c \
@BUILD_CUBEIT_TRUE@ src/reflist.c src/reflist-utils.c
+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
@@ -853,24 +871,28 @@ clean-binPROGRAMS:
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+contrib/$(am__dirstamp):
+ @$(MKDIR_P) contrib
+ @: > contrib/$(am__dirstamp)
+contrib/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) contrib/$(DEPDIR)
+ @: > contrib/$(DEPDIR)/$(am__dirstamp)
+contrib/alter_stream.$(OBJEXT): contrib/$(am__dirstamp) \
+ contrib/$(DEPDIR)/$(am__dirstamp)
src/$(am__dirstamp):
@$(MKDIR_P) src
@: > src/$(am__dirstamp)
src/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) src/$(DEPDIR)
@: > src/$(DEPDIR)/$(am__dirstamp)
-src/calibrate_detector.$(OBJEXT): src/$(am__dirstamp) \
- src/$(DEPDIR)/$(am__dirstamp)
-src/utils.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
-src/hdf5-file.$(OBJEXT): src/$(am__dirstamp) \
+src/stream.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/image.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/thread-pool.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/detector.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
-src/stream.$(OBJEXT): src/$(am__dirstamp) \
- src/$(DEPDIR)/$(am__dirstamp)
+src/utils.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/cell.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/reflist-utils.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
@@ -878,7 +900,18 @@ src/reflist.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/symmetry.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
+src/hdf5-file.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/beam-parameters.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/geometry.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/peaks.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+contrib/alter_stream$(EXEEXT): $(contrib_alter_stream_OBJECTS) $(contrib_alter_stream_DEPENDENCIES) contrib/$(am__dirstamp)
+ @rm -f contrib/alter_stream$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(contrib_alter_stream_OBJECTS) $(contrib_alter_stream_LDADD) $(LIBS)
+src/calibrate_detector.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/calibrate_detector$(EXEEXT): $(src_calibrate_detector_OBJECTS) $(src_calibrate_detector_DEPENDENCIES) src/$(am__dirstamp)
@rm -f src/calibrate_detector$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(src_calibrate_detector_OBJECTS) $(src_calibrate_detector_LDADD) $(LIBS)
@@ -905,8 +938,6 @@ src/cubeit$(EXEEXT): $(src_cubeit_OBJECTS) $(src_cubeit_DEPENDENCIES) src/$(am__
$(AM_V_CCLD)$(LINK) $(src_cubeit_OBJECTS) $(src_cubeit_LDADD) $(LIBS)
src/get_hkl.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
-src/beam-parameters.$(OBJEXT): src/$(am__dirstamp) \
- src/$(DEPDIR)/$(am__dirstamp)
src/get_hkl$(EXEEXT): $(src_get_hkl_OBJECTS) $(src_get_hkl_DEPENDENCIES) src/$(am__dirstamp)
@rm -f src/get_hkl$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(src_get_hkl_OBJECTS) $(src_get_hkl_LDADD) $(LIBS)
@@ -925,8 +956,6 @@ src/diffraction.$(OBJEXT): src/$(am__dirstamp) \
src/dirax.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/mosflm.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
-src/geometry.$(OBJEXT): src/$(am__dirstamp) \
- src/$(DEPDIR)/$(am__dirstamp)
src/diffraction-gpu.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/cl-utils.$(OBJEXT): src/$(am__dirstamp) \
@@ -1004,6 +1033,7 @@ tests/pr_gradient_check$(EXEEXT): $(tests_pr_gradient_check_OBJECTS) $(tests_pr_
mostlyclean-compile:
-rm -f *.$(OBJEXT)
+ -rm -f contrib/alter_stream.$(OBJEXT)
-rm -f src/beam-parameters.$(OBJEXT)
-rm -f src/calibrate_detector.$(OBJEXT)
-rm -f src/cell.$(OBJEXT)
@@ -1052,6 +1082,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@contrib/$(DEPDIR)/alter_stream.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/beam-parameters.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/calibrate_detector.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/cell.Po@am__quote@
@@ -1658,6 +1689,8 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f contrib/$(DEPDIR)/$(am__dirstamp)
+ -rm -f contrib/$(am__dirstamp)
-rm -f src/$(DEPDIR)/$(am__dirstamp)
-rm -f src/$(am__dirstamp)
-rm -f tests/$(DEPDIR)/$(am__dirstamp)
@@ -1673,7 +1706,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf src/$(DEPDIR) tests/$(DEPDIR)
+ -rm -rf contrib/$(DEPDIR) src/$(DEPDIR) tests/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
@@ -1722,7 +1755,7 @@ installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf src/$(DEPDIR) tests/$(DEPDIR)
+ -rm -rf contrib/$(DEPDIR) src/$(DEPDIR) tests/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
diff --git a/contrib/alter_stream.c b/contrib/alter_stream.c
new file mode 100644
index 00000000..2c5d207b
--- /dev/null
+++ b/contrib/alter_stream.c
@@ -0,0 +1,215 @@
+/*
+ * 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, STREAM_INTEGRATED);
+
+ }
+
+ } while ( v == 0 );
+
+
+ fclose(ofh);
+ fclose(ifh);
+
+ return 0;
+}