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

Add facetron program for profile fitting and post-refinement

parent 63129a82
......@@ -15,4 +15,5 @@ src/compare_hkl
src/powder_plot
src/render_hkl
src/calibrate_detector
src/facetron
*~
#!/bin/sh
echo $1 | indexamajig --indexing=dirax -i - \
-g ~/crystfel/examples/lcls-dec.geom \
-p ~/lcls/1JB0.pdb \
--near-bragg --filter-cm \
2>/dev/null | grep 'star' | cut -d"=" -f 2 | cut -d" " -f 1-4 \
| ~/crystfel/src/facetron
bin_PROGRAMS = pattern_sim process_hkl get_hkl indexamajig compare_hkl \
powder_plot render_hkl calibrate_detector
powder_plot render_hkl calibrate_detector facetron
if HAVE_GTK
bin_PROGRAMS += hdfsee
......@@ -55,4 +55,7 @@ calibrate_detector_SOURCES = calibrate_detector.c utils.c hdf5-file.c image.c \
sfac.c
calibrate_detector_LDADD = @LIBS@
facetron_SOURCES = facetron.c cell.c
facetron_LDADD = @LIBS@
INCLUDES = "-I$(top_srcdir)/data"
......@@ -35,7 +35,7 @@ POST_UNINSTALL = :
bin_PROGRAMS = pattern_sim$(EXEEXT) process_hkl$(EXEEXT) \
get_hkl$(EXEEXT) indexamajig$(EXEEXT) compare_hkl$(EXEEXT) \
powder_plot$(EXEEXT) render_hkl$(EXEEXT) \
calibrate_detector$(EXEEXT) $(am__EXEEXT_1)
calibrate_detector$(EXEEXT) facetron$(EXEEXT) $(am__EXEEXT_1)
@HAVE_GTK_TRUE@am__append_1 = hdfsee
@HAVE_OPENCL_TRUE@am__append_2 = diffraction-gpu.c cl-utils.c
@HAVE_OPENCL_TRUE@am__append_3 = diffraction-gpu.c cl-utils.c
......@@ -63,6 +63,9 @@ am_compare_hkl_OBJECTS = compare_hkl.$(OBJEXT) sfac.$(OBJEXT) \
statistics.$(OBJEXT) symmetry.$(OBJEXT)
compare_hkl_OBJECTS = $(am_compare_hkl_OBJECTS)
compare_hkl_DEPENDENCIES =
am_facetron_OBJECTS = facetron.$(OBJEXT) cell.$(OBJEXT)
facetron_OBJECTS = $(am_facetron_OBJECTS)
facetron_DEPENDENCIES =
am_get_hkl_OBJECTS = get_hkl.$(OBJEXT) sfac.$(OBJEXT) cell.$(OBJEXT) \
utils.$(OBJEXT) reflections.$(OBJEXT) symmetry.$(OBJEXT)
get_hkl_OBJECTS = $(am_get_hkl_OBJECTS)
......@@ -134,12 +137,13 @@ AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(calibrate_detector_SOURCES) $(compare_hkl_SOURCES) \
$(get_hkl_SOURCES) $(hdfsee_SOURCES) $(indexamajig_SOURCES) \
$(pattern_sim_SOURCES) $(powder_plot_SOURCES) \
$(process_hkl_SOURCES) $(render_hkl_SOURCES)
$(facetron_SOURCES) $(get_hkl_SOURCES) $(hdfsee_SOURCES) \
$(indexamajig_SOURCES) $(pattern_sim_SOURCES) \
$(powder_plot_SOURCES) $(process_hkl_SOURCES) \
$(render_hkl_SOURCES)
DIST_SOURCES = $(calibrate_detector_SOURCES) $(compare_hkl_SOURCES) \
$(get_hkl_SOURCES) $(am__hdfsee_SOURCES_DIST) \
$(am__indexamajig_SOURCES_DIST) \
$(facetron_SOURCES) $(get_hkl_SOURCES) \
$(am__hdfsee_SOURCES_DIST) $(am__indexamajig_SOURCES_DIST) \
$(am__pattern_sim_SOURCES_DIST) $(powder_plot_SOURCES) \
$(process_hkl_SOURCES) $(render_hkl_SOURCES)
ETAGS = etags
......@@ -272,6 +276,8 @@ calibrate_detector_SOURCES = calibrate_detector.c utils.c hdf5-file.c image.c \
sfac.c
calibrate_detector_LDADD = @LIBS@
facetron_SOURCES = facetron.c cell.c
facetron_LDADD = @LIBS@
INCLUDES = "-I$(top_srcdir)/data"
all: all-am
......@@ -350,6 +356,9 @@ calibrate_detector$(EXEEXT): $(calibrate_detector_OBJECTS) $(calibrate_detector_
compare_hkl$(EXEEXT): $(compare_hkl_OBJECTS) $(compare_hkl_DEPENDENCIES)
@rm -f compare_hkl$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(compare_hkl_OBJECTS) $(compare_hkl_LDADD) $(LIBS)
facetron$(EXEEXT): $(facetron_OBJECTS) $(facetron_DEPENDENCIES)
@rm -f facetron$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(facetron_OBJECTS) $(facetron_LDADD) $(LIBS)
get_hkl$(EXEEXT): $(get_hkl_OBJECTS) $(get_hkl_DEPENDENCIES)
@rm -f get_hkl$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(get_hkl_OBJECTS) $(get_hkl_LDADD) $(LIBS)
......@@ -387,6 +396,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diffraction.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirax.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/displaywindow.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/facetron.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filters.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_hkl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdf5-file.Po@am__quote@
......
......@@ -150,8 +150,7 @@ UnitCell *cell_new_from_parameters(double a, double b, double c,
}
static UnitCell *cell_new_from_axes(struct rvec as, struct rvec bs,
struct rvec cs)
UnitCell *cell_new_from_axes(struct rvec as, struct rvec bs, struct rvec cs)
{
UnitCell *cell;
......
......@@ -16,6 +16,14 @@
#include <config.h>
#endif
/* A 3D vector in reciprocal space */
struct rvec
{
double u;
double v;
double w;
};
typedef struct _unitcell UnitCell;
extern UnitCell *cell_new(void);
......@@ -25,6 +33,9 @@ extern UnitCell *cell_new_from_cell(UnitCell *orig);
extern UnitCell *cell_new_from_parameters(double a, double b, double c,
double alpha, double beta, double gamma);
extern UnitCell *cell_new_from_axes(struct rvec as, struct rvec bs,
struct rvec cs);
extern void cell_set_cartesian(UnitCell *cell,
double ax, double ay, double az,
double bx, double by, double bz,
......
/*
* facetron.c
*
* Profile fitting for coherent nanocrystallography
*
* (c) 2006-2010 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 "image.h"
#include "cell.h"
static void show_help(const char *s)
{
printf("Syntax: %s [options]\n\n", s);
printf(
"Profile fitting for coherent nanocrystallography.\n"
"\n"
" -h, --help Display this help message.\n"
"\n"
" -i, --input=<filename> Specify the name of the image to work on.\n"
" -m, --matrix=<filename> Specify the file which contains the initial\n"
" orientation matrix. Can be '-' for stdin,\n"
" which is the default. Units are nm^-1.\n"
);
}
static UnitCell *read_orientation_matrix(const char *filename)
{
FILE *mfh;
float u, v, w;
struct rvec as, bs, cs;
UnitCell *cell;
if ( (filename == NULL) || (strcmp(filename, "-") == 0) ) {
mfh = stdin;
} else {
mfh = fopen(filename, "r");
}
if ( mfh == NULL ) {
ERROR("Failed to open matrix file '%s'\n", filename);
return NULL;
}
if ( fscanf(mfh, "%f %f %f", &u, &v, &w) != 3 ) {
ERROR("Couldn't read a-star\n");
return NULL;
}
as.u = u*1e9; as.v = v*1e9; as.w = w*1e9;
if ( fscanf(mfh, "%f %f %f", &u, &v, &w) != 3 ) {
ERROR("Couldn't read b-star\n");
return NULL;
}
bs.u = u*1e9; bs.v = v*1e9; bs.w = w*1e9;
if ( fscanf(mfh, "%f %f %f", &u, &v, &w) != 3 ) {
ERROR("Couldn't read c-star\n");
return NULL;
}
cs.u = u*1e9; cs.v = v*1e9; cs.w = w*1e9;
cell = cell_new_from_axes(as, bs, cs);
fclose(mfh);
return cell;
}
int main(int argc, char *argv[])
{
int c;
char *infile = NULL;
char *matrix = NULL;
UnitCell *cell;
/* Long options */
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"input", 1, NULL, 'i'},
{"matrix", 1, NULL, 'm'},
{0, 0, NULL, 0}
};
/* Short options */
while ((c = getopt_long(argc, argv, "hi:m:", longopts, NULL)) != -1) {
switch (c) {
case 'h' :
show_help(argv[0]);
return 0;
case 'i' :
infile = strdup(optarg);
break;
case 'm' :
matrix = strdup(optarg);
break;
case 0 :
break;
default :
return 1;
}
}
cell = read_orientation_matrix(matrix);
free(matrix);
if ( cell == NULL ) {
ERROR("Couldn't read initial orientation matrix.\n");
return 1;
}
cell_print(cell);
return 0;
}
......@@ -58,15 +58,6 @@ struct imagefeature {
typedef struct _imagefeaturelist ImageFeatureList;
/* A 3D vector in reciprocal space */
struct rvec
{
double u;
double v;
double w;
};
struct reflhit {
signed int h;
signed int k;
......
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