aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-10-23 11:30:39 +0200
committerThomas White <taw@bitwiz.org.uk>2009-10-23 11:30:39 +0200
commit2600c19c6d9b994de1cb2d5e634571a55434c707 (patch)
tree804ac9d20d06b9f2c93c15b107e71fc439456e2f /src
parent7335cb683b8c6cafb817c3cb809a6d5c61c5c3b1 (diff)
Initial fork from template_index to pattern_sim
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am13
-rw-r--r--src/cell.c2
-rw-r--r--src/cell.h2
-rw-r--r--src/hdf5-file.c2
-rw-r--r--src/hdf5-file.h2
-rw-r--r--src/image.c2
-rw-r--r--src/image.h2
-rw-r--r--src/main.c109
-rw-r--r--src/relrod.c2
-rw-r--r--src/relrod.h2
-rw-r--r--src/sim-main.c116
-rw-r--r--src/templates.c2
-rw-r--r--src/templates.h2
-rw-r--r--src/utils.c2
-rw-r--r--src/utils.h2
15 files changed, 66 insertions, 196 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 40a39194..d30736c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,10 +1,5 @@
-bin_PROGRAMS = template_index simulate_patterns
+bin_PROGRAMS = pattern_sim
-template_index_SOURCES = main.c relrod.c utils.c image.c cell.c hdf5-file.c \
- templates.c
-template_index_LDADD = @LIBS@ -lm -lgsl -lgslcblas
-AM_CFLAGS = -Wall -g
-
-simulate_patterns_SOURCES = sim-main.c relrod.c utils.c image.c cell.c \
- hdf5-file.c templates.c
-simulate_patterns_LDADD = @LIBS@ -lm -lgsl -lgslcblas
+pattern_sim_SOURCES = main.c relrod.c utils.c image.c cell.c hdf5-file.c \
+ templates.c
+pattern_sim_LDADD = @LIBS@ -lm -lgsl -lgslcblas
diff --git a/src/cell.c b/src/cell.c
index 7f726fab..5e8b1ce6 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -5,7 +5,7 @@
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/cell.h b/src/cell.h
index 196b9521..b2203561 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -5,7 +5,7 @@
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/hdf5-file.c b/src/hdf5-file.c
index 46538c76..ca1d5450 100644
--- a/src/hdf5-file.c
+++ b/src/hdf5-file.c
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/hdf5-file.h b/src/hdf5-file.h
index c288d4cd..a263368a 100644
--- a/src/hdf5-file.h
+++ b/src/hdf5-file.h
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/image.c b/src/image.c
index b7cf4c31..874d1f4a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/image.h b/src/image.h
index 41e6e2b6..c596abfe 100644
--- a/src/image.h
+++ b/src/image.h
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/main.c b/src/main.c
index 967fbb58..04f806f2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,11 +1,9 @@
/*
* main.c
*
- * "Main"
- *
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
@@ -20,11 +18,15 @@
#include <string.h>
#include <unistd.h>
-#include "cell.h"
#include "image.h"
+#include "relrod.h"
+#include "cell.h"
#include "utils.h"
#include "hdf5-file.h"
-#include "templates.h"
+
+
+/* Crystal size in metres */
+#define CRYSTAL_SIZE (500.0e-9)
static void main_show_help(const char *s)
@@ -37,13 +39,11 @@ static void main_show_help(const char *s)
int main(int argc, char *argv[])
{
- int c;
- char **in_files;
- size_t nin;
- size_t i;
+ int c, i;
UnitCell *cell;
- TemplateList *templates;
- struct image template_parameters;
+ struct image image;
+ int nrefl;
+ float t;
while ((c = getopt(argc, argv, "h")) != -1) {
@@ -58,17 +58,6 @@ int main(int argc, char *argv[])
}
- if ( optind < argc ) {
- nin = argc-optind;
- in_files = malloc(nin*sizeof(char *));
- for ( i=0; i<nin; i++ ) {
- in_files[i] = strdup(argv[optind+i]);
- }
- } else {
- fprintf(stderr, "No input files!\n");
- return 1;
- }
-
/* Define unit cell */
cell = cell_new_from_parameters(28.10e-9,
28.10e-9,
@@ -77,45 +66,47 @@ int main(int argc, char *argv[])
deg2rad(90.0),
deg2rad(120.0));
- /* Generate templates */
- template_parameters.width = 512;
- template_parameters.height = 512;
- template_parameters.fmode = FORMULATION_CLEN;
- template_parameters.x_centre = 255.5;
- template_parameters.y_centre = 255.5;
- template_parameters.camera_len = 0.2; /* 20 cm */
- template_parameters.resolution = 5120; /* 512 pixels in 10 cm */
- template_parameters.lambda = 0.2e-9; /* LCLS wavelength */
- templates = generate_templates(cell, template_parameters);
-
- printf("%i files to index:\n", nin);
- printf(" #: Omega Tilt\n");
- printf("--------------------------------------------------\n");
- for ( i=0; i<nin; i++ ) {
-
- struct image image;
-
- printf("%6i: %20s ", i+1, in_files[i]);
-
- image.width = 512;
- image.height = 512;
- image.fmode = FORMULATION_CLEN;
- image.x_centre = 255.5;
- image.y_centre = 255.5;
- image.camera_len = 0.2; /* 20 cm */
- image.resolution = 5120; /* 512 pixels in 10 cm */
- image.lambda = 0.2e-9; /* LCLS wavelength */
-
- if ( hdf5_read(&image, in_files[i]) ) {
- fprintf(stderr, "Couldn't read file '%s'\n",
- in_files[i]);
- continue;
- }
+ /* Define image parameters */
+ image.width = 512;
+ image.height = 512;
+ image.omega = deg2rad(40.0);
+ image.fmode = FORMULATION_CLEN;
+ image.x_centre = 255.5;
+ image.y_centre = 255.5;
+ image.camera_len = 0.2; /* 20 cm */
+ image.resolution = 5120; /* 512 pixels in 10 cm */
+ image.lambda = 0.2e-9; /* LCLS wavelength */
+ image.data = malloc(512*512*2);
+
+ for ( t=0.0; t<180.0; t+=10.0 ) {
- try_templates(&image, templates);
+ char filename[32];
+
+ memset(image.data, 0, 512*512*2);
+ image.tilt = deg2rad(t);
+
+ /* Calculate reflections */
+ get_reflections(&image, cell, 1.0/CRYSTAL_SIZE);
+
+ /* Construct the image */
+ nrefl = image_feature_count(image.rflist);
+ for ( i=0; i<nrefl; i++ ) {
+
+ struct imagefeature *f;
+ int x, y;
+
+ f = image_get_feature(image.rflist, i);
+
+ x = f->x;
+ y = f->y; /* Discards digits after the decimal point */
+
+ image.data[y*image.width+x] = 1;
+
+ }
- printf("%+8.2f %+8.2f deg\n", rad2deg(image.omega),
- rad2deg(image.tilt));
+ /* Write the output file */
+ snprintf(filename, 32, "simulated-%.0f.h5", t);
+ hdf5_write(filename, image.data, image.width, image.height);
}
diff --git a/src/relrod.c b/src/relrod.c
index f9ae68c9..7ee4dfe3 100644
--- a/src/relrod.c
+++ b/src/relrod.c
@@ -5,7 +5,7 @@
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/relrod.h b/src/relrod.h
index 9bb1762a..7d35cf60 100644
--- a/src/relrod.h
+++ b/src/relrod.h
@@ -5,7 +5,7 @@
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/sim-main.c b/src/sim-main.c
deleted file mode 100644
index c316987f..00000000
--- a/src/sim-main.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * sim-main.c
- *
- * Simulate test data
- *
- * (c) 2006-2009 Thomas White <thomas.white@desy.de>
- *
- * template_index - Indexing diffraction patterns by template matching
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "image.h"
-#include "relrod.h"
-#include "cell.h"
-#include "utils.h"
-#include "hdf5-file.h"
-
-
-/* Crystal size in metres */
-#define CRYSTAL_SIZE (500.0e-9)
-
-
-static void main_show_help(const char *s)
-{
- printf("Syntax: %s <file1.h5> <file2.h5> [...]\n\n", s);
- printf("Index diffraction patterns\n\n");
- printf(" -h Display this help message\n");
-}
-
-
-int main(int argc, char *argv[])
-{
- int c, i;
- UnitCell *cell;
- struct image image;
- int nrefl;
- float t;
-
- while ((c = getopt(argc, argv, "h")) != -1) {
-
- switch ( c ) {
-
- case 'h' : {
- main_show_help(argv[0]);
- return 0;
- }
-
- }
-
- }
-
- /* Define unit cell */
- cell = cell_new_from_parameters(28.10e-9,
- 28.10e-9,
- 16.52e-9,
- deg2rad(90.0),
- deg2rad(90.0),
- deg2rad(120.0));
-
- /* Define image parameters */
- image.width = 512;
- image.height = 512;
- image.omega = deg2rad(40.0);
- image.fmode = FORMULATION_CLEN;
- image.x_centre = 255.5;
- image.y_centre = 255.5;
- image.camera_len = 0.2; /* 20 cm */
- image.resolution = 5120; /* 512 pixels in 10 cm */
- image.lambda = 0.2e-9; /* LCLS wavelength */
- image.data = malloc(512*512*2);
-
- for ( t=0.0; t<180.0; t+=10.0 ) {
-
- char filename[32];
-
- memset(image.data, 0, 512*512*2);
- image.tilt = deg2rad(t);
-
- /* Calculate reflections */
- get_reflections(&image, cell, 1.0/CRYSTAL_SIZE);
-
- /* Construct the image */
- nrefl = image_feature_count(image.rflist);
- for ( i=0; i<nrefl; i++ ) {
-
- struct imagefeature *f;
- int x, y;
-
- f = image_get_feature(image.rflist, i);
-
- x = f->x;
- y = f->y; /* Discards digits after the decimal point */
-
- image.data[y*image.width+x] = 1;
-
- }
-
- /* Write the output file */
- snprintf(filename, 32, "simulated-%.0f.h5", t);
- hdf5_write(filename, image.data, image.width, image.height);
-
- }
-
- return 0;
-}
diff --git a/src/templates.c b/src/templates.c
index 632e5a9f..1ad1c95a 100644
--- a/src/templates.c
+++ b/src/templates.c
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/templates.h b/src/templates.h
index c4b66171..c9d053ad 100644
--- a/src/templates.h
+++ b/src/templates.h
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/utils.c b/src/utils.c
index 0c7d7ad4..38855671 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/
diff --git a/src/utils.h b/src/utils.h
index ef37bc73..a60abe7e 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -5,7 +5,7 @@
*
* (c) 2006-2009 Thomas White <thomas.white@desy.de>
*
- * template_index - Indexing diffraction patterns by template matching
+ * pattern_sim - Simulate diffraction patterns from small crystals
*
*/