From bd252a6897f3fe1d626c3c23fc9b4b62288f1bb2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 27 Feb 2018 16:45:33 +0100 Subject: Combine pgraph and specgraph into one file for all iterations --- src/partialator.c | 76 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 23 deletions(-) (limited to 'src/partialator.c') diff --git a/src/partialator.c b/src/partialator.c index 45098aee..f4a4bfb7 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -604,13 +604,22 @@ static void select_free_reflections(RefList *list, gsl_rng *rng) static void write_to_pgraph(FILE *fh, RefList *list, RefList *full, Crystal *cr, - int fr) + int fr, int inum) { Reflection *refl; RefListIterator *iter; double G = crystal_get_osf(cr); double B = crystal_get_Bfac(cr); UnitCell *cell = crystal_get_cell(cr); + char ins[5]; + + if ( inum >= 0 ) { + snprintf(ins, 4, "%i", inum); + } else { + ins[0] = 'F'; + ins[1] = '\0'; + } + for ( refl = first_refl(list, &iter); refl != NULL; @@ -641,8 +650,8 @@ static void write_to_pgraph(FILE *fh, RefList *list, RefList *full, Crystal *cr, Ipart = get_intensity(refl) * corr; pobs = Ipart / get_intensity(match); - fprintf(fh, "%5i %4i %4i %4i %8.4f %8.3f %8.3f\n", - fr, h, k, l, 2*res/1e9, pcalc, pobs); + fprintf(fh, "%5i %4i %4i %4i %e %8.3f %8.3f %s\n", + fr, h, k, l, 2*res, pcalc, pobs, ins); } } @@ -658,22 +667,36 @@ static void write_specgraph(RefList *full, Crystal *crystal, int in) double B = crystal_get_Bfac(crystal); UnitCell *cell; struct image *image = crystal_get_image(crystal); + char ins[5]; - snprintf(tmp, 256, "specgraph-iter%i.dat", in); + snprintf(tmp, 256, "specgraph%s.dat", suff); + + if ( in == 0 ) { + fh = fopen(tmp, "w"); + } else { + fh = fopen(tmp, "a"); + } - fh = fopen(tmp, "w"); if ( fh == NULL ) { ERROR("Failed to open '%s'\n", tmp); return; } - fprintf(fh, "Image: %s %s\n", - image->filename, get_event_string(image->event)); - - fprintf(fh, "khalf/m pcalc pobs\n"); + if ( in == 0 ) { + fprintf(fh, "Image: %s %s\n", + image->filename, get_event_string(image->event)); + fprintf(fh, "khalf/m 1/d(m) pcalc pobs iteration\n"); + } cell = crystal_get_cell(crystal); + if ( in >= 0 ) { + snprintf(ins, 4, "%i", in); + } else { + ins[0] = 'F'; + ins[1] = '\0'; + } + for ( refl = first_refl(crystal_get_reflections(crystal), &iter); refl != NULL; refl = next_refl(refl, iter) ) @@ -686,7 +709,7 @@ static void write_specgraph(RefList *full, Crystal *crystal, int in) get_indices(refl, &h, &k, &l); res = resolution(cell, h, k, l); - /* FIXME Free-flagged reflections only */ + /* FIXME Free-flagged reflections only? */ match = find_refl(full, h, k, l); if ( match == NULL ) continue; @@ -697,7 +720,8 @@ static void write_specgraph(RefList *full, Crystal *crystal, int in) pobs = Ipart / Ifull; pcalc = get_partiality(refl); - fprintf(fh, "%e %f %f\n", get_khalf(refl), pcalc, pobs); + fprintf(fh, "%e %e %f %f %s\n", get_khalf(refl), 2.0*res, + pcalc, pobs, ins); } @@ -706,30 +730,36 @@ static void write_specgraph(RefList *full, Crystal *crystal, int in) static void write_pgraph(RefList *full, Crystal **crystals, int n_crystals, - int iter) + int iter, const char *suff) { FILE *fh; char tmp[256]; int i; - snprintf(tmp, 256, "pgraph-iter%i.dat", iter); + snprintf(tmp, 256, "pgraph%s.dat", suff); + + if ( iter == 0 ) { + fh = fopen(tmp, "w"); + } else { + fh = fopen(tmp, "a"); + } - fh = fopen(tmp, "w"); if ( fh == NULL ) { ERROR("Failed to open '%s'\n", tmp); return; } - fprintf(fh, " fr h k l 1/d(nm) pcalc pobs\n"); + if ( iter == 0 ) { + fprintf(fh, " Crystal h k l 1/d(m) pcalc pobs iteration\n"); + } for ( i=0; i