diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ambigator.c | 7 | ||||
-rw-r--r-- | src/cell_explorer.c | 11 | ||||
-rw-r--r-- | src/check_hkl.c | 25 | ||||
-rw-r--r-- | src/compare_hkl.c | 81 | ||||
-rw-r--r-- | src/get_hkl.c | 43 | ||||
-rw-r--r-- | src/indexamajig.c | 24 | ||||
-rw-r--r-- | src/partial_sim.c | 46 | ||||
-rw-r--r-- | src/partialator.c | 5 | ||||
-rw-r--r-- | src/pattern_sim.c | 36 | ||||
-rw-r--r-- | src/render_hkl.c | 31 |
10 files changed, 210 insertions, 99 deletions
diff --git a/src/ambigator.c b/src/ambigator.c index f7837721..3df66f3b 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -1254,8 +1254,11 @@ int main(int argc, char *argv[]) return 1; } - fread(&seed, sizeof(seed), 1, fh); - gsl_rng_set(rng, seed); + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(rng, seed); + } else { + ERROR("Failed to seed RNG\n"); + } fclose(fh); } diff --git a/src/cell_explorer.c b/src/cell_explorer.c index a8a8a7dc..f3ec7cb7 100644 --- a/src/cell_explorer.c +++ b/src/cell_explorer.c @@ -1638,6 +1638,17 @@ int main(int argc, char *argv[]) fprintf(stderr, "\n"); + if ( stream_has_old_indexers(st) ) { + ERROR("----- Notice -----\n"); + ERROR("This stream contains indexing methods specified in an old way.\n"); + ERROR("The full indexing method names will not be shown by cell_explorer, \n"); + ERROR("only the methods themselves and prior information modifiers "); + ERROR("('cell' or 'latt').\n"); + ERROR("Similar indexing methods will be combined. For example\n"); + ERROR("'mosflm-raw' and 'mosflm-axes' will both show up as 'mosflm'\n"); + ERROR("To simplify matters, it's best to re-run indexamajig.\n"); + ERROR("------------------\n"); + } close_stream(st); w.cols_on[0] = 1; diff --git a/src/check_hkl.c b/src/check_hkl.c index c7afb6cc..3c71d4cc 100644 --- a/src/check_hkl.c +++ b/src/check_hkl.c @@ -3,11 +3,11 @@ * * Characterise reflection lists * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2016 Thomas White <taw@physics.org> + * 2010-2017 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -690,6 +690,7 @@ int main(int argc, char *argv[]) UnitCell *cell; char *file = NULL; char *sym_str = NULL; + char *sym_str_fromfile = NULL; SymOpList *sym; RefList *raw_list; RefList *list; @@ -838,12 +839,6 @@ int main(int argc, char *argv[]) "set!\n"); } - if ( sym_str == NULL ) { - sym_str = strdup("1"); - } - sym = get_pointgroup(sym_str); - free(sym_str); - file = strdup(argv[optind++]); if ( cellfile == NULL ) { @@ -857,13 +852,25 @@ int main(int argc, char *argv[]) } free(cellfile); - raw_list = read_reflections(file); + raw_list = read_reflections_2(file, &sym_str_fromfile); if ( raw_list == NULL ) { ERROR("Couldn't read file '%s'\n", file); return 1; } free(file); + if ( sym_str == NULL ) { + if ( sym_str_fromfile != NULL ) { + STATUS("Using symmetry from reflection file: %s\n", + sym_str_fromfile); + sym_str = sym_str_fromfile; + } else { + sym_str = strdup("1"); + } + } + sym = get_pointgroup(sym_str); + free(sym_str); + if ( shell_file == NULL ) shell_file = strdup("shells.dat"); /* Check that the intensities have the correct symmetry */ diff --git a/src/compare_hkl.c b/src/compare_hkl.c index 81f12c94..fd988b89 100644 --- a/src/compare_hkl.c +++ b/src/compare_hkl.c @@ -3,11 +3,11 @@ * * Compare reflection lists * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2010-2016 Thomas White <taw@physics.org> + * 2010-2017 Thomas White <taw@physics.org> * 2013 Lorenzo Galli <lorenzo.galli@desy.de> * * This file is part of CrystFEL. @@ -1124,6 +1124,9 @@ int main(int argc, char *argv[]) char *afile = NULL; char *bfile = NULL; char *sym_str = NULL; + char *sym_str_fromfile = NULL; + char *sym_str_fromfile1 = NULL; + char *sym_str_fromfile2 = NULL; SymOpList *sym; int ncom, nrej, nmul, nneg, nres, nbij, ncen; RefList *list1_acc; @@ -1320,8 +1323,53 @@ int main(int argc, char *argv[]) "set!\n"); } + afile = strdup(argv[optind++]); + bfile = strdup(argv[optind]); + + if ( shell_file == NULL ) shell_file = strdup("shells.dat"); + + cell = load_cell_from_file(cellfile); + if ( cellfile == NULL ) { + ERROR("You must provide a unit cell.\n"); + exit(1); + } + if ( cell == NULL ) { + ERROR("Failed to load cell.\n"); + return 1; + } + free(cellfile); + + list1_raw = read_reflections_2(afile, &sym_str_fromfile1); + if ( list1_raw == NULL ) { + ERROR("Couldn't read file '%s'\n", afile); + return 1; + } + + list2_raw = read_reflections_2(bfile, &sym_str_fromfile2); + if ( list2_raw == NULL ) { + ERROR("Couldn't read file '%s'\n", bfile); + return 1; + } + + if ( (sym_str_fromfile1 != NULL) && (sym_str_fromfile2 != NULL) ) { + if ( strcmp(sym_str_fromfile1, sym_str_fromfile2) != 0 ) { + ERROR("The symmetries of the two list do not match:\n"); + ERROR(" %s: %s\n", afile, sym_str_fromfile1); + ERROR(" %s: %s\n", bfile, sym_str_fromfile2); + return 1; + } + sym_str_fromfile = sym_str_fromfile1; + free(sym_str_fromfile2); + } + if ( sym_str == NULL ) { - sym_str = strdup("1"); + if ( sym_str_fromfile != NULL ) { + STATUS("Using symmetry from reflection files: %s\n", + sym_str_fromfile); + sym_str = sym_str_fromfile; + } else { + sym_str = strdup("1"); + } } sym = get_pointgroup(sym_str); free(sym_str); @@ -1354,33 +1402,6 @@ int main(int argc, char *argv[]) } } - afile = strdup(argv[optind++]); - bfile = strdup(argv[optind]); - - if ( shell_file == NULL ) shell_file = strdup("shells.dat"); - - cell = load_cell_from_file(cellfile); - if ( cellfile == NULL ) { - ERROR("You must provide a unit cell.\n"); - exit(1); - } - if ( cell == NULL ) { - ERROR("Failed to load cell.\n"); - return 1; - } - free(cellfile); - - list1_raw = read_reflections(afile); - if ( list1_raw == NULL ) { - ERROR("Couldn't read file '%s'\n", afile); - return 1; - } - - list2_raw = read_reflections(bfile); - if ( list2_raw == NULL ) { - ERROR("Couldn't read file '%s'\n", bfile); - return 1; - } /* Check that the intensities have the correct symmetry */ if ( check_list_symmetry(list1_raw, sym) ) { diff --git a/src/get_hkl.c b/src/get_hkl.c index 77f34da2..5dddc5be 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -3,11 +3,11 @@ * * Small program to manipulate reflection lists * - * Copyright © 2013-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2013-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2009-2016 Thomas White <taw@physics.org> + * 2009-2017 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -415,6 +415,7 @@ int main(int argc, char *argv[]) int config_nap = 1; char *holo_str = NULL; char *mero_str = NULL; + char *sym_str_fromfile = NULL; char *expand_str = NULL; SymOpList *holo = NULL; SymOpList *mero = NULL; @@ -569,13 +570,6 @@ int main(int argc, char *argv[]) } 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); @@ -590,6 +584,30 @@ int main(int argc, char *argv[]) set_symmetry_name(reindex, "Reindex"); } + input = read_reflections_2(input_file, &sym_str_fromfile); + if ( input == NULL ) { + ERROR("Problem reading input file %s\n", input_file); + return 1; + } + free(input_file); + + if ( mero_str == NULL ) { + if ( sym_str_fromfile != NULL ) { + STATUS("Using symmetry from reflection file: %s\n", + sym_str_fromfile); + mero_str = sym_str_fromfile; + } else { + mero_str = strdup("1"); + } + } + if ( mero_str != NULL ) { + pointgroup_warning(mero_str); + mero = get_pointgroup(mero_str); + free(mero_str); + } else { + mero = NULL; + } + if ( (expand != NULL) || (holo != NULL) || config_trimc || config_multi ) { if ( mero == NULL ) { @@ -597,13 +615,6 @@ int main(int argc, char *argv[]) } } - input = read_reflections(input_file); - if ( input == NULL ) { - ERROR("Problem reading input file %s\n", input_file); - return 1; - } - free(input_file); - STATUS("%i reflections in input.\n", num_reflections(input)); if ( (mero != NULL) && !config_trimc diff --git a/src/indexamajig.c b/src/indexamajig.c index 88b61563..04022441 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -924,17 +924,25 @@ int main(int argc, char *argv[]) } free(outfile); + if ( indm_str == NULL ) { + + STATUS("No indexing methods specified. I will try to "); + STATUS("automatically detect the available methods.\n"); + STATUS("To disable auto-detection of indexing methods, specify "); + STATUS("which methods to use with --indexing=<methods>.\n"); + STATUS("Use --indexing=none to disable indexing and integration.\n"); + indm_str = detect_indexing_methods(iargs.cell); + + } + /* 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"); - if ( iargs.cell != NULL ) { - STATUS("Ignoring your unit cell.\n"); - } - iargs.ipriv = NULL; + ERROR("No indexing method specified, and no usable indexing "); + ERROR("methods auto-detected.\n"); + ERROR("Install some indexing programs (mosflm,dirax etc), or "); + ERROR("try again with --indexing=none.\n"); + return 1; } else if ( strcmp(indm_str, "none") == 0 ) { diff --git a/src/partial_sim.c b/src/partial_sim.c index c5084955..2f0a0277 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -3,11 +3,11 @@ * * Generate partials for testing scaling * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: - * 2011-2016 Thomas White <taw@physics.org> + * 2011-2017 Thomas White <taw@physics.org> * 2014 Valerio Mariani * * This file is part of CrystFEL. @@ -763,23 +763,35 @@ int main(int argc, char *argv[]) } fixup_geom(det); - if ( sym_str == NULL ) sym_str = strdup("1"); - sym = get_pointgroup(sym_str); - free(sym_str); - if ( save_file == NULL ) save_file = strdup("partial_sim.hkl"); /* Load (full) reflections */ if ( input_file != NULL ) { RefList *as; + char *sym_str_fromfile = NULL; - full = read_reflections(input_file); + full = read_reflections_2(input_file, &sym_str_fromfile); if ( full == NULL ) { ERROR("Failed to read reflections from '%s'\n", input_file); return 1; } + + /* If we don't have a point group yet, and if the file provides + * one, use the one from the file */ + if ( (sym_str == NULL) && (sym_str_fromfile != NULL) ) { + sym_str = sym_str_fromfile; + STATUS("Using symmetry from reflection file: %s\n", + sym_str); + } + + /* If we still don't have a point group, use "1" */ + if ( sym_str == NULL ) sym_str = strdup("1"); + + pointgroup_warning(sym_str); + sym = get_pointgroup(sym_str); + if ( check_list_symmetry(full, sym) ) { ERROR("The input reflection list does not appear to" " have symmetry %s\n", symmetry_name(sym)); @@ -798,6 +810,8 @@ int main(int argc, char *argv[]) } else { random_intensities = 1; + if ( sym_str == NULL ) sym_str = strdup("1"); + sym = get_pointgroup(sym_str); } if ( n < 1 ) { @@ -852,10 +866,11 @@ int main(int argc, char *argv[]) noise_stddev); if ( random_intensities ) { STATUS(" Full intensities: randomly generated: " - "abs(Gaussian(sigma=%.2f))\n", full_stddev); + "abs(Gaussian(sigma=%.2f)), symmetry %s\n", + full_stddev, sym_str); } else { - STATUS(" Full intensities: from %s\n", - input_file); + STATUS(" Full intensities: from %s (symmetry %s)\n", + input_file, sym_str); } STATUS(" Max error in cell components: %.2f %%\n", cnoise); @@ -902,10 +917,13 @@ int main(int argc, char *argv[]) for ( i=0; i<n_threads; i++ ) { unsigned long int seed; - - fread(&seed, sizeof(seed), 1, fh); qargs.rngs[i] = gsl_rng_alloc(gsl_rng_mt19937); - gsl_rng_set(qargs.rngs[i], seed); + + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(qargs.rngs[i], seed); + } else { + ERROR("Failed to seed RNG %i\n", i); + } } @@ -931,7 +949,7 @@ int main(int argc, char *argv[]) if ( random_intensities ) { STATUS("Writing full intensities to %s\n", save_file); - write_reflist(save_file, full); + write_reflist_2(save_file, full, sym); } if ( phist_file != NULL ) { diff --git a/src/partialator.c b/src/partialator.c index 569145e8..142ca892 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -1018,7 +1018,10 @@ int main(int argc, char *argv[]) ERROR("Failed to open '%s'\n", sparams_fn); return 1; } - fgets(line, 1024, sparams_fh); + if ( fgets(line, 1024, sparams_fh) == NULL ) { + ERROR("Failed to read header from %s\n", sparams_fn); + return 1; + } STATUS("Reading initial scaling factors (G,B) from '%s'\n", sparams_fn); free(sparams_fn); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 347dd618..a3fea8e3 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -633,11 +633,6 @@ int main(int argc, char *argv[]) free(template_file); } - if ( sym_str == NULL ) sym_str = strdup("1"); - pointgroup_warning(sym_str); - sym = get_pointgroup(sym_str); - /* sym_str is used below */ - if ( grad_str == NULL ) { STATUS("You didn't specify a gradient calculation method, so" " I'm using the 'mosaic' method, which is fastest.\n"); @@ -720,16 +715,35 @@ int main(int argc, char *argv[]) phases = NULL; flags = NULL; + if ( sym_str == NULL ) sym_str = strdup("1"); + pointgroup_warning(sym_str); + sym = get_pointgroup(sym_str); + } else { RefList *reflections; + char *sym_str_fromfile = NULL; - reflections = read_reflections(intfile); + reflections = read_reflections_2(intfile, &sym_str_fromfile); if ( reflections == NULL ) { ERROR("Problem reading input file %s\n", intfile); return 1; } + /* If we don't have a point group yet, and if the file provides + * one, use the one from the file */ + if ( (sym_str == NULL) && (sym_str_fromfile != NULL) ) { + sym_str = sym_str_fromfile; + STATUS("Using symmetry from reflection file: %s\n", + sym_str); + } + + /* If we still don't have a point group, use "1" */ + if ( sym_str == NULL ) sym_str = strdup("1"); + + pointgroup_warning(sym_str); + sym = get_pointgroup(sym_str); + if ( grad == GRADIENT_PHASED ) { phases = phases_from_list(reflections); } else { @@ -785,9 +799,12 @@ int main(int argc, char *argv[]) FILE *fh; unsigned long int seed; fh = fopen("/dev/urandom", "r"); - fread(&seed, sizeof(seed), 1, fh); + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(rng, seed); + } else { + ERROR("Failed to seed random number generator\n"); + } fclose(fh); - gsl_rng_set(rng, seed); } powder.det = image.det; @@ -848,7 +865,8 @@ int main(int argc, char *argv[]) if ( intfile == NULL ) { STATUS(" Full intensities: all equal\n"); } else { - STATUS(" Full intensities: from %s\n", intfile); + STATUS(" Full intensities: from %s (symmetry %s)\n", + intfile, sym_str); } do { diff --git a/src/render_hkl.c b/src/render_hkl.c index 3996814a..3952940e 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -3,11 +3,11 @@ * * Draw pretty renderings of reflection lists * - * 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 <taw@physics.org> + * 2010-2017 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -757,6 +757,7 @@ int main(int argc, char *argv[]) int r = 0; double boost = 1.0; char *sym_str = NULL; + char *sym_str_fromfile = NULL; SymOpList *sym; char *weighting = NULL; int wght; @@ -916,13 +917,6 @@ int main(int argc, char *argv[]) return 1; } - if ( sym_str == NULL ) { - sym_str = strdup("1"); - } - pointgroup_warning(sym_str); - sym = get_pointgroup(sym_str); - free(sym_str); - if ( weighting == NULL ) { weighting = strdup("I"); } @@ -1003,11 +997,28 @@ int main(int argc, char *argv[]) ERROR("Couldn't load unit cell from %s\n", cellfile); return 1; } - list = read_reflections(infile); + + list = read_reflections_2(infile, &sym_str_fromfile); if ( list == NULL ) { ERROR("Couldn't read file '%s'\n", infile); return 1; } + + if ( sym_str == NULL ) { + if ( sym_str_fromfile != NULL ) { + STATUS("Using symmetry from reflection file: %s\n", + sym_str_fromfile); + sym_str = sym_str_fromfile; + } else { + sym_str = strdup("1"); + } + } + + pointgroup_warning(sym_str); + sym = get_pointgroup(sym_str); + if ( sym == NULL ) return 1; + free(sym_str); + if ( check_list_symmetry(list, sym) ) { ERROR("The input reflection list does not appear to" " have symmetry %s\n", symmetry_name(sym)); |