aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-10-27 16:13:49 +0200
committerThomas White <taw@physics.org>2017-10-27 16:13:49 +0200
commit29d60af9d37a9d2cf67d7e0b77354d4fd518679a (patch)
tree506e4e8ef6d3e881db2790d5904813d8b9657d5e /libcrystfel/src
parent45038c42847476ce1aee5b09c47fb330a0108cd6 (diff)
parent3caab16fad2ebd2fcc2f245a6cb4a62fad46f806 (diff)
Merge branch 'tom/simpler_felix'
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/felix.c197
-rw-r--r--libcrystfel/src/felix.h14
-rw-r--r--libcrystfel/src/index.c11
-rw-r--r--libcrystfel/src/index.h6
4 files changed, 111 insertions, 117 deletions
diff --git a/libcrystfel/src/felix.c b/libcrystfel/src/felix.c
index 79252b2b..bbd82b0e 100644
--- a/libcrystfel/src/felix.c
+++ b/libcrystfel/src/felix.c
@@ -188,7 +188,9 @@ static int read_felix(struct felix_private *gp, struct image *image,
cell_set_cartesian(cell, ubi12/1e10, ubi13/1e10, ubi11/1e10,
ubi22/1e10, ubi23/1e10, ubi21/1e10,
ubi32/1e10, ubi33/1e10, ubi31/1e10);
+ cell_set_lattice_type(cell, cell_get_lattice_type(gp->cell));
cell_set_centering(cell, cell_get_centering(gp->cell));
+ cell_set_unique_axis(cell, cell_get_unique_axis(gp->cell));
cr = crystal_new();
if ( cr == NULL ) {
@@ -383,7 +385,8 @@ static char *write_ini(struct image *image, struct felix_private *gp)
&tt, 1.0/image->lambda);
fprintf(fh, "spacegroup %i\n", gp->spacegroup);
- fprintf(fh, "tthrange %f %f\n", gp->tthrange_min, gp->tthrange_max);
+ fprintf(fh, "tthrange %f %f\n", rad2deg(gp->tthrange_min),
+ rad2deg(gp->tthrange_max));
fprintf(fh, "etarange %f %f\n", gp->etarange_min, gp->etarange_max);
fprintf(fh, "domega %f\n", gp->domega);
fprintf(fh, "omegarange %f %f\n", gp->omegarange_min, gp->omegarange_max);
@@ -544,112 +547,66 @@ int felix_index(struct image *image, IndexingPrivate *ipriv)
}
-static void parse_options(const char *options, struct felix_private *gp)
+static int sg_number_for_cell(UnitCell *cell)
{
- char *temp_options;
- char *option;
- char *freeme;
-
- temp_options = strdup(options);
- freeme = temp_options;
-
- while ( (option=strsep(&temp_options, ",")) != NULL ) {
-
- if ( strncmp(option, "spacegroup=", 11) == 0 ){
- gp->spacegroup = atoi(option+11);
- }
-
- if ( strncmp(option, "tthrange_min=", 13) == 0 ){
- gp->tthrange_min = atof(option+13);
- }
-
- if ( strncmp(option, "tthrange_max=", 13 ) == 0 ){
- gp->tthrange_max = atof(option+13);
- }
-
- if ( strncmp(option, "etarange_min=", 13 ) == 0 ){
- gp->etarange_min = atof(option+13);
- }
-
- if ( strncmp(option, "etarange_max=", 13 ) == 0 ){
- gp->etarange_max = atof(option+13);
- }
-
- if ( strncmp(option, "domega=", 7) == 0 ){
- gp->domega = atof(option+7);
- }
-
- if ( strncmp(option, "omegarange_min=", 15) == 0 ){
- gp->omegarange_min = atof(option+15);
- }
-
- if ( strncmp(option, "omegarange_max=", 15) == 0 ){
- gp->omegarange_max = atof(option+15);
- }
-
- if ( strncmp(option, "min_measurements=", 17) == 0 ){
- gp->min_measurements = atoi(option+17);
- }
-
- if ( strncmp(option, "min_completeness=", 17) == 0 ){
- gp->min_completeness = atof(option+17);
- }
-
- if ( strncmp(option, "min_uniqueness=", 15) == 0 ){
- gp->min_uniqueness = atof(option+15);
- }
-
- if ( strncmp(option, "n_voxels=", 9) == 0 ){
- gp->n_voxels = atoi(option+9);
- }
-
- if ( strncmp(option, "test_fraction=", 14) == 0 ){
- gp->test_fraction = atof(option+14);
- }
-
- if ( strncmp(option, "sigma_tth=", 10) == 0 ){
- gp->sigma_tth = atof(option+10);
- }
-
- if ( strncmp(option, "sigma_eta=", 10) == 0 ){
- gp->sigma_eta = atof(option+10);
+ LatticeType lattice = cell_get_lattice_type(cell);
+ char cen = cell_get_centering(cell);
+
+ switch (lattice)
+ {
+ case L_TRICLINIC:
+ return 1; /* P1 */
+
+ case L_MONOCLINIC:
+ switch ( cen ) {
+ case 'P' : return 3; /* P2 */
+ case 'C' : return 5; /* C2 */
+ default : return 0;
}
- if ( strncmp(option, "sigma_omega=", 12) == 0 ){
- gp->sigma_omega = atof(option+12);
+ case L_ORTHORHOMBIC:
+ switch ( cen ) {
+ case 'P' : return 16; /* P222 */
+ case 'C' : return 21; /* C222 */
+ case 'F' : return 22; /* F222 */
+ case 'I' : return 23; /* I222 */
+ case 'A' : return 38; /* Amm2 */
+ default : return 0;
}
- if ( strncmp(option, "n_sigmas=", 9) == 0 ){
- gp->n_sigmas = atoi(option+9);
+ case L_TETRAGONAL:
+ switch ( cen ) {
+ case 'P' : return 89; /* P422 */
+ case 'I' : return 97; /* I422 */
+ default : return 0;
}
- if ( strncmp(option, "force4frustums", 14) == 0 ){
- gp->force4frustums = 1;
- }
-
- /* Only allow one orispace command.
- * orispace frustum is the default, so have to turn off to use octa.
- */
- if ( strncmp(option, "orispace_octa", 13) == 0 ){
- gp->orispace_octa = 1;
- gp->orispace_frustum = 0;
- }
+ case L_RHOMBOHEDRAL:
+ return 155; /* R32 */
- if ( strncmp(option, "readhkl=", 8) == 0 ){
- gp->readhkl_file = strdup(option+8);
+ case L_HEXAGONAL:
+ switch ( cen ) {
+ case 'P' : return 177; /* P622 */
+ case 'H' : return 143; /* P3 */
+ default : return 0;
}
- if ( strncmp(option, "maxtime=", 8) == 0 ){
- gp->maxtime = atof(option+8);
+ case L_CUBIC:
+ switch ( cen ) {
+ case 'P' : return 207; /* P432 */
+ case 'F' : return 209; /* F432 */
+ case 'I' : return 211; /* I432 */
+ default : return 0;
}
+ default:
+ return 0;
}
-
- free(freeme);
- free(option);
}
-void *felix_prepare(IndexingMethod *indm, UnitCell *cell, const char *options)
+
+void *felix_prepare(IndexingMethod *indm, UnitCell *cell,
+ struct felix_options *opts)
{
struct felix_private *gp;
@@ -659,7 +616,7 @@ void *felix_prepare(IndexingMethod *indm, UnitCell *cell, const char *options)
return NULL;
}
- if ( cell == NULL ) {
+ if ( !cell_has_parameters(cell) ) {
ERROR("Felix needs a unit cell.\n");
return NULL;
}
@@ -675,9 +632,15 @@ void *felix_prepare(IndexingMethod *indm, UnitCell *cell, const char *options)
gp->indm = *indm;
/* Default values of felix options */
- gp->spacegroup = 0;
- gp->tthrange_min = 0;
- gp->tthrange_max = 30.0;
+ gp->spacegroup = sg_number_for_cell(cell);
+ if ( gp->spacegroup == 0 ) {
+ ERROR("Couldn't determine representative space group for your cell.\n");
+ ERROR("Try again with a more conventional cell.\n");
+ return NULL;
+ }
+
+ /* Default parameters */
+ gp->n_voxels = 100;
gp->etarange_min = 0;
gp->etarange_max = 360;
gp->domega = 2;
@@ -686,28 +649,44 @@ void *felix_prepare(IndexingMethod *indm, UnitCell *cell, const char *options)
gp->min_measurements = 15;
gp->min_completeness = 0.001;
gp->min_uniqueness = 0.5;
- gp->n_voxels = 100;
gp->test_fraction = 0.75;
- gp->sigma_tth = 0.15;
+ gp->sigma_tth = 0.2;
gp->sigma_eta = 0.2;
gp->sigma_omega = 0.2;
- gp->n_sigmas = 2;
+ gp->n_sigmas = 1;
gp->force4frustums = 0;
gp->orispace_frustum = 1;
gp->orispace_octa = 0;
gp->readhkl_file = NULL;
gp->maxtime = 30.0;
+ gp->tthrange_min = deg2rad(0.0);
+ gp->tthrange_max = deg2rad(30.0);
- /* Parse the options string and fill in the necessary
- * private variables. */
- if ( options != NULL ) parse_options(options, gp);
-
- /* Make sure that they at least specified the spacegroup number.*/
-
- if ( gp->spacegroup == 0 ) {
- ERROR("Felix requires that you specify the spacegroup number.\n");
- ERROR("You should use the argument --felix-options=spacegroup=xx\n");
- return NULL;
+ if ( opts->ttmin > 0.0 ) {
+ gp->tthrange_min = opts->ttmin;
+ }
+ if ( opts->ttmax > 0.0 ) {
+ gp->tthrange_max = opts->ttmax;
+ }
+ if ( opts->min_measurements > 0 ) {
+ gp->min_measurements = opts->min_measurements;
+ }
+ if ( opts->min_completeness > 0.0 ) {
+ gp->min_completeness = opts->min_completeness;
+ }
+ if ( opts->min_uniqueness > 0.0 ) {
+ gp->min_uniqueness = opts->min_uniqueness;
+ }
+ if ( opts->n_voxels > 0 ) {
+ gp->n_voxels = opts->n_voxels;
+ }
+ if ( opts->test_fraction > 0.0 ) {
+ gp->test_fraction = opts->test_fraction;
+ }
+ if ( opts->sigma > 0.0 ) {
+ gp->sigma_tth = opts->sigma;
+ gp->sigma_eta = opts->sigma;
+ gp->sigma_omega = opts->sigma;
}
return (IndexingPrivate *)gp;
diff --git a/libcrystfel/src/felix.h b/libcrystfel/src/felix.h
index 61b1d352..48ffbe9c 100644
--- a/libcrystfel/src/felix.h
+++ b/libcrystfel/src/felix.h
@@ -36,8 +36,20 @@
#include "cell.h"
+struct felix_options
+{
+ double ttmin; /* radians */
+ double ttmax; /* radians */
+ int min_measurements;
+ double min_completeness;
+ double min_uniqueness;
+ int n_voxels;
+ double test_fraction;
+ double sigma;
+};
+
extern void *felix_prepare(IndexingMethod *indm, UnitCell *cell,
- const char *options);
+ struct felix_options *opts);
extern const char *felix_probe(UnitCell *cell);
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index cdc0e305..62f22c13 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -197,7 +197,7 @@ static char *friendly_indexer_name(IndexingMethod m)
static void *prepare_method(IndexingMethod *m, UnitCell *cell,
- const char *options)
+ struct felix_options *felix_opts)
{
char *str;
IndexingMethod in = *m;
@@ -230,7 +230,7 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell,
break;
case INDEXING_FELIX :
- priv = felix_prepare(m, cell, options);
+ priv = felix_prepare(m, cell, felix_opts);
break;
case INDEXING_TAKETWO :
@@ -266,8 +266,9 @@ static void *prepare_method(IndexingMethod *m, UnitCell *cell,
IndexingPrivate *setup_indexing(const char *method_list, UnitCell *cell,
struct detector *det, float *ltl,
- IndexingFlags flags, const char *options,
- struct taketwo_options *ttopts)
+ IndexingFlags flags,
+ struct taketwo_options *ttopts,
+ struct felix_options *felix_opts)
{
int i, n;
char **method_strings;
@@ -363,7 +364,7 @@ IndexingPrivate *setup_indexing(const char *method_list, UnitCell *cell,
int j;
ipriv->engine_private[i] = prepare_method(&methods[i], cell,
- options);
+ felix_opts);
if ( ipriv->engine_private[i] == NULL ) return NULL;
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index 4e1f1519..8ece9227 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -136,12 +136,14 @@ extern IndexingMethod get_indm_from_string_2(const char *method, int *err);
#include "cell.h"
#include "image.h"
#include "taketwo.h"
+#include "felix.h"
extern IndexingPrivate *setup_indexing(const char *methods, UnitCell *cell,
struct detector *det, float *ltl,
- IndexingFlags flags, const char *options,
- struct taketwo_options *ttopts);
+ IndexingFlags flags,
+ struct taketwo_options *ttopts,
+ struct felix_options *felix_opts);
extern char *detect_indexing_methods(UnitCell *cell);