From 99849c8ed87a424a76e4826ed39ad65cacfaecfb Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 24 Apr 2023 16:52:16 +0200 Subject: indexamajig: Hooks for Mille --- libcrystfel/src/index.c | 18 +++++++++++++----- libcrystfel/src/index.h | 8 ++++++-- libcrystfel/src/predict-refine.c | 35 ++++++++++++++++++++++++++++++++--- libcrystfel/src/predict-refine.h | 9 ++++++++- 4 files changed, 59 insertions(+), 11 deletions(-) (limited to 'libcrystfel/src') 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,18 +921,25 @@ 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 + * 2010-2023 Thomas White * 2010 Richard Kirian * 2012 Lorenzo Galli * 2015 Kenneth Beyerlein @@ -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 + * 2010-2023 Thomas White * 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 +#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); -- cgit v1.2.3