From 901c99a1dbe1b9f93b8ecc3bff7bc6b80cc59904 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 24 Jul 2014 15:43:13 +0200 Subject: Suspend indexing statistics while --int-diag is displaying --- libcrystfel/src/integration.c | 51 ++++++++++++++++++++++++++++++++----------- libcrystfel/src/integration.h | 8 +++++++ src/im-sandbox.c | 44 ++++++++++++++++++++++++++----------- src/process_image.c | 6 ++--- src/process_image.h | 6 ++--- tests/integration_check.c | 2 +- tests/prof2d_check.c | 2 +- 7 files changed, 85 insertions(+), 34 deletions(-) diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index a0d23d2d..f42da36f 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -337,13 +338,16 @@ static void show_reference_profile(struct intcontext *ic, int i) } -static void show_peak_box(struct intcontext *ic, struct peak_box *bx) +static void show_peak_box(struct intcontext *ic, struct peak_box *bx, + int results_pipe) { #ifdef HAVE_CURSES_COLOR int q; signed int h, k, l; double fs, ss; + if ( results_pipe != 0 ) write(results_pipe, "SUSPEND\n", 8); + initscr(); clear(); start_color(); @@ -402,6 +406,8 @@ static void show_peak_box(struct intcontext *ic, struct peak_box *bx) refresh(); getch(); endwin(); + + if ( results_pipe != 0 ) write(results_pipe, "RELEASE\n", 8); #endif } @@ -1345,7 +1351,8 @@ static int get_int_diag(struct intcontext *ic, Reflection *refl) -static void integrate_prof2d_once(struct intcontext *ic, struct peak_box *bx) +static void integrate_prof2d_once(struct intcontext *ic, struct peak_box *bx, + int results_pipe) { bx->intensity = fit_intensity(ic, bx); bx->sigma = calc_sigma(ic, bx); @@ -1375,7 +1382,8 @@ static void integrate_prof2d_once(struct intcontext *ic, struct peak_box *bx) set_redundancy(bx->refl, 0); } - if ( get_int_diag(ic, bx->refl) ) show_peak_box(ic, bx); + if ( get_int_diag(ic, bx->refl) ) show_peak_box(ic, bx, + results_pipe); } else { @@ -1467,7 +1475,8 @@ static void setup_profile_boxes(struct intcontext *ic, RefList *list) static void integrate_prof2d(IntegrationMethod meth, PartialityModel pmodel, Crystal *cr, struct image *image, IntDiag int_diag, signed int idh, signed int idk, signed int idl, - double ir_inn, double ir_mid, double ir_out) + double ir_inn, double ir_mid, double ir_out, + int results_pipe) { RefList *list; UnitCell *cell; @@ -1512,7 +1521,7 @@ static void integrate_prof2d(IntegrationMethod meth, PartialityModel pmodel, for ( i=0; ioffs_ss; set_detector_pos(refl, 0.0, pfs, pss); - if ( get_int_diag(ic, refl) ) show_peak_box(ic, bx); + if ( get_int_diag(ic, refl) ) show_peak_box(ic, bx, results_pipe); if ( intensity < -5.0*sigma ) { ic->n_implausible++; @@ -1722,7 +1732,8 @@ static double estimate_resolution(UnitCell *cell, ImageFeatureList *flist) static void integrate_rings(IntegrationMethod meth, PartialityModel pmodel, Crystal *cr, struct image *image, IntDiag int_diag, signed int idh, signed int idk, signed int idl, - double ir_inn, double ir_mid, double ir_out) + double ir_inn, double ir_mid, double ir_out, + int results_pipe) { RefList *list; Reflection *refl; @@ -1761,7 +1772,7 @@ static void integrate_rings(IntegrationMethod meth, PartialityModel pmodel, refl != NULL; refl = next_refl(refl, iter) ) { - integrate_rings_once(refl, image, &ic, cell); + integrate_rings_once(refl, image, &ic, cell, results_pipe); } //refine_rigid_groups(&ic); @@ -1799,11 +1810,12 @@ static void apply_resolution_cutoff(Crystal *cr, double res) } -void integrate_all_3(struct image *image, IntegrationMethod meth, +void integrate_all_4(struct image *image, IntegrationMethod meth, PartialityModel pmodel, double push_res, double ir_inn, double ir_mid, double ir_out, IntDiag int_diag, - signed int idh, signed int idk, signed int idl) + signed int idh, signed int idk, signed int idl, + int results_pipe) { int i; @@ -1820,7 +1832,8 @@ void integrate_all_3(struct image *image, IntegrationMethod meth, case INTEGRATION_RINGS : integrate_rings(meth, pmodel, cr, image, int_diag, idh, idk, idl, - ir_inn, ir_mid, ir_out); + ir_inn, ir_mid, ir_out, + results_pipe); res = estimate_resolution(crystal_get_cell(cr), image->features); break; @@ -1828,7 +1841,8 @@ void integrate_all_3(struct image *image, IntegrationMethod meth, case INTEGRATION_PROF2D : integrate_prof2d(meth, pmodel, cr, image, int_diag, idh, idk, idl, - ir_inn, ir_mid, ir_out); + ir_inn, ir_mid, ir_out, + results_pipe); res = estimate_resolution(crystal_get_cell(cr), image->features); break; @@ -1848,6 +1862,17 @@ void integrate_all_3(struct image *image, IntegrationMethod meth, } +void integrate_all_3(struct image *image, IntegrationMethod meth, + PartialityModel pmodel, double push_res, + double ir_inn, double ir_mid, double ir_out, + IntDiag int_diag, + signed int idh, signed int idk, signed int idl) +{ + integrate_all_4(image, meth, pmodel, 0.0, ir_inn, ir_mid, ir_out, + int_diag, idh, idk, idl, 0); +} + + void integrate_all_2(struct image *image, IntegrationMethod meth, double push_res, double ir_inn, double ir_mid, double ir_out, diff --git a/libcrystfel/src/integration.h b/libcrystfel/src/integration.h index f077be32..9e1c8ee1 100644 --- a/libcrystfel/src/integration.h +++ b/libcrystfel/src/integration.h @@ -105,6 +105,14 @@ extern void integrate_all_3(struct image *image, IntegrationMethod meth, IntDiag int_diag, signed int idh, signed int idk, signed int idl); +extern void integrate_all_4(struct image *image, IntegrationMethod meth, + PartialityModel pmodel, double push_res, + double ir_inn, double ir_mid, double ir_out, + IntDiag int_diag, + signed int idh, signed int idk, signed int idl, + int results_pipe); + + #ifdef __cplusplus } #endif diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 3e2ab2b3..7305dfd4 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -3,13 +3,13 @@ * * Sandbox for indexing * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2013 Thomas White + * 2010-2014 Thomas White * 2011 Richard Kirian * 2012 Lorenzo Galli * 2012 Chunhong Yoon @@ -90,6 +90,7 @@ struct sandbox int n_hadcrystals_last_stats; int n_crystals_last_stats; int t_last_stats; + int suspend_stats; struct index_args *iargs; @@ -218,7 +219,8 @@ static void run_work(const struct index_args *iargs, pargs.filename = line; pargs.n_crystals = 0; - process_image(iargs, &pargs, st, cookie, tmpdir); + process_image(iargs, &pargs, st, cookie, tmpdir, + results_pipe); /* Request another image */ c = sprintf(buf, "%i\n", pargs.n_crystals); @@ -650,6 +652,7 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, sb->n_hadcrystals_last_stats = 0; sb->n_crystals_last_stats = 0; sb->t_last_stats = get_monotonic_seconds(); + sb->suspend_stats = 0; sb->n_proc = n_proc; sb->iargs = iargs; @@ -824,19 +827,32 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, chomp(results); - strtol(results, &eptr, 10); - if ( eptr == results ) { - if ( strlen(results) > 0 ) { - ERROR("Invalid result '%s'\n", results); + if ( strcmp(results, "SUSPEND") == 0 ) { + sb->suspend_stats++; + } else if ( strcmp(results, "RELEASE") == 0 ) { + if ( sb->suspend_stats > 0 ) { + sb->suspend_stats--; + } else { + ERROR("RELEASE before SUSPEND.\n"); } } else { - int nc = atoi(results); - sb->n_crystals += nc; - if ( nc > 0 ) { - sb->n_hadcrystals++; + strtol(results, &eptr, 10); + if ( eptr == results ) { + if ( strlen(results) > 0 ) { + ERROR("Invalid result '%s'\n", + results); + } + } else { + + int nc = atoi(results); + sb->n_crystals += nc; + if ( nc > 0 ) { + sb->n_hadcrystals++; + } + sb->n_processed++; + } - sb->n_processed++; } @@ -867,7 +883,9 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix, /* Update progress */ lock_sandbox(sb); tNow = get_monotonic_seconds(); - if ( tNow >= sb->t_last_stats+STATS_EVERY_N_SECONDS ) { + if ( !sb->suspend_stats + && (tNow >= sb->t_last_stats+STATS_EVERY_N_SECONDS) ) + { STATUS("%4i indexable out of %4i processed (%4.1f%%), " "%4i crystals so far. " diff --git a/src/process_image.c b/src/process_image.c index 4751073b..0ec058ac 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -51,7 +51,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, - Stream *st, int cookie, const char *tmpdir) + Stream *st, int cookie, const char *tmpdir, int results_pipe) { float *data_for_measurement; size_t data_size; @@ -184,10 +184,10 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Integrate all the crystals at once - need all the crystals so that * overlaps can be detected. */ - integrate_all_2(&image, iargs->int_meth, iargs->push_res, + integrate_all_4(&image, iargs->int_meth, PMODEL_SPHERE, iargs->push_res, iargs->ir_inn, iargs->ir_mid, iargs->ir_out, iargs->int_diag, iargs->int_diag_h, - iargs->int_diag_k, iargs->int_diag_l); + iargs->int_diag_k, iargs->int_diag_l, results_pipe); write_chunk(st, &image, hdfile, iargs->stream_peaks, iargs->stream_refls); diff --git a/src/process_image.h b/src/process_image.h index 1a8a9ff3..98228f6f 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -3,11 +3,11 @@ * * The processing pipeline for one image * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2013 Thomas White + * 2010-2014 Thomas White * * This file is part of CrystFEL. * @@ -97,7 +97,7 @@ struct pattern_args extern void process_image(const struct index_args *iargs, struct pattern_args *pargs, Stream *st, - int cookie, const char *tmpdir); + int cookie, const char *tmpdir, int results_pipe); #endif /* PROCESS_IMAGEs_H */ diff --git a/tests/integration_check.c b/tests/integration_check.c index 701d8be7..b5dbea67 100644 --- a/tests/integration_check.c +++ b/tests/integration_check.c @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) } setup_ring_masks(&ic, ir_inn, ir_mid, ir_out); - integrate_rings_once(refl, &image, &ic, cell); + integrate_rings_once(refl, &image, &ic, cell, 0); cell_free(cell); diff --git a/tests/prof2d_check.c b/tests/prof2d_check.c index 75b9748e..a1c89d36 100644 --- a/tests/prof2d_check.c +++ b/tests/prof2d_check.c @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) reflist_free(list); /* integrate_prof2d() will predict again */ integrate_prof2d(INTEGRATION_PROF2D, PMODEL_SPHERE, cr, &image, - INTDIAG_NONE, 0, 0, 0, ir_inn, ir_mid, ir_out); + INTDIAG_NONE, 0, 0, 0, ir_inn, ir_mid, ir_out, 0); list = crystal_get_reflections(cr); printf("Weak reflections:\n"); -- cgit v1.2.3