diff options
author | Thomas White <taw@physics.org> | 2023-07-11 16:08:46 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-07-11 16:49:52 +0200 |
commit | 1e6cb84f7ae14cb39b4ca5c0bc768399462ad2d0 (patch) | |
tree | 44b6a18d9fec3bf2f7e93c64906c9a8592405962 /src | |
parent | 2c934afed7299cf85b1d469040071f46d2fbcd57 (diff) |
partialator: Add --unmerged-output
Diffstat (limited to 'src')
-rw-r--r-- | src/merge.c | 61 | ||||
-rw-r--r-- | src/merge.h | 2 | ||||
-rw-r--r-- | src/partialator.c | 11 |
3 files changed, 74 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c index 20981ff8..0a5c5f14 100644 --- a/src/merge.c +++ b/src/merge.c @@ -484,3 +484,64 @@ double log_residual(Crystal *cr, const RefList *full, int free, if ( pn_used != NULL ) *pn_used = n_used; return dev; } + + +/* Has to match run_merge_job to be useful */ +void write_unmerged(const char *fn, Crystal **crystals, int n_crystals) +{ + FILE *fh; + int i; + + fh = fopen(fn, "w"); + if ( fh == NULL ) { + ERROR("Failed to open %s\n", fn); + return; + } + + for ( i=0; i<n_crystals; i++ ) { + + Reflection *refl; + RefListIterator *iter; + double G, B; + UnitCell *cell; + + fprintf(fh, "Crystal %i\n", i); + if ( crystal_get_user_flag(crystals[i]) ) { + fprintf(fh, "Flagged: yes\n"); + } else { + fprintf(fh, "Flagged: no\n"); + } + + G = crystal_get_osf(crystals[i]); + B = crystal_get_Bfac(crystals[i]); + cell = crystal_get_cell(crystals[i]); + + for ( refl = first_refl(crystal_get_reflections(crystals[i]), &iter); + refl != NULL; + refl = next_refl(refl, iter) ) + { + signed int h, k, l; + double res; + + get_indices(refl, &h, &k, &l); + res = resolution(cell, h, k, l); + fprintf(fh, "%4i %4i %4i %10.2f %10.2f", h, k, l, + correct_reflection(get_intensity(refl), refl, G, B, res), + get_partiality(refl) / correct_reflection_nopart(1.0, refl, G, B, res)); + + if ( get_partiality(refl) < MIN_PART_MERGE ) { + fprintf(fh, " partiality_too_small"); + } + if ( isnan(get_esd_intensity(refl)) ) { + fprintf(fh, " nan_esd"); + } + fprintf(fh, "\n"); + + } + + fprintf(fh, "\n"); + + } + + fclose(fh); +} diff --git a/src/merge.h b/src/merge.h index 1e193b62..5f7e0e64 100644 --- a/src/merge.h +++ b/src/merge.h @@ -59,4 +59,6 @@ extern double residual(Crystal *cr, const RefList *full, int free, extern double log_residual(Crystal *cr, const RefList *full, int free, int *pn_used, const char *filename); +extern void write_unmerged(const char *fn, Crystal **crystals, int n_crystals); + #endif /* MERGE */ diff --git a/src/partialator.c b/src/partialator.c index 39e8f8a3..9b1803b0 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -332,6 +332,7 @@ static void show_help(const char *s) " -i, --input=<filename> Specify the name of the input 'stream'.\n" " -o, --output=<filename> Output filename. Default: partialator.hkl.\n" " --output-every-cycle Write .hkl* and .params files in every cycle.\n" +" --unmerged-output=<f> Write unmerged (but scaled and corrected) intensities.\n" " -y, --symmetry=<sym> Merge according to symmetry <sym>.\n" " --start-after=<n> Skip <n> crystals at the start of the stream.\n" " --stop-after=<n> Stop after merging <n> crystals.\n" @@ -1068,6 +1069,7 @@ int main(int argc, char *argv[]) .streams = NULL}; char *outfile = NULL; char *sym_str = NULL; + char *unmerged_filename = NULL; SymOpList *sym; SymOpList *amb; SymOpList *w_sym; @@ -1151,6 +1153,7 @@ int main(int argc, char *argv[]) {"no-polarization", 0, NULL, 15}, /* compat */ {"harvest-file", 1, NULL, 16}, {"log-folder", 1, NULL, 17}, + {"unmerged-output", 1, NULL, 18}, {"no-scale", 0, &no_scale, 1}, {"no-Bscale", 0, &no_Bscale, 1}, @@ -1344,6 +1347,10 @@ int main(int argc, char *argv[]) log_folder = strdup(optarg); break; + case 18 : + unmerged_filename = strdup(optarg); + break; + case 0 : break; @@ -1790,6 +1797,10 @@ int main(int argc, char *argv[]) min_measurements, push_res, 1, 0); } + if ( unmerged_filename != NULL ) { + write_unmerged(unmerged_filename, crystals, n_crystals); + } + /* Write final figures of merit (no rejection any more) */ show_all_residuals(crystals, n_crystals, full, no_free); if ( do_write_logs ) { |