aboutsummaryrefslogtreecommitdiff
path: root/src/reflist-utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-15 15:56:26 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:20 +0100
commitb8ac0faea1abb2e3033140dcd157160bfa98d251 (patch)
treee62dd9269372375c95936d72c33187a5945edf29 /src/reflist-utils.c
parentbe49b97c792edc33d908965823f73f33b830d557 (diff)
WIP on new stream format in process_hkl
Diffstat (limited to 'src/reflist-utils.c')
-rw-r--r--src/reflist-utils.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/reflist-utils.c b/src/reflist-utils.c
new file mode 100644
index 00000000..33d373b8
--- /dev/null
+++ b/src/reflist-utils.c
@@ -0,0 +1,72 @@
+/*
+ * reflist-utils.c
+ *
+ * Utilities to complement the core reflist.c
+ *
+ * (c) 2006-2011 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+
+#include <stdio.h>
+
+
+#include "reflist.h"
+#include "cell.h"
+
+
+void write_reflections_to_file(FILE *fh, RefList *list, UnitCell *cell)
+{
+ Reflection *refl;
+ RefListIterator *iter;
+
+ fprintf(fh, " h k l I phase sigma(I) "
+ " 1/d(nm^-1) counts fs/px ss/px\n");
+
+ for ( refl = first_refl(list, &iter);
+ refl != NULL;
+ refl = next_refl(refl, iter) ) {
+
+ signed int h, k, l;
+ double intensity, esd_i, s;
+ double fs, ss;
+
+ get_indices(refl, &h, &k, &l);
+ get_detector_pos(refl, &fs, &ss);
+ intensity = get_intensity(refl);
+ esd_i = 0.0; /* FIXME! */
+ s = 0.0; /* FIXME! */
+
+ /* h, k, l, I, sigma(I), s */
+ fprintf(fh,
+ "%3i %3i %3i %10.2f %s %10.2f %10.2f %7i %6.1f %6.1f\n",
+ h, k, l, intensity, " -", esd_i, s/1.0e9, 1,
+ fs, ss);
+
+ }
+}
+
+
+int write_reflist(const char *filename, RefList *list, UnitCell *cell)
+{
+ FILE *fh;
+
+ if ( filename == NULL ) {
+ fh = stdout;
+ } else {
+ fh = fopen(filename, "w");
+ }
+
+ if ( fh == NULL ) {
+ ERROR("Couldn't open output file '%s'.\n", filename);
+ return 1;
+ }
+
+ write_reflections_to_file(fh, list, cell);
+
+ fclose(fh);
+
+ return 0;
+}