Commit 2600c19c authored by Thomas White's avatar Thomas White
Browse files

Initial fork from template_index to pattern_sim

parent 7335cb68
......@@ -9,5 +9,4 @@ configure
stamp-h1
src/*.o
src/.deps
src/template_index
src/simulate_patterns
src/pattern_sim
dnl Process this file with autoconf to produce a configure script.
AC_INIT(template_index, 0.1.0, thomas.white@desy.de)
AC_INIT(pattern_sim, 0.1.0, thomas.white@desy.de)
VERSION=AC_PACKAGE_VERSION
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(template_index, "$VERSION")
AM_INIT_AUTOMAKE(pattern_sim, "$VERSION")
AC_PROG_CC
AC_PROG_AWK
......
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
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
/*
* 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);
}
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
/*
* 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;
}
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
......@@ -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
*
*/
......
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