aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-03-03 17:37:10 +0100
committerThomas White <taw@physics.org>2017-03-08 16:53:19 +0100
commit61565336125a999790fb4c36219e9c46c5eb30cc (patch)
treea4762229bad75ecf7679ac5f76162b20d7b0cd66 /src
parent10c3e04dda4264add6e99cb4763c9dbb31c771c9 (diff)
Allow indexing system to store its own data, independently of indexing methods
Previously, the indexing system passed all the information on to the indexing engines and then forgot about it. That made it difficult to do things like check the indexing solution after prediction refinement, because the target unit cell was unavailable. Now, the indexing system itself can keep some information. Of course, that information includes the private pointers for the indexing engines themselves. I took the opportunity to streamline things a little bit. The caller can now set up the indexing system in one step, without having to separately parse the names of the indexing methods. The caller no longer has to keep track of a separate array of methods, instead just one structure which contains everything.
Diffstat (limited to 'src')
-rw-r--r--src/im-sandbox.c2
-rw-r--r--src/indexamajig.c67
-rw-r--r--src/process_image.c3
-rw-r--r--src/process_image.h3
4 files changed, 24 insertions, 51 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index f5493453..2dabf3e9 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -372,7 +372,7 @@ static void run_work(const struct index_args *iargs, Stream *st,
}
time_accounts_set(taccs, TACC_FINALCLEANUP);
- cleanup_indexing(iargs->indm, iargs->ipriv);
+ cleanup_indexing(iargs->ipriv);
free_detector_geometry(iargs->det);
free(iargs->hdf5_peak_path);
free_copy_hdf5_field_list(iargs->copyme);
diff --git a/src/indexamajig.c b/src/indexamajig.c
index a1997b9e..82a15e21 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -3,13 +3,13 @@
*
* Index patterns, output hkl+intensity etc.
*
- * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
* Copyright © 2012 Lorenzo Galli
*
* Authors:
- * 2010-2015 Thomas White <taw@physics.org>
+ * 2010-2017 Thomas White <taw@physics.org>
* 2011 Richard Kirian
* 2012 Lorenzo Galli
* 2012 Chunhong Yoon
@@ -181,8 +181,6 @@ int main(int argc, char *argv[])
int config_checkprefix = 1;
int config_basename = 0;
int integrate_saturated = 0;
- IndexingMethod *indm;
- IndexingPrivate **ipriv;
char *indm_str = NULL;
char *cellfile = NULL;
char *prefix = NULL;
@@ -236,7 +234,6 @@ int main(int argc, char *argv[])
ERROR("Couldn't allocate HDF5 field list.\n");
return 1;
}
- iargs.indm = NULL; /* No default */
iargs.ipriv = NULL; /* No default */
iargs.int_meth = integration_method("rings-nocen-nosat-nograd", NULL);
iargs.push_res = 0.0;
@@ -591,35 +588,6 @@ int main(int argc, char *argv[])
iargs.hdf5_peak_path = command_line_peak_path;
}
- /* Parse indexing methods */
- if ( indm_str == NULL ) {
-
- STATUS("You didn't specify an indexing method, so I won't try "
- " to index anything.\n"
- "If that isn't what you wanted, re-run with"
- " --indexing=<methods>.\n");
- indm = NULL;
-
- } else {
-
- int i = 0;
-
- indm = build_indexer_list(indm_str);
- if ( indm == NULL ) {
- ERROR("Invalid indexer list '%s'\n", indm_str);
- return 1;
- }
- free(indm_str);
-
- /* If --no-refine, unset the refinement flag on all methods */
- if ( no_refine ) {
- while ( indm[i] != INDEXING_NONE ) {
- indm[i] &= ~INDEXING_REFINE;
- i++;
- }
- }
- }
-
/* Parse integration method */
if ( int_str != NULL ) {
@@ -755,23 +723,30 @@ int main(int argc, char *argv[])
}
free(outfile);
- /* Prepare the indexer */
- if ( indm != NULL ) {
- ipriv = prepare_indexing(indm, iargs.cell, iargs.det,
- iargs.tols, iargs.felix_options);
- if ( ipriv == NULL ) {
- ERROR("Failed to prepare indexing.\n");
+ /* Prepare the indexing system */
+ if ( indm_str == NULL ) {
+
+ STATUS("You didn't specify an indexing method, so I won't try "
+ " to index anything.\n"
+ "If that isn't what you wanted, re-run with"
+ " --indexing=<methods>.\n");
+ iargs.ipriv = NULL;
+
+ } else {
+
+ iargs.ipriv = setup_indexing(indm_str, iargs.cell, iargs.det,
+ iargs.tols, no_refine,
+ iargs.felix_options);
+ if ( iargs.ipriv == NULL ) {
+ ERROR("Failed to set up indexing system\n");
return 1;
}
- } else {
- ipriv = NULL;
+ free(indm_str);
+
}
gsl_set_error_handler_off();
- iargs.indm = indm;
- iargs.ipriv = ipriv;
-
create_sandbox(&iargs, n_proc, prefix, config_basename, fh,
st, tempdir);
@@ -783,7 +758,7 @@ int main(int argc, char *argv[])
free_detector_geometry(iargs.det);
free(iargs.hdf5_peak_path);
close_stream(st);
- cleanup_indexing(indm, ipriv);
+ cleanup_indexing(iargs.ipriv);
return 0;
}
diff --git a/src/process_image.c b/src/process_image.c
index bcaee543..f3629e0e 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -219,8 +219,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
/* Index the pattern */
time_accounts_set(taccs, TACC_INDEXING);
- index_pattern_2(&image, iargs->indm, iargs->ipriv,
- &sb_shared->pings[cookie]);
+ index_pattern_2(&image, iargs->ipriv, &sb_shared->pings[cookie]);
r = chdir(rn);
if ( r ) {
diff --git a/src/process_image.h b/src/process_image.h
index d41c23f5..57be255c 100644
--- a/src/process_image.h
+++ b/src/process_image.h
@@ -61,8 +61,7 @@ struct index_args
float min_snr;
int check_hdf5_snr;
struct detector *det;
- IndexingMethod *indm;
- IndexingPrivate **ipriv;
+ IndexingPrivate *ipriv;
int peaks; /* Peak detection method */
float tols[4];
struct beam_params *beam;