From cccd318f5c1e1d18c42456d2ffa662e07d38f434 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 28 Oct 2016 17:06:07 +0200 Subject: partialator: Don't write a dataset if it contains no crystals --- src/partialator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/partialator.c b/src/partialator.c index b246571d..3f9f91f6 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -274,6 +274,12 @@ static void write_custom_split(struct custom_split *csplit, int dsn, tmp = insert_into_filename(outfile, csplit->dataset_names[dsn]); + if ( n_crystalsn == 0 ) { + ERROR("Not writing dataset '%s' because it contains no " + "crystals\n", csplit->dataset_names[dsn]); + return; + } + STATUS("Writing dataset '%s' to %s (%i crystals)\n", csplit->dataset_names[dsn], tmp, n_crystalsn); split = merge_intensities(crystalsn, n_crystalsn, nthreads, -- cgit v1.2.3 From 775bbc2d0081978f05d9fa35175bd82cf34c3c40 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 28 Oct 2016 17:06:35 +0200 Subject: partialator: Show some useful numbers about csplit datasets --- src/partialator.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/partialator.c b/src/partialator.c index 3f9f91f6..9f50620b 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -323,6 +323,101 @@ static void show_help(const char *s) } +static signed int find_first_crystal(Crystal **crystals, int n_crystals, + struct custom_split *csplit, int dsn) +{ + int i; + + for ( i=0; ifilename; + ev = crystal_get_image(crystals[i])->event; + evs = get_event_string(ev); + + id = malloc(strlen(evs)+strlen(fn)+2); + if ( id == NULL ) { + ERROR("Failed to allocate ID\n"); + return -1; + } + strcpy(id, fn); + strcat(id, " "); + strcat(id, evs); + dsn_crystal = find_dsn_for_id(csplit, id); + free(id); + + if ( dsn == dsn_crystal ) return i; + } + return -1; +} + + +static void check_csplit(Crystal **crystals, int n_crystals, + struct custom_split *csplit) +{ + int i; + int n_nosplit = 0; + int n_split = 0; + int n_cry = 0; + int n_nocry = 0; + + STATUS("Checking your custom split datasets...\n"); + + for ( i=0; ifilename; + ev = crystal_get_image(crystals[i])->event; + evs = get_event_string(ev); + + id = malloc(strlen(evs)+strlen(fn)+2); + if ( id == NULL ) { + ERROR("Failed to allocate ID\n"); + return; + } + strcpy(id, fn); + strcat(id, " "); + strcat(id, evs); + dsn_crystal = find_dsn_for_id(csplit, id); + free(id); + if ( dsn_crystal == -1 ) { + n_nosplit++; + } else { + n_split++; + } + + } + + for ( i=0; in_datasets; i++ ) { + + /* Try to find a crystal with dsn = i */ + if ( find_first_crystal(crystals, n_crystals, csplit, i) != -1 ) + { + n_cry++; + } else { + n_nocry++; + STATUS("Dataset %s has no crystals.\n", + csplit->dataset_names[i]); + } + } + + STATUS("Please check that these numbers match your expectations:\n"); + STATUS(" Number of crystals assigned to a dataset: %i\n", n_split); + STATUS("Number of crystals with no dataset asssigned: %i\n", n_nosplit); + STATUS("Number of datasets with at least one crystal: %i\n", n_cry); + STATUS(" Number of datasets with no crystals: %i\n", n_nocry); +} + + static struct custom_split *load_custom_split(const char *filename) { struct custom_split *csplit; @@ -1040,6 +1135,8 @@ int main(int argc, char *argv[]) } } + check_csplit(crystals, n_crystals, csplit); + /* Make a first pass at cutting out crap */ STATUS("Checking patterns.\n"); //early_rejection(crystals, n_crystals); -- cgit v1.2.3 From c4a9925905abc1108b33057240b17913de2e671a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Nov 2016 13:35:15 +0100 Subject: Add (more) warnings about unique axes --- libcrystfel/src/symmetry.c | 21 ++++++++++++++++++--- libcrystfel/src/symmetry.h | 8 +++++--- src/ambigator.c | 2 ++ src/get_hkl.c | 3 +++ src/partialator.c | 1 + src/pattern_sim.c | 1 + src/process_hkl.c | 1 + src/render_hkl.c | 1 + 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/libcrystfel/src/symmetry.c b/libcrystfel/src/symmetry.c index 503078a7..d675fb30 100644 --- a/libcrystfel/src/symmetry.c +++ b/libcrystfel/src/symmetry.c @@ -3,12 +3,12 @@ * * Symmetry * - * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2014 Thomas White - * 2014 Kenneth Beyerlein + * 2010-2014,2016 Thomas White + * 2014 Kenneth Beyerlein * * This file is part of CrystFEL. * @@ -1088,6 +1088,21 @@ SymOpList *get_pointgroup(const char *sym) } +void pointgroup_warning(const char *sym) +{ + if ( (strcmp(sym, "m") == 0) + || (strcmp(sym, "2/m") == 0) + || (strcmp(sym, "2") == 0) ) + { + ERROR("WARNING: You have specified a monoclinic point group " + "without a unique axis. The default unique axis is 'c'. " + "If you want unique axis b, append '_uab' to your point " + "group.\n"); + } + +} + + static void do_op(const IntegerMatrix *op, signed int h, signed int k, signed int l, signed int *he, signed int *ke, signed int *le) diff --git a/libcrystfel/src/symmetry.h b/libcrystfel/src/symmetry.h index c29164ef..a61ca96f 100644 --- a/libcrystfel/src/symmetry.h +++ b/libcrystfel/src/symmetry.h @@ -3,12 +3,12 @@ * * Symmetry * - * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2014 Thomas White - * 2014 Kenneth Beyerlein + * 2010-2014,2016 Thomas White + * 2014 Kenneth Beyerlein * * This file is part of CrystFEL. * @@ -90,6 +90,8 @@ extern void describe_symmetry(const SymOpList *s); extern int is_centric(signed int h, signed int k, signed int l, const SymOpList *ops); +extern void pointgroup_warning(const char *sym); + extern void add_symop(SymOpList *ops, IntegerMatrix *m); extern SymOpList *parse_symmetry_operations(const char *s); extern char *get_matrix_name(const IntegerMatrix *m, int row); diff --git a/src/ambigator.c b/src/ambigator.c index 659b17dc..f7837721 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -1099,6 +1099,7 @@ int main(int argc, char *argv[]) if ( s_sym_str == NULL ) { s_sym_str = strdup("1"); } + pointgroup_warning(s_sym_str); s_sym = get_pointgroup(s_sym_str); if ( s_sym == NULL ) return 1; free(s_sym_str); @@ -1113,6 +1114,7 @@ int main(int argc, char *argv[]) w_sym = NULL; amb = NULL; } else { + pointgroup_warning(w_sym_str); w_sym = get_pointgroup(w_sym_str); free(w_sym_str); if ( w_sym == NULL ) return 1; diff --git a/src/get_hkl.c b/src/get_hkl.c index 62c9e608..d6efe747 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -561,18 +561,21 @@ int main(int argc, char *argv[]) } if ( holo_str != NULL ) { + pointgroup_warning(holo_str); holo = get_pointgroup(holo_str); free(holo_str); } else { holo = NULL; } if ( mero_str != NULL ) { + pointgroup_warning(mero_str); mero = get_pointgroup(mero_str); free(mero_str); } else { mero = NULL; } if ( expand_str != NULL ) { + pointgroup_warning(expand_str); expand = get_pointgroup(expand_str); free(expand_str); } else { diff --git a/src/partialator.c b/src/partialator.c index 9f50620b..03eaee50 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -962,6 +962,7 @@ int main(int argc, char *argv[]) } if ( sym_str == NULL ) sym_str = strdup("1"); + pointgroup_warning(sym_str); sym = get_pointgroup(sym_str); free(sym_str); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index c60b3280..e1e04789 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -533,6 +533,7 @@ int main(int argc, char *argv[]) } if ( sym_str == NULL ) sym_str = strdup("1"); + pointgroup_warning(sym_str); sym = get_pointgroup(sym_str); /* sym_str is used below */ diff --git a/src/process_hkl.c b/src/process_hkl.c index 29ef29a1..d2cf640b 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -692,6 +692,7 @@ int main(int argc, char *argv[]) } if ( sym_str == NULL ) sym_str = strdup("1"); + pointgroup_warning(sym_str); sym = get_pointgroup(sym_str); free(sym_str); diff --git a/src/render_hkl.c b/src/render_hkl.c index f9398c3d..b0dca996 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -914,6 +914,7 @@ int main(int argc, char *argv[]) if ( sym_str == NULL ) { sym_str = strdup("1"); } + pointgroup_warning(sym_str); sym = get_pointgroup(sym_str); free(sym_str); -- cgit v1.2.3 From 3a5eacd9262964210d44118a407e30b21157dfa2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 7 Nov 2016 16:12:01 +0100 Subject: render_hkl: Show max value, and improve documentation for --scale-top --- doc/man/render_hkl.1 | 5 +++++ src/render_hkl.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/doc/man/render_hkl.1 b/doc/man/render_hkl.1 index d78e3343..eadbba34 100644 --- a/doc/man/render_hkl.1 +++ b/doc/man/render_hkl.1 @@ -92,6 +92,11 @@ The raw numbers of observations of the reflections, without performing the corre .PP The default is \fB--weighting=I\fR. +.PD 0 +.IP \fB--scale-top=\fIn\fR +.PD +Force the top of the colour scale to correspond to a value of \fIn\fR. Any value you give for \fB--boost\fR will be ignored. + .PD 0 .IP \fB--colour-key\fR .PD diff --git a/src/render_hkl.c b/src/render_hkl.c index b0dca996..3996814a 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -90,6 +90,7 @@ static void show_help(const char *s) " rawcts : the raw number of measurements for the\n" " reflection (no 'epsilon' correction).\n" "\n" +" --scale-top= Manually set the top of the colour scale\n" " --res-ring= Draw a resolution ring at Angstroms.\n" " --highres= Render spots only up to Angstroms.\n" " --no-axes Do not draw reciprocal space axes.\n" @@ -477,7 +478,11 @@ static void render_za(UnitCell *cell, RefList *list, /* Use manual scale top if specified */ if ( scale_top > 0.0 ) { max_val = scale_top; + STATUS("Ignoring boost value (%f) because you used " + "--scale-top\n", boost); + boost = 1.0; } + STATUS("Top of colour scale = %e\n", max_val/boost); scale1 = ((double)wh-border) / (2.0*rmax); scale2 = ((double)ht-border) / (2.0*rmax); -- cgit v1.2.3 From 6f2696f7a15a3b2f0a8ed39ce23e77123b85d904 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 10 Nov 2016 10:47:55 +0100 Subject: Fix 2theta calculation in locate_peak_on_panel() The "improved" version of this, added by 9b1374999 along with the new spot position calculation for out-of-plane panels, actually assumes that the reflection is at the exact Bragg condition. This is not a valid assumption here. The difference is small (<0.5 px), but made the prediction refinement gradients completely wrong. --- libcrystfel/src/geometry.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 266d6267..5403325f 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -52,16 +52,15 @@ static int locate_peak_on_panel(double x, double y, double z, double k, struct panel *p, double *pfs, double *pss) { - double r2, ctt, tta, phi; + double ctt, tta, phi; gsl_vector *v; gsl_vector *t; gsl_matrix *M; double fs, ss, one_over_mu; /* Calculate 2theta (scattering angle) and azimuth (phi) */ - r2 = x*x + y*y + z*z; - ctt = 1.0 - r2 / (2.0*k*k); /* cos(2theta) */ - tta = acos(ctt); + tta = atan2(sqrt(x*x+y*y), k+z); + ctt = cos(tta); phi = atan2(y, x); /* Set up matrix equation */ -- cgit v1.2.3 From c664d718c86fd7d287d310514bc9bad05a0810fa Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 16 Nov 2016 10:46:58 +0100 Subject: partialator: Fix segfault when not using --custom-split Crash introduced by 775bbc2d. How silly of me. Thanks to Ken Beyerlein for fixing this. --- src/partialator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partialator.c b/src/partialator.c index 03eaee50..30d265af 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -1136,7 +1136,7 @@ int main(int argc, char *argv[]) } } - check_csplit(crystals, n_crystals, csplit); + if (csplit != NULL) check_csplit(crystals, n_crystals, csplit); /* Make a first pass at cutting out crap */ STATUS("Checking patterns.\n"); -- cgit v1.2.3 From e8ea422d07198aad67f9bdc8b31b1cd421b278fd Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 24 Nov 2016 14:12:35 +0100 Subject: partialator: Fix counting of images --- src/partialator.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/partialator.c b/src/partialator.c index 30d265af..5b6ea2fb 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -756,7 +756,6 @@ int main(int argc, char *argv[]) int n_iter = 10; RefList *full; int n_images = 0; - int n_images_seen = 0; int n_crystals = 0; int n_crystals_seen = 0; char cmdline[1024]; @@ -1001,7 +1000,6 @@ int main(int argc, char *argv[]) /* Fill in what we know about the images so far */ n_images = 0; - n_images_seen = 0; n_crystals = 0; n_crystals_seen = 0; images = NULL; @@ -1049,8 +1047,6 @@ int main(int argc, char *argv[]) return 1; } - n_images_seen++; - for ( i=0; in_crystals; i++ ) { Crystal *cr; @@ -1103,9 +1099,7 @@ int main(int argc, char *argv[]) } - if ( n_crystals > 0 ) { - n_images++; - } + n_images++; if ( n_images % 100 == 0 ) { display_progress(n_images, n_crystals); -- cgit v1.2.3 From 6ef84c7d88c2b4882a0f781413d74b10951b907a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 25 Nov 2016 17:18:01 +0100 Subject: Display line numbers at which stream is corrupted --- libcrystfel/src/stream.c | 58 ++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 789a9d7a..e858172e 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -65,9 +65,11 @@ struct _stream int major_version; int minor_version; + + long long int ln; }; -static int read_peaks(FILE *fh, struct image *image) +static int read_peaks(Stream *st, struct image *image) { char *rval = NULL; int first = 1; @@ -82,7 +84,8 @@ static int read_peaks(FILE *fh, struct image *image) struct panel *p = NULL; float add_x, add_y; - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; if ( rval == NULL ) continue; chomp(line); @@ -126,7 +129,7 @@ static int read_peaks(FILE *fh, struct image *image) } -static int read_peaks_2_3(FILE *fh, struct image *image) +static int read_peaks_2_3(Stream *st, struct image *image) { char *rval = NULL; int first = 1; @@ -142,7 +145,8 @@ static int read_peaks_2_3(FILE *fh, struct image *image) struct panel *p = NULL; float add_x, add_y; - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; if ( rval == NULL ) continue; chomp(line); @@ -269,7 +273,7 @@ static int write_peaks_2_3(struct image *image, FILE *ofh) } -static RefList *read_stream_reflections_2_3(FILE *fh, struct detector *det) +static RefList *read_stream_reflections_2_3(Stream *st, struct detector *det) { char *rval = NULL; int first = 1; @@ -290,7 +294,8 @@ static RefList *read_stream_reflections_2_3(FILE *fh, struct detector *det) int r; Reflection *refl; - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; if ( rval == NULL ) continue; chomp(line); @@ -342,7 +347,7 @@ static RefList *read_stream_reflections_2_3(FILE *fh, struct detector *det) } -static RefList *read_stream_reflections_2_1(FILE *fh, struct detector *det) +static RefList *read_stream_reflections_2_1(Stream *st, struct detector *det) { char *rval = NULL; int first = 1; @@ -364,7 +369,8 @@ static RefList *read_stream_reflections_2_1(FILE *fh, struct detector *det) int r; Reflection *refl; - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; if ( rval == NULL ) continue; chomp(line); @@ -426,7 +432,7 @@ static RefList *read_stream_reflections_2_1(FILE *fh, struct detector *det) } -static RefList *read_stream_reflections_2_2(FILE *fh, struct detector *det) +static RefList *read_stream_reflections_2_2(Stream *st, struct detector *det) { char *rval = NULL; int first = 1; @@ -442,7 +448,8 @@ static RefList *read_stream_reflections_2_2(FILE *fh, struct detector *det) int r; Reflection *refl; - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; if ( rval == NULL ) continue; chomp(line); @@ -887,14 +894,15 @@ int write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, } -static int find_start_of_chunk(FILE *fh) +static int find_start_of_chunk(Stream *st) { char *rval = NULL; char line[1024]; do { - rval = fgets(line, 1023, fh); + rval = fgets(line, 1023, st->fh); + st->ln++; /* Trouble? */ if ( rval == NULL ) return 1; @@ -942,6 +950,7 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) char c; rval = fgets(line, 1023, st->fh); + st->ln++; /* Trouble? */ if ( rval == NULL ) break; @@ -975,7 +984,8 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) centering = c; have_cen = 1; } else { - ERROR("Duplicate centering ignored.\n"); + ERROR("Duplicate centering (line %lli) - " + "stream may be corrupted!\n", st->ln); } } @@ -986,7 +996,8 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) unique_axis = c; have_ua = 1; } else { - ERROR("Duplicate unique axis ignored.\n"); + ERROR("Duplicate unique axis (line %lli) - " + "stream may be corrupted!\n", st->ln); } } @@ -997,7 +1008,8 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) lattice_type = lattice_from_str(line+15); have_latt = 1; } else { - ERROR("Duplicate lattice type ignored.\n"); + ERROR("Duplicate lattice type (line %lli) - " + "stream may be corrupted!\n", st->ln); } } @@ -1030,13 +1042,13 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) /* The reflection list format in the stream diverges * after 2.2 */ if ( AT_LEAST_VERSION(st, 2, 3) ) { - reflist = read_stream_reflections_2_3(st->fh, + reflist = read_stream_reflections_2_3(st, image->det); } else if ( AT_LEAST_VERSION(st, 2, 2) ) { - reflist = read_stream_reflections_2_2(st->fh, + reflist = read_stream_reflections_2_2(st, image->det); } else { - reflist = read_stream_reflections_2_1(st->fh, + reflist = read_stream_reflections_2_1(st, image->det); } if ( reflist == NULL ) { @@ -1148,7 +1160,7 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf) int have_filename = 0; int have_ev = 0; - if ( find_start_of_chunk(st->fh) ) return 1; + if ( find_start_of_chunk(st) ) return 1; image->lambda = -1.0; image->features = NULL; @@ -1167,6 +1179,7 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf) float div, bw; rval = fgets(line, 1023, st->fh); + st->ln++; /* Trouble? */ if ( rval == NULL ) break; @@ -1257,9 +1270,9 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf) int fail; if ( AT_LEAST_VERSION(st, 2, 3) ) { - fail = read_peaks_2_3(st->fh, image); + fail = read_peaks_2_3(st, image); } else { - fail = read_peaks(st->fh, image); + fail = read_peaks(st, image); } if ( fail ) { ERROR("Failed while reading peaks\n"); @@ -1358,6 +1371,8 @@ Stream *open_stream_for_read(const char *filename) return NULL; } + st->ln = 1; + return st; } @@ -1656,6 +1671,7 @@ void write_geometry_file(Stream *st, const char *geom_filename) { */ int rewind_stream(Stream *st) { + st->ln = 0; return fseek(st->fh, 0, SEEK_SET); } -- cgit v1.2.3 From 7d1c7f5f3d6e6acb82c7677b29de150a0633dccf Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 8 Dec 2016 10:55:06 +0100 Subject: New polarisation correction --- libcrystfel/src/geometry.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 5403325f..b968dc06 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -636,25 +636,18 @@ void polarisation_correction(RefList *list, UnitCell *cell, struct image *image) refl != NULL; refl = next_refl(refl, iter) ) { - double pol, pa, pb, phi, tt, ool; + double pol; double intensity; - double xl, yl, zl; + double xl, yl; signed int h, k, l; + const double P = 1.0; /* degree of polarisation */ get_indices(refl, &h, &k, &l); - /* Polarisation correction assuming 100% polarisation - * along the x direction */ - xl = h*asx + k*bsx + l*csx; - yl = h*asy + k*bsy + l*csy; - zl = h*asz + k*bsz + l*csz; + xl = (h*asx + k*bsx + l*csx)*image->lambda; + yl = (h*asy + k*bsy + l*csy)*image->lambda; - ool = 1.0 / image->lambda; - tt = angle_between(0.0, 0.0, 1.0, xl, yl, zl+ool); - phi = atan2(yl, xl); - pa = pow(sin(phi)*sin(tt), 2.0); - pb = pow(cos(tt), 2.0); - pol = 1.0 - 2.0*(1.0-pa) + (1.0+pb); + pol = P*(1.0 - xl*xl) + (1.0-P)*(1.0 - yl*yl); intensity = get_intensity(refl); set_intensity(refl, intensity / pol); -- cgit v1.2.3 From 25418e68b5ba3ead044aaf4eed12eff51d65cb92 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 13 Dec 2016 11:24:48 +0100 Subject: Fix tests for new polarisation correction Actually, disable the polarisation correction in the tests. --- tests/first_merge_check | 4 ++-- tests/fourth_merge_check | 2 +- tests/second_merge_check | 4 ++-- tests/third_merge_check | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/first_merge_check b/tests/first_merge_check index bb1484bd..17b9f87b 100755 --- a/tests/first_merge_check +++ b/tests/first_merge_check @@ -38,10 +38,10 @@ cat > first_merge_check_ans.hkl << EOF CrystFEL reflection list version 2.0 Symmetry: 1 h k l I phase sigma(I) nmeas - 1 0 0 150.03 - 35.36 2 + 1 0 0 150.00 - 35.36 2 EOF -src/process_hkl -i first_merge_check.stream -o first_merge_check.hkl +src/process_hkl -i first_merge_check.stream -o first_merge_check.hkl --no-polarisation ex -c '/End of reflections/ .,$d x' first_merge_check.hkl diff --git a/tests/fourth_merge_check b/tests/fourth_merge_check index 1c738da7..b0935bc9 100755 --- a/tests/fourth_merge_check +++ b/tests/fourth_merge_check @@ -25,7 +25,7 @@ Symmetry: 1 h k l I phase sigma(I) nmeas EOF -src/process_hkl -i fourth_merge_check.stream -o fourth_merge_check.hkl +src/process_hkl -i fourth_merge_check.stream -o fourth_merge_check.hkl --no-polarisation ex -c '/End of reflections/ .,$d x' fourth_merge_check.hkl diff --git a/tests/second_merge_check b/tests/second_merge_check index ed2ba9f9..1283cb0a 100755 --- a/tests/second_merge_check +++ b/tests/second_merge_check @@ -38,10 +38,10 @@ cat > second_merge_check_ans.hkl << EOF CrystFEL reflection list version 2.0 Symmetry: -1 h k l I phase sigma(I) nmeas - 1 0 0 150.03 - 35.36 2 + 1 0 0 150.00 - 35.36 2 EOF -src/process_hkl -y -1 -i second_merge_check.stream -o second_merge_check.hkl +src/process_hkl -y -1 -i second_merge_check.stream -o second_merge_check.hkl --no-polarisation ex -c '/End of reflections/ .,$d x' second_merge_check.hkl diff --git a/tests/third_merge_check b/tests/third_merge_check index 714afb7f..d4f5f9ef 100755 --- a/tests/third_merge_check +++ b/tests/third_merge_check @@ -53,10 +53,10 @@ cat > third_merge_check_ans.hkl << EOF CrystFEL reflection list version 2.0 Symmetry: 1 h k l I phase sigma(I) nmeas - 1 0 0 133.36 - 27.22 3 + 1 0 0 133.33 - 27.22 3 EOF -src/process_hkl -i third_merge_check.stream -o third_merge_check.hkl +src/process_hkl -i third_merge_check.stream -o third_merge_check.hkl --no-polarisation ex -c '/End of reflections/ .,$d x' third_merge_check.hkl -- cgit v1.2.3 From 7dbbfa426b1569ebac2fcea8d74306db09fa5bcb Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 12 Jan 2017 14:24:55 +0100 Subject: indexamajig: Fix hanging on "Waiting for last patterns" --- src/im-sandbox.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 51cd5903..979fc136 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -3,13 +3,13 @@ * * Sandbox for indexing * - * Copyright © 2012-2016 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-2016 Thomas White + * 2010-2017 Thomas White * 2014 Valerio Mariani * 2011 Richard Kirian * 2012 Lorenzo Galli @@ -73,10 +73,17 @@ struct sandbox struct index_args *iargs; + /* Worker processes */ int n_proc; pid_t *pids; - int *running; + time_t *last_response; + + /* Streams to read from (NB not the same indices as the above) */ + int n_read; + FILE **fhs; + int *fds; + int serial; struct sb_shm *shared; @@ -84,14 +91,6 @@ struct sandbox char *tmpdir; - /* The last time each worker was heard from */ - time_t *last_response; - - /* Streams to read from */ - int n_read; - FILE **fhs; - int *fds; - /* Final output */ Stream *stream; }; @@ -131,7 +130,7 @@ static void check_hung_workers(struct sandbox *sb) { int i; time_t tnow = get_monotonic_seconds(); - for ( i=0; in_read; i++ ) { + for ( i=0; in_proc; i++ ) { if ( !sb->running[i] ) continue; if ( tnow - sb->last_response[i] > 240 ) { STATUS("Worker %i did not respond for 240 seconds - " -- cgit v1.2.3 From 7aea676ae486da8db04724d936241e7416ddd05f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 1 Feb 2017 14:30:23 +0100 Subject: partialator: Exit if point group is unrecognised --- src/partialator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/partialator.c b/src/partialator.c index 5b6ea2fb..09feebb4 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -964,6 +964,7 @@ int main(int argc, char *argv[]) pointgroup_warning(sym_str); sym = get_pointgroup(sym_str); free(sym_str); + if ( sym == NULL ) return 1; if ( pmodel_str != NULL ) { if ( strcmp(pmodel_str, "unity") == 0 ) { -- cgit v1.2.3 From cb5ad70ca8ba8796f276bad7e80f5cf345f00639 Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Wed, 5 Aug 2015 16:55:50 +0200 Subject: Change d_max according to the provided cell --- libcrystfel/src/asdf.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index df20f7ef..a8c8b0f3 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -322,6 +322,15 @@ static int compare_doubles(const void *a, const void *b) } +static double max(double a, double b, double c) +{ + double m = a; + if ( m < b ) m = b; + if ( m < c ) m = c; + return m; +} + + /* Compares tvectors by length */ static int compare_tvectors(const void *a, const void *b) { @@ -889,12 +898,14 @@ static int find_cell(struct tvector *tvectors, int N_tvectors, double IndexFit, return 0; } + void swap(int *a, int *b) { int c = *a; *a = *b; *b = c; } + /* Generate triplets of integers < N_reflections in random sequence */ static int **generate_triplets(int N_reflections, int N_triplets_max, int *N) { @@ -962,6 +973,7 @@ static int **generate_triplets(int N_reflections, int N_triplets_max, int *N) return triplets; } + static int index_refls(gsl_vector **reflections, int N_reflections, double d_max, double volume_min, double volume_max, double LevelFit, double IndexFit, int N_triplets_max, @@ -1094,7 +1106,7 @@ int run_asdf(struct image *image, IndexingPrivate *ipriv) double LevelFit = 1./1000; double IndexFit = 1./500; - double d_max = 220.; // thrice the maximum expected axis length + double d_max = 400.; // thrice the maximum expected axis length double volume_min = 100.; double volume_max = 1000000.; @@ -1103,6 +1115,12 @@ int run_asdf(struct image *image, IndexingPrivate *ipriv) struct asdf_private *dp = (struct asdf_private *)ipriv; if ( dp->indm & INDEXING_CHECK_CELL_AXES ) { + double a, b, c, gamma, beta, alpha; + cell_get_parameters(dp->template, &a, &b, &c, + &alpha, &beta, &gamma); + + d_max = max(a, b, c) * 3 * 1e10; + double volume = cell_get_volume(dp->template); double vtol = (dp->ltl[0] + dp->ltl[1] + dp->ltl[2]) / 100 + dp->ltl[3] / 180 * M_PI; -- cgit v1.2.3 From d03c456a838bdebf30e8b508885f0f0907618c00 Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Fri, 30 Oct 2015 11:55:30 +0100 Subject: Change volume_min, volume_max and d_max when indexing=asdf-comb --- libcrystfel/src/asdf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index a8c8b0f3..94d993cf 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -1106,15 +1106,16 @@ int run_asdf(struct image *image, IndexingPrivate *ipriv) double LevelFit = 1./1000; double IndexFit = 1./500; - double d_max = 400.; // thrice the maximum expected axis length + double d_max = 1000.; // thrice the maximum expected axis length double volume_min = 100.; - double volume_max = 1000000.; + double volume_max = 100000000.; int N_triplets_max = 10000; // maximum number of triplets struct asdf_private *dp = (struct asdf_private *)ipriv; - if ( dp->indm & INDEXING_CHECK_CELL_AXES ) { + if ( dp->indm & INDEXING_CHECK_CELL_AXES || + dp->indm & INDEXING_CHECK_CELL_COMBINATIONS) { double a, b, c, gamma, beta, alpha; cell_get_parameters(dp->template, &a, &b, &c, &alpha, &beta, &gamma); -- cgit v1.2.3 From 91ba89c68c263daaa7bd903cdf33de0b11c1642b Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Fri, 30 Oct 2015 13:39:53 +0100 Subject: Fix malloc fail due to integer overflow in N_triplets --- libcrystfel/src/asdf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index 94d993cf..bf2ce342 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -915,10 +915,13 @@ static int **generate_triplets(int N_reflections, int N_triplets_max, int *N) int N_triplets = N_reflections * (N_reflections - 1) * (N_reflections - 2) / 6; - if ( N_triplets > N_triplets_max ) N_triplets = N_triplets_max; + if ( N_triplets > N_triplets_max || N_reflections > 1000 ) { + N_triplets = N_triplets_max; + } *N = N_triplets; int **triplets = malloc(N_triplets * sizeof(int *)); + if (triplets == NULL) { ERROR("Failed to allocate triplets in generate_triplets!\n"); return 0; -- cgit v1.2.3 From c1cc621eae93e96184693d94f07c9a389aa14192 Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Fri, 26 Feb 2016 17:50:10 +0100 Subject: asdf.c: Divide volume constraints by number of lattice points per unit cell since asdf always finds primitive cell --- libcrystfel/src/asdf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index bf2ce342..9c917523 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -1128,8 +1128,18 @@ int run_asdf(struct image *image, IndexingPrivate *ipriv) double volume = cell_get_volume(dp->template); double vtol = (dp->ltl[0] + dp->ltl[1] + dp->ltl[2]) / 100 + dp->ltl[3] / 180 * M_PI; - volume_min = volume * (1 - vtol); - volume_max = volume * (1 + vtol); + + /* Divide volume constraints by number of lattice points per + * unit cell since asdf always finds primitive cell */ + int latt_points_per_uc = 1; + char centering = cell_get_centering(dp->template); + if ( centering == 'A' || + centering == 'B' || + centering == 'C' || + centering == 'I') latt_points_per_uc = 2; + + volume_min = volume * (1 - vtol)/latt_points_per_uc; + volume_max = volume * (1 + vtol)/latt_points_per_uc; } int n = image_feature_count(image->features); -- cgit v1.2.3 From dae4cf373c3cea2a3ccc4ea64aa9abca14e4feda Mon Sep 17 00:00:00 2001 From: Alexandra Tolstikova Date: Mon, 29 Feb 2016 13:56:03 +0100 Subject: asdf.c: Divide volume constraints by number of lattice points per unit cell. Add F centering --- libcrystfel/src/asdf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c index 9c917523..49917ad9 100644 --- a/libcrystfel/src/asdf.c +++ b/libcrystfel/src/asdf.c @@ -1136,7 +1136,8 @@ int run_asdf(struct image *image, IndexingPrivate *ipriv) if ( centering == 'A' || centering == 'B' || centering == 'C' || - centering == 'I') latt_points_per_uc = 2; + centering == 'I' ) latt_points_per_uc = 2; + else if ( centering == 'F' ) latt_points_per_uc = 4; volume_min = volume * (1 - vtol)/latt_points_per_uc; volume_max = volume * (1 + vtol)/latt_points_per_uc; -- cgit v1.2.3 From 526e5ab3d6fd21b8fe3c435f3984866c7e145a84 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 2 Feb 2017 10:40:20 +0100 Subject: cell_explorer: Fix labels once and for all --- src/cell_explorer.c | 77 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/src/cell_explorer.c b/src/cell_explorer.c index 914e4740..c8bbb069 100644 --- a/src/cell_explorer.c +++ b/src/cell_explorer.c @@ -3,11 +3,11 @@ * * Examine cell parameter histograms * - * Copyright © 2014 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. + * Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. * * Authors: - * 2014 Thomas White + * 2014,2017 Thomas White * * This file is part of CrystFEL. * @@ -270,6 +270,52 @@ static void draw_axis(cairo_t *cr, HistoBox *b, int width, int height) } +static void draw_label(cairo_t *cr, HistoBox *b, int width, int height) +{ + PangoLayout *layout; + PangoFontDescription *fontdesc; + PangoRectangle ext; + char label[256]; + double sz; + + layout = pango_cairo_create_layout(cr); + + if ( b->have_fit ) { + snprintf(label, 255, "%s = %.2f ± %.2f%s", + b->label, b->fit_b, b->fit_c/sqrt(2), b->units); + } else { + strncpy(label, b->label, 255); + } + pango_layout_set_text(layout, label, -1); + + sz = (height*PANGO_SCALE)/10.0; + + fontdesc = pango_font_description_new(); + pango_font_description_set_family_static(fontdesc, "Serif"); + pango_font_description_set_style(fontdesc, PANGO_STYLE_ITALIC); + pango_font_description_set_absolute_size(fontdesc, sz); + pango_layout_set_font_description(layout, fontdesc); + + /* If text is too wide for box, adjust the size so it fits */ + pango_layout_get_extents(layout, NULL, &ext); + if ( ext.width > PANGO_SCALE*(width-20.0) ) { + sz = ((double)PANGO_SCALE*(width-20.0) / ext.width)*sz; + pango_font_description_set_absolute_size(fontdesc, sz); + pango_layout_set_font_description(layout, fontdesc); + } + + + cairo_move_to(cr, 10.0, 10.0); + cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); + pango_cairo_update_layout(cr, layout); + pango_cairo_show_layout(cr, layout); + cairo_fill(cr); + + g_object_unref(layout); + pango_font_description_free(fontdesc); +} + + static gboolean draw_sig(GtkWidget *da, GdkEventExpose *event, HistoBox *b) { int width, height; @@ -431,24 +477,7 @@ static gboolean draw_sig(GtkWidget *da, GdkEventExpose *event, HistoBox *b) cairo_restore(cr); draw_axis(cr, b, width, height); - - cairo_text_extents_t ext; - char label[256]; - - cairo_select_font_face(cr, "Serif", CAIRO_FONT_SLANT_ITALIC, - CAIRO_FONT_WEIGHT_BOLD); - cairo_set_font_size(cr, height/10.0); - - if ( b->have_fit ) { - snprintf(label, 255, "%s = %.2f ± %.2f%s", - b->label, b->fit_b, b->fit_c/sqrt(2), b->units); - } else { - strncpy(label, b->label, 255); - } - - cairo_text_extents(cr, label, &ext); - cairo_move_to(cr, 10.0, 10.0+ext.height); - cairo_show_text(cr, label); + draw_label(cr, b, width, height); cairo_destroy(cr); @@ -1598,9 +1627,9 @@ int main(int argc, char *argv[]) w.cols_on[0] = 1; for ( i=1; i<8; i++ ) w.cols_on[i] = 2; - w.hist_a = histobox_new(&w, " A", "a"); - w.hist_b = histobox_new(&w, " A", "b"); - w.hist_c = histobox_new(&w, " A", "c"); + w.hist_a = histobox_new(&w, " Å", "a"); + w.hist_b = histobox_new(&w, " Å", "b"); + w.hist_c = histobox_new(&w, " Å", "c"); w.hist_al = histobox_new(&w, "°", "α"); w.hist_be = histobox_new(&w, "°", "β"); w.hist_ga = histobox_new(&w, "°", "γ"); -- cgit v1.2.3 From c7abdfb3e404a8a238e8352ea5e195f864efefd2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 5 Dec 2016 10:10:24 +0100 Subject: indexamajig: Add ping mechanism to avoid timing out when trying lots of indexers --- libcrystfel/src/index.c | 13 ++++++++++--- libcrystfel/src/index.h | 7 +++++-- src/im-sandbox.c | 12 ++++++++++++ src/im-sandbox.h | 5 +++-- src/process_image.c | 15 ++++++++++++--- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index c8c86414..a2fdb861 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -3,12 +3,12 @@ * * Perform indexing (somehow) * - * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2014 Thomas White + * 2010-2017 Thomas White * 2010-2011 Richard Kirian * 2012 Lorenzo Galli * 2013 Cornelius Gati @@ -421,9 +421,15 @@ static int finished_retry(IndexingMethod indm, int r, struct image *image) } } - void index_pattern(struct image *image, IndexingMethod *indms, IndexingPrivate **iprivs) +{ + index_pattern_2(image, indms, iprivs, NULL); +} + + +void index_pattern_2(struct image *image, IndexingMethod *indms, + IndexingPrivate **iprivs, int *ping) { int n = 0; ImageFeatureList *orig; @@ -452,6 +458,7 @@ void index_pattern(struct image *image, ntry++; done = finished_retry(indms[n], r, image); if ( ntry > 5 ) done = 1; + if ( ping != NULL ) (*ping)++; } while ( !done ); diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index 2fb5a13d..e5f7764a 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -3,13 +3,13 @@ * * Perform indexing (somehow) * - * Copyright © 2012-2016 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-2016 Thomas White + * 2010-2017 Thomas White * 2010 Richard Kirian * 2012 Lorenzo Galli * 2015 Kenneth Beyerlein @@ -154,6 +154,9 @@ extern IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, extern void index_pattern(struct image *image, IndexingMethod *indms, IndexingPrivate **iprivs); +extern void index_pattern_2(struct image *image, IndexingMethod *indms, + IndexingPrivate **iprivs, int *ping); + extern void cleanup_indexing(IndexingMethod *indms, IndexingPrivate **privs); #ifdef __cplusplus diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 979fc136..df8ed1e2 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -78,6 +78,7 @@ struct sandbox pid_t *pids; int *running; time_t *last_response; + int last_ping[MAX_NUM_WORKERS]; /* Streams to read from (NB not the same indices as the above) */ int n_read; @@ -123,6 +124,7 @@ static time_t get_monotonic_seconds() static void stamp_response(struct sandbox *sb, int n) { sb->last_response[n] = get_monotonic_seconds(); + sb->last_ping[n] = sb->shared->pings[n]; } @@ -131,13 +133,20 @@ static void check_hung_workers(struct sandbox *sb) int i; time_t tnow = get_monotonic_seconds(); for ( i=0; in_proc; i++ ) { + if ( !sb->running[i] ) continue; + + if ( sb->shared->pings[i] != sb->last_ping[i] ) { + stamp_response(sb, i); + } + if ( tnow - sb->last_response[i] > 240 ) { STATUS("Worker %i did not respond for 240 seconds - " "sending it SIGKILL.\n", i); kill(sb->pids[i], SIGKILL); stamp_response(sb, i); } + } } @@ -534,6 +543,9 @@ static void start_worker_process(struct sandbox *sb, int slot) return; } + sb->shared->pings[slot] = 0; + sb->last_ping[slot] = 0; + p = fork(); if ( p == -1 ) { ERROR("fork() failed!\n"); diff --git a/src/im-sandbox.h b/src/im-sandbox.h index b39f9566..b58e4b9e 100644 --- a/src/im-sandbox.h +++ b/src/im-sandbox.h @@ -3,13 +3,13 @@ * * Sandbox for indexing * - * 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 + * 2010-2017 Thomas White * 2011 Richard Kirian * 2012 Lorenzo Galli * 2012 Chunhong Yoon @@ -61,6 +61,7 @@ struct sb_shm char queue[QUEUE_SIZE][MAX_EV_LEN]; int no_more; char last_ev[MAX_NUM_WORKERS][MAX_EV_LEN]; + int pings[MAX_NUM_WORKERS]; pthread_mutex_t totals_lock; int n_processed; diff --git a/src/process_image.c b/src/process_image.c index 62ef732c..bcaee543 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -3,11 +3,11 @@ * * The processing pipeline for one image * - * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2015 Thomas White + * 2010-2017 Thomas White * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -124,6 +124,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, image.indexed_by = INDEXING_NONE; time_accounts_set(taccs, TACC_HDF5OPEN); + sb_shared->pings[cookie]++; hdfile = hdfile_open(image.filename); if ( hdfile == NULL ) { ERROR("Couldn't open file: %s\n", image.filename); @@ -131,6 +132,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, } time_accounts_set(taccs, TACC_HDF5READ); + sb_shared->pings[cookie]++; check = hdf5_read2(hdfile, &image, image.event, 0); if ( check ) { return; @@ -138,6 +140,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Take snapshot of image before applying horrible noise filters */ time_accounts_set(taccs, TACC_FILTER); + sb_shared->pings[cookie]++; prefilter = backup_image_data(image.dp, image.det); if ( iargs->median_filter > 0 ) { @@ -149,9 +152,11 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, } time_accounts_set(taccs, TACC_RESRANGE); + sb_shared->pings[cookie]++; mark_resolution_range_as_bad(&image, iargs->highres, +INFINITY); time_accounts_set(taccs, TACC_PEAKSEARCH); + sb_shared->pings[cookie]++; switch ( iargs->peaks ) { case PEAK_HDF5: @@ -214,7 +219,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Index the pattern */ time_accounts_set(taccs, TACC_INDEXING); - index_pattern(&image, iargs->indm, iargs->ipriv); + index_pattern_2(&image, iargs->indm, iargs->ipriv, + &sb_shared->pings[cookie]); r = chdir(rn); if ( r ) { @@ -247,6 +253,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Integrate! */ time_accounts_set(taccs, TACC_INTEGRATION); + sb_shared->pings[cookie]++; integrate_all_4(&image, iargs->int_meth, PMODEL_SCSPHERE, iargs->push_res, iargs->ir_inn, iargs->ir_mid, iargs->ir_out, @@ -255,6 +262,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, &sb_shared->term_lock); time_accounts_set(taccs, TACC_WRITESTREAM); + sb_shared->pings[cookie]++; ret = write_chunk(st, &image, hdfile, iargs->stream_peaks, iargs->stream_refls, pargs->filename_p_e->ev); @@ -274,6 +282,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, /* Count crystals which are still good */ time_accounts_set(taccs, TACC_TOTALS); + sb_shared->pings[cookie]++; pthread_mutex_lock(&sb_shared->totals_lock); any_crystals = 0; for ( i=0; i Date: Thu, 2 Feb 2017 11:36:14 +0100 Subject: Cannot use stamp_response() here We have a pipe index (0 to n_read), not a process index (0 to n_proc). These are two separate lists, with no correspondence between them. See 7dbbfa4 for another fix related to this issue. --- src/im-sandbox.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/im-sandbox.c b/src/im-sandbox.c index df8ed1e2..f5493453 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -524,7 +524,6 @@ static void try_read(struct sandbox *sb, TimeAccounts *taccs) /* If the chunk cannot be read, assume the connection * is broken and that the process will die soon. */ time_accounts_set(taccs, TACC_STREAMREAD); - stamp_response(sb, i); if ( pump_chunk(sb->fhs[i], ofd) ) { remove_pipe(sb, i); } -- cgit v1.2.3