diff options
author | Thomas White <taw@physics.org> | 2023-04-24 16:52:16 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-07-28 13:22:04 +0200 |
commit | 99849c8ed87a424a76e4826ed39ad65cacfaecfb (patch) | |
tree | 23c1b0f505527cf7550f65e0f004d505e2efe2a9 | |
parent | c8fb149760f7a8ef4e018f22e79bcb48e1e3c444 (diff) |
indexamajig: Hooks for Mille
-rw-r--r-- | libcrystfel/src/index.c | 18 | ||||
-rw-r--r-- | libcrystfel/src/index.h | 8 | ||||
-rw-r--r-- | libcrystfel/src/predict-refine.c | 35 | ||||
-rw-r--r-- | libcrystfel/src/predict-refine.h | 9 | ||||
-rw-r--r-- | src/im-sandbox.c | 14 | ||||
-rw-r--r-- | src/indexamajig.c | 11 | ||||
-rw-r--r-- | src/process_image.c | 7 | ||||
-rw-r--r-- | src/process_image.h | 9 |
8 files changed, 91 insertions, 20 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 02b01757..e3512b4a 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -591,7 +591,8 @@ static float real_time() /* Return non-zero for "success" */ static int try_indexer(struct image *image, IndexingMethod indm, - IndexingPrivate *ipriv, void *mpriv, char *last_task) + IndexingPrivate *ipriv, void *mpriv, char *last_task, + Mille *mille) { int i, r; int n_bad = 0; @@ -719,7 +720,7 @@ static int try_indexer(struct image *image, IndexingMethod indm, { int r; profile_start("refine"); - r = refine_prediction(image, cr); + r = refine_prediction(image, cr, mille); profile_end("refine"); if ( r ) { crystal_set_user_flag(cr, 1); @@ -920,19 +921,26 @@ static int finished_retry(IndexingMethod indm, IndexingFlags flags, void index_pattern(struct image *image, IndexingPrivate *ipriv) { - index_pattern_3(image, ipriv, NULL, NULL); + index_pattern_4(image, ipriv, NULL, NULL, NULL); } void index_pattern_2(struct image *image, IndexingPrivate *ipriv, int *ping) { - index_pattern_3(image, ipriv, ping, NULL); + index_pattern_4(image, ipriv, ping, NULL, NULL); } void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, char *last_task) { + index_pattern_4(image, ipriv, ping, last_task, NULL); +} + + +void index_pattern_4(struct image *image, IndexingPrivate *ipriv, int *ping, + char *last_task, Mille *mille) +{ int n = 0; ImageFeatureList *orig; @@ -982,7 +990,7 @@ void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, r = try_indexer(image, ipriv->methods[n], ipriv, ipriv->engine_private[n], - last_task); + last_task, mille); success += r; ntry++; done = finished_retry(ipriv->methods[n], ipriv->flags, diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index 94018904..fa371276 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -3,13 +3,13 @@ * * Perform indexing (somehow) * - * Copyright © 2012-2021 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2023 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2021 Thomas White <taw@physics.org> + * 2010-2023 Thomas White <taw@physics.org> * 2010 Richard Kirian * 2012 Lorenzo Galli * 2015 Kenneth Beyerlein <kenneth.beyerlein@desy.de> @@ -210,6 +210,7 @@ extern char *base_indexer_str(IndexingMethod indm); #include "cell.h" #include "image.h" #include "datatemplate.h" +#include "predict-refine.h" extern struct argp felix_argp; extern struct argp pinkIndexer_argp; @@ -251,6 +252,9 @@ extern void index_pattern_2(struct image *image, IndexingPrivate *ipriv, extern void index_pattern_3(struct image *image, IndexingPrivate *ipriv, int *ping, char *last_task); +extern void index_pattern_4(struct image *image, IndexingPrivate *ipriv, + int *ping, char *last_task, Mille *mille); + extern void cleanup_indexing(IndexingPrivate *ipriv); #ifdef __cplusplus diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c index 19c689cd..d45388b9 100644 --- a/libcrystfel/src/predict-refine.c +++ b/libcrystfel/src/predict-refine.c @@ -3,11 +3,11 @@ * * Prediction refinement * - * Copyright © 2012-2021 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2023 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2020 Thomas White <taw@physics.org> + * 2010-2023 Thomas White <taw@physics.org> * 2016 Valerio Mariani * * This file is part of CrystFEL. @@ -37,6 +37,11 @@ #include "image.h" #include "geometry.h" #include "cell-utils.h" +#include "predict-refine.h" + +#ifdef HAVE_MILLEPEDE +#include <mille_c_wrap.h> +#endif /** \file predict-refine.h */ @@ -569,7 +574,7 @@ static void free_rps_noreflist(struct reflpeak *rps, int n) } -int refine_prediction(struct image *image, Crystal *cr) +int refine_prediction(struct image *image, Crystal *cr, Mille *mille) { int n; int i; @@ -654,5 +659,29 @@ int refine_prediction(struct image *image, Crystal *cr) return 1; } + if ( mille != NULL ) { + printf("Mille mode!\n"); + } + return 0; } + + +Mille *crystfel_mille_new(const char *outFileName, + int asBinary, + int writeZero) +{ + #ifdef HAVE_MILLEPEDE + return mille_new(outFileName, asBinary, writeZero); + #else + return NULL; + #endif +} + + +void crystfel_mille_free(Mille *m) +{ + #ifdef HAVE_MILLEPEDE + mille_free(m); + #endif +} diff --git a/libcrystfel/src/predict-refine.h b/libcrystfel/src/predict-refine.h index 5607e356..91b44e07 100644 --- a/libcrystfel/src/predict-refine.h +++ b/libcrystfel/src/predict-refine.h @@ -33,12 +33,19 @@ struct image; +typedef void *Mille; + /** * \file predict-refine.h * Prediction refinement: refinement of indexing solutions before integration. */ -extern int refine_prediction(struct image *image, Crystal *cr); +extern Mille *crystfel_mille_new(const char *outFileName, + int asBinary, + int writeZero); +extern void crystfel_mille_free(Mille *m); + +extern int refine_prediction(struct image *image, Crystal *cr, Mille *mille); extern int refine_radius(Crystal *cr, struct image *image); diff --git a/src/im-sandbox.c b/src/im-sandbox.c index a91c6a87..c3f2ca70 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -69,6 +69,7 @@ #include "im-zmq.h" #include "profile.h" #include "im-asapo.h" +#include "predict-refine.h" struct sandbox @@ -340,6 +341,7 @@ static int run_work(const struct index_args *iargs, Stream *st, int allDone = 0; struct im_zmq *zmqstuff = NULL; struct im_asapo *asapostuff = NULL; + Mille *mille; if ( sb->profile ) { profile_init(); @@ -363,6 +365,14 @@ static int run_work(const struct index_args *iargs, Stream *st, } } + if ( iargs->mille ) { + char tmp[64]; + snprintf(tmp, 63, "mille-data-%i.bin", cookie); + mille = crystfel_mille_new(tmp, 1, 0); + } else { + mille = NULL; + } + while ( !allDone ) { struct pattern_args pargs; @@ -519,7 +529,7 @@ static int run_work(const struct index_args *iargs, Stream *st, profile_start("process-image"); process_image(iargs, &pargs, st, cookie, tmpdir, ser, sb->shared, sb->shared->last_task[cookie], - asapostuff); + asapostuff, mille); profile_end("process-image"); } @@ -536,6 +546,8 @@ static int run_work(const struct index_args *iargs, Stream *st, free(pargs.event); } + crystfel_mille_free(mille); + /* These are both no-ops if argument is NULL */ im_zmq_shutdown(zmqstuff); im_asapo_shutdown(asapostuff); diff --git a/src/indexamajig.c b/src/indexamajig.c index 57e1e5fb..7f5504cd 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -3,13 +3,13 @@ * * Index patterns, output hkl+intensity etc. * - * Copyright © 2012-2022 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2023 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2022 Thomas White <taw@physics.org> + * 2010-2023 Thomas White <taw@physics.org> * 2011 Richard Kirian * 2012 Lorenzo Galli * 2012 Chunhong Yoon @@ -722,6 +722,10 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) } break; + case 416 : + args->iargs.mille = 1; + break; + /* ---------- Integration ---------- */ case 501 : @@ -966,6 +970,7 @@ int main(int argc, char *argv[]) args.iargs.clen_estimate = NAN; args.iargs.n_threads = 1; args.iargs.data_format = DATA_SOURCE_TYPE_UNKNOWN; + args.iargs.mille = 0; argp_program_version_hook = show_version; @@ -1085,6 +1090,8 @@ int main(int argc, char *argv[]) "Maximum number of threads allowed for indexing engines."}, {"camera-length-estimate", 415, "metres", 0, "Estimate of the camera length, in metres."}, + {"mille", 416, NULL, 0, + "Generate data for detector geometry refinement using Millepede"}, {NULL, 0, 0, OPTION_DOC, "Integration options:", 5}, {"integration", 501, "method", OPTION_NO_USAGE, "Integration method"}, diff --git a/src/process_image.c b/src/process_image.c index 8acd3e86..4763646a 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -178,7 +178,8 @@ static struct image *file_wait_open_read(const char *filename, void process_image(const struct index_args *iargs, struct pattern_args *pargs, Stream *st, int cookie, const char *tmpdir, int serial, struct sb_shm *sb_shared, - char *last_task, struct im_asapo *asapostuff) + char *last_task, struct im_asapo *asapostuff, + Mille *mille) { struct image *image; int i; @@ -414,8 +415,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Index the pattern */ set_last_task(last_task, "indexing"); profile_start("index"); - index_pattern_3(image, iargs->ipriv, &sb_shared->pings[cookie], - last_task); + index_pattern_4(image, iargs->ipriv, &sb_shared->pings[cookie], + last_task, mille); profile_end("index"); r = chdir(rn); diff --git a/src/process_image.h b/src/process_image.h index cca2f7d2..eabd425a 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -3,11 +3,11 @@ * * The processing pipeline for one image * - * Copyright © 2012-2022 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2023 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2022 Thomas White <taw@physics.org> + * 2010-2023 Thomas White <taw@physics.org> * 2014-2017 Valerio Mariani <valerio.mariani@desy.de> * 2017-2018 Yaroslav Gevorkov <yaroslav.gevorkov@desy.de> * @@ -46,6 +46,7 @@ struct index_args; #include "peaks.h" #include "image.h" #include "im-asapo.h" +#include "predict-refine.h" /* Information about the indexing process which is common to all patterns */ @@ -73,6 +74,7 @@ struct index_args float wavelength_estimate; float clen_estimate; int n_threads; + int mille; /* Integration */ IntegrationMethod int_meth; @@ -115,7 +117,8 @@ extern void process_image(const struct index_args *iargs, struct pattern_args *pargs, Stream *st, int cookie, const char *tmpdir, int serial, struct sb_shm *sb_shared, char *last_task, - struct im_asapo *asapostuff); + struct im_asapo *asapostuff, + Mille *mille); #endif /* PROCESS_IMAGE_H */ |