aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-20 11:16:15 +0200
committerThomas White <taw@physics.org>2020-08-20 11:16:15 +0200
commitd9e011c9e3f877ed95482fd54a549c065ff9b8be (patch)
tree2983933be34814995b449fe78362bf4ea180e5b1
parenta0e9410fae73b1c91e21f8748a39164691895c6f (diff)
Add default_method_options()
This allows the indexing method private options structures to be set up easily.
-rw-r--r--libcrystfel/src/index.c12
-rw-r--r--libcrystfel/src/index.h5
-rw-r--r--libcrystfel/src/indexers/felix.c38
-rw-r--r--libcrystfel/src/indexers/felix.h2
-rw-r--r--libcrystfel/src/indexers/pinkindexer.c44
-rw-r--r--libcrystfel/src/indexers/pinkindexer.h2
-rw-r--r--libcrystfel/src/indexers/taketwo.c25
-rw-r--r--libcrystfel/src/indexers/taketwo.h1
-rw-r--r--libcrystfel/src/indexers/xgandalf.c32
-rw-r--r--libcrystfel/src/indexers/xgandalf.h2
10 files changed, 121 insertions, 42 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index d8c48a2e..836901ff 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -1195,3 +1195,15 @@ char *detect_indexing_methods(UnitCell *cell)
return methods;
}
+
+
+void default_method_options(TakeTwoOptions **ttopts,
+ XGandalfOptions **xgandalf_opts,
+ PinkIndexerOptions **pinkIndexer_opts,
+ FelixOptions **felix_opts)
+{
+ taketwo_default_options(ttopts);
+ xgandalf_default_options(xgandalf_opts);
+ pinkIndexer_default_options(pinkIndexer_opts);
+ felix_default_options(felix_opts);
+}
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index ab2b12a4..39f5429c 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -158,6 +158,11 @@ extern struct argp pinkIndexer_argp;
extern struct argp taketwo_argp;
extern struct argp xgandalf_argp;
+extern void default_method_options(TakeTwoOptions **ttopts,
+ XGandalfOptions **xgandalf_opts,
+ PinkIndexerOptions **pinkIndexer_opts,
+ FelixOptions **felix_opts);
+
extern IndexingPrivate *setup_indexing(const char *methods,
UnitCell *cell,
const DataTemplate *dtempl,
diff --git a/libcrystfel/src/indexers/felix.c b/libcrystfel/src/indexers/felix.c
index 524e68a7..b94227d0 100644
--- a/libcrystfel/src/indexers/felix.c
+++ b/libcrystfel/src/indexers/felix.c
@@ -832,27 +832,41 @@ static void felix_show_help()
}
+int felix_default_options(FelixOptions **opts_ptr)
+{
+ FelixOptions *opts;
+
+ opts = malloc(sizeof(struct felix_options));
+ if ( opts == NULL ) return ENOMEM;
+
+ opts->ttmin = -1.0;
+ opts->ttmax = -1.0;
+ opts->min_visits = 0;
+ opts->min_completeness = -1.0;
+ opts->max_uniqueness = -1.0;
+ opts->n_voxels = 0;
+ opts->fraction_max_visits = -1.0;
+ opts->sigma = -1.0;
+ opts->domega = -1.0;
+ opts->max_internal_angle = -1.0;
+
+ *opts_ptr = opts;
+ return 0;
+}
+
+
static error_t felix_parse_arg(int key, char *arg,
struct argp_state *state)
{
struct felix_options **opts_ptr = state->input;
float tmp;
+ int r;
switch ( key ) {
case ARGP_KEY_INIT :
- *opts_ptr = malloc(sizeof(struct felix_options));
- if ( *opts_ptr == NULL ) return ENOMEM;
- (*opts_ptr)->ttmin = -1.0;
- (*opts_ptr)->ttmax = -1.0;
- (*opts_ptr)->min_visits = 0;
- (*opts_ptr)->min_completeness = -1.0;
- (*opts_ptr)->max_uniqueness = -1.0;
- (*opts_ptr)->n_voxels = 0;
- (*opts_ptr)->fraction_max_visits = -1.0;
- (*opts_ptr)->sigma = -1.0;
- (*opts_ptr)->domega = -1.0;
- (*opts_ptr)->max_internal_angle = -1.0;
+ r = felix_default_options(opts_ptr);
+ if ( r ) return r;
break;
case 1 :
diff --git a/libcrystfel/src/indexers/felix.h b/libcrystfel/src/indexers/felix.h
index 3c9d4a94..2e4d78ab 100644
--- a/libcrystfel/src/indexers/felix.h
+++ b/libcrystfel/src/indexers/felix.h
@@ -39,6 +39,8 @@
* Felix indexer interface
*/
+extern int felix_default_options(FelixOptions **opts_ptr);
+
extern void *felix_prepare(IndexingMethod *indm, UnitCell *cell,
struct felix_options *opts);
diff --git a/libcrystfel/src/indexers/pinkindexer.c b/libcrystfel/src/indexers/pinkindexer.c
index 3d23e158..ac4a42d2 100644
--- a/libcrystfel/src/indexers/pinkindexer.c
+++ b/libcrystfel/src/indexers/pinkindexer.c
@@ -475,30 +475,44 @@ static void pinkIndexer_show_help()
}
+int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr)
+{
+ PinkIndexerOptions *opts;
+
+ opts = malloc(sizeof(struct pinkIndexer_options));
+ if ( opts == NULL ) return ENOMEM;
+
+ opts->considered_peaks_count = 4;
+ opts->angle_resolution = 2;
+ opts->refinement_type = 1;
+ opts->tolerance = 0.06;
+ opts->maxResolutionForIndexing_1_per_A = +INFINITY;
+ opts->thread_count = 1;
+ opts->multi = 0;
+ opts->no_check_indexed = 0;
+ opts->min_peaks = 2;
+ opts->reflectionRadius = -1;
+ opts->customPhotonEnergy = -1;
+ opts->customBandwidth = -1;
+ opts->maxRefinementDisbalance = 0.4;
+
+ *opts_ptr = opts;
+ return 0;
+}
+
+
static error_t pinkindexer_parse_arg(int key, char *arg,
struct argp_state *state)
{
float tmp, tmp2;
+ int r;
struct pinkIndexer_options **opts_ptr = state->input;
switch ( key ) {
case ARGP_KEY_INIT :
- *opts_ptr = malloc(sizeof(struct pinkIndexer_options));
- if ( *opts_ptr == NULL ) return ENOMEM;
- (*opts_ptr)->considered_peaks_count = 4;
- (*opts_ptr)->angle_resolution = 2;
- (*opts_ptr)->refinement_type = 1;
- (*opts_ptr)->tolerance = 0.06;
- (*opts_ptr)->maxResolutionForIndexing_1_per_A = +INFINITY;
- (*opts_ptr)->thread_count = 1;
- (*opts_ptr)->multi = 0;
- (*opts_ptr)->no_check_indexed = 0;
- (*opts_ptr)->min_peaks = 2;
- (*opts_ptr)->reflectionRadius = -1;
- (*opts_ptr)->customPhotonEnergy = -1;
- (*opts_ptr)->customBandwidth = -1;
- (*opts_ptr)->maxRefinementDisbalance = 0.4;
+ r = pinkIndexer_default_options(opts_ptr);
+ if ( r ) return r;
break;
case 1 :
diff --git a/libcrystfel/src/indexers/pinkindexer.h b/libcrystfel/src/indexers/pinkindexer.h
index cab88a75..57df5f62 100644
--- a/libcrystfel/src/indexers/pinkindexer.h
+++ b/libcrystfel/src/indexers/pinkindexer.h
@@ -34,6 +34,8 @@
#include "index.h"
#include "datatemplate.h"
+extern int pinkIndexer_default_options(PinkIndexerOptions **opts_ptr);
+
extern int run_pinkIndexer(struct image *image, void *ipriv);
extern void *pinkIndexer_prepare(IndexingMethod *indm, UnitCell *cell,
diff --git a/libcrystfel/src/indexers/taketwo.c b/libcrystfel/src/indexers/taketwo.c
index 65265b0e..aef88582 100644
--- a/libcrystfel/src/indexers/taketwo.c
+++ b/libcrystfel/src/indexers/taketwo.c
@@ -2288,21 +2288,34 @@ static void taketwo_show_help()
}
+int taketwo_default_options(TakeTwoOptions **opts_ptr)
+{
+ TakeTwoOptions *opts;
+
+ opts = malloc(sizeof(struct taketwo_options));
+ if ( opts == NULL ) return ENOMEM;
+ opts->member_thresh = -1.0;
+ opts->len_tol = -1.0;
+ opts->angle_tol = -1.0;
+ opts->trace_tol = -1.0;
+
+ *opts_ptr = opts;
+ return 0;
+}
+
+
static error_t taketwo_parse_arg(int key, char *arg,
struct argp_state *state)
{
struct taketwo_options **opts_ptr = state->input;
float tmp;
+ int r;
switch ( key ) {
case ARGP_KEY_INIT :
- *opts_ptr = malloc(sizeof(struct taketwo_options));
- if ( *opts_ptr == NULL ) return ENOMEM;
- (*opts_ptr)->member_thresh = -1.0;
- (*opts_ptr)->len_tol = -1.0;
- (*opts_ptr)->angle_tol = -1.0;
- (*opts_ptr)->trace_tol = -1.0;
+ r = taketwo_default_options(opts_ptr);
+ if ( r ) return r;
break;
case 1 :
diff --git a/libcrystfel/src/indexers/taketwo.h b/libcrystfel/src/indexers/taketwo.h
index 50fa221d..7bfd582c 100644
--- a/libcrystfel/src/indexers/taketwo.h
+++ b/libcrystfel/src/indexers/taketwo.h
@@ -38,6 +38,7 @@
/** \file taketwo.h */
+extern int taketwo_default_options(TakeTwoOptions **opts_ptr);
extern void *taketwo_prepare(IndexingMethod *indm, struct taketwo_options *opts,
UnitCell *cell);
extern const char *taketwo_probe(UnitCell *cell);
diff --git a/libcrystfel/src/indexers/xgandalf.c b/libcrystfel/src/indexers/xgandalf.c
index 2d2dca48..3a44bf04 100644
--- a/libcrystfel/src/indexers/xgandalf.c
+++ b/libcrystfel/src/indexers/xgandalf.c
@@ -382,23 +382,37 @@ static void xgandalf_show_help()
}
+int xgandalf_default_options(XGandalfOptions **opts_ptr)
+{
+ XGandalfOptions *opts;
+
+ opts = malloc(sizeof(struct xgandalf_options));
+ if ( opts == NULL ) return ENOMEM;
+
+ opts->sampling_pitch = 6;
+ opts->grad_desc_iterations = 4;
+ opts->tolerance = 0.02;
+ opts->no_deviation_from_provided_cell = 0;
+ opts->minLatticeVectorLength_A = 30;
+ opts->maxLatticeVectorLength_A = 250;
+ opts->maxPeaksForIndexing = 250;
+
+ *opts_ptr = opts;
+ return 0;
+}
+
+
static error_t xgandalf_parse_arg(int key, char *arg,
struct argp_state *state)
{
struct xgandalf_options **opts_ptr = state->input;
+ int r;
switch ( key ) {
case ARGP_KEY_INIT :
- *opts_ptr = malloc(sizeof(struct xgandalf_options));
- if ( *opts_ptr == NULL ) return ENOMEM;
- (*opts_ptr)->sampling_pitch = 6;
- (*opts_ptr)->grad_desc_iterations = 4;
- (*opts_ptr)->tolerance = 0.02;
- (*opts_ptr)->no_deviation_from_provided_cell = 0;
- (*opts_ptr)->minLatticeVectorLength_A = 30;
- (*opts_ptr)->maxLatticeVectorLength_A = 250;
- (*opts_ptr)->maxPeaksForIndexing = 250;
+ r = xgandalf_default_options(opts_ptr);
+ if ( r ) return r;
break;
case 1 :
diff --git a/libcrystfel/src/indexers/xgandalf.h b/libcrystfel/src/indexers/xgandalf.h
index 288d141a..01bc52ed 100644
--- a/libcrystfel/src/indexers/xgandalf.h
+++ b/libcrystfel/src/indexers/xgandalf.h
@@ -39,6 +39,8 @@
#include "index.h"
+extern int xgandalf_default_options(XGandalfOptions **opts_ptr);
+
extern int run_xgandalf(struct image *image, void *ipriv);
extern void *xgandalf_prepare(IndexingMethod *indm, UnitCell *cell,