aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-02-27 16:46:56 +0100
committerThomas White <taw@physics.org>2018-02-27 17:12:42 +0100
commit6e2bfae0ef6a56457d3a94afbfb1154a34d5ef94 (patch)
tree29be4112e20eb3b55780decc90f894b036206967
parent83eabebc964981d997561c2a3b97560e0ee9d5d9 (diff)
Move specgraph stuff to post-refinement.c
-rw-r--r--src/partialator.c76
-rw-r--r--src/post-refinement.c76
2 files changed, 76 insertions, 76 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 4e3cd5da..b708bd9f 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -657,79 +657,6 @@ static void write_to_pgraph(FILE *fh, RefList *list, RefList *full, Crystal *cr,
}
-static void write_specgraph(RefList *full, Crystal *crystal, signed int in,
- const char *suff)
-{
- FILE *fh;
- char tmp[256];
- Reflection *refl;
- RefListIterator *iter;
- double G = crystal_get_osf(crystal);
- double B = crystal_get_Bfac(crystal);
- UnitCell *cell;
- struct image *image = crystal_get_image(crystal);
- char ins[5];
-
- snprintf(tmp, 256, "specgraph%s.dat", suff);
-
- if ( in == 0 ) {
- fh = fopen(tmp, "w");
- } else {
- fh = fopen(tmp, "a");
- }
-
- if ( fh == NULL ) {
- ERROR("Failed to open '%s'\n", tmp);
- return;
- }
-
- 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) )
- {
- double corr, Ipart, Ifull, pobs, pcalc;
- double res;
- signed int h, k, l;
- Reflection *match;
-
- get_indices(refl, &h, &k, &l);
- res = resolution(cell, h, k, l);
-
- /* FIXME Free-flagged reflections only? */
-
- match = find_refl(full, h, k, l);
- if ( match == NULL ) continue;
-
- corr = G * exp(B*res*res) * get_lorentz(refl);
- Ipart = get_intensity(refl) * corr;
- Ifull = get_intensity(match);
- pobs = Ipart / Ifull;
- pcalc = get_partiality(refl);
-
- fprintf(fh, "%e %e %f %f %s\n", get_khalf(refl), 2.0*res,
- pcalc, pobs, ins);
-
- }
-
- fclose(fh);
-}
-
-
static void write_pgraph(RefList *full, Crystal **crystals, int n_crystals,
signed int iter, const char *suff)
{
@@ -1263,7 +1190,6 @@ int main(int argc, char *argv[])
check_rejection(crystals, n_crystals, full, max_B);
show_all_residuals(crystals, n_crystals, full);
write_pgraph(full, crystals, n_crystals, 0, "");
- write_specgraph(full, crystals[0], 0, "");
/* Iterate */
for ( i=0; i<n_iter; i++ ) {
@@ -1287,7 +1213,6 @@ int main(int argc, char *argv[])
check_rejection(crystals, n_crystals, full, max_B);
show_all_residuals(crystals, n_crystals, full);
write_pgraph(full, crystals, n_crystals, i+1, "");
- write_specgraph(full, crystals[0], i+1, "");
if ( output_everycycle ) {
@@ -1337,7 +1262,6 @@ int main(int argc, char *argv[])
/* Write final figures of merit (no rejection any more) */
show_all_residuals(crystals, n_crystals, full);
write_pgraph(full, crystals, n_crystals, -1, "");
- write_specgraph(full, crystals[0], -1, "");
STATUS("Final profile radius: %e\n", crystal_get_profile_radius(crystals[0]));
/* Output results */
diff --git a/src/post-refinement.c b/src/post-refinement.c
index b11ad57e..f94a46ee 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -485,6 +485,79 @@ void try_reindex(Crystal *crin, const RefList *full)
}
+static void write_specgraph(const RefList *full, Crystal *crystal, signed int in,
+ const char *suff)
+{
+ FILE *fh;
+ char tmp[256];
+ Reflection *refl;
+ RefListIterator *iter;
+ double G = crystal_get_osf(crystal);
+ double B = crystal_get_Bfac(crystal);
+ UnitCell *cell;
+ struct image *image = crystal_get_image(crystal);
+ char ins[5];
+
+ snprintf(tmp, 256, "pr-logs/specgraph%s.dat", suff);
+
+ if ( in == 0 ) {
+ fh = fopen(tmp, "w");
+ } else {
+ fh = fopen(tmp, "a");
+ }
+
+ if ( fh == NULL ) {
+ ERROR("Failed to open '%s'\n", tmp);
+ return;
+ }
+
+ 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) )
+ {
+ double corr, Ipart, Ifull, pobs, pcalc;
+ double res;
+ signed int h, k, l;
+ Reflection *match;
+
+ get_indices(refl, &h, &k, &l);
+ res = resolution(cell, h, k, l);
+
+ /* FIXME Free-flagged reflections only? */
+
+ match = find_refl(full, h, k, l);
+ if ( match == NULL ) continue;
+
+ corr = G * exp(B*res*res) * get_lorentz(refl);
+ Ipart = get_intensity(refl) * corr;
+ Ifull = get_intensity(match);
+ pobs = Ipart / Ifull;
+ pcalc = get_partiality(refl);
+
+ fprintf(fh, "%e %e %f %f %s\n", get_khalf(refl), 2.0*res,
+ pcalc, pobs, ins);
+
+ }
+
+ fclose(fh);
+}
+
+
static void do_pr_refine(Crystal *cr, const RefList *full,
PartialityModel pmodel, int verbose, int serial,
int cycle)
@@ -569,6 +642,9 @@ static void do_pr_refine(Crystal *cr, const RefList *full,
const enum gparam par1 = GPARAM_ANG1;
const enum gparam par2 = GPARAM_WAVELENGTH;
+ snprintf(fn, 63, "-crystal%i", serial);
+ write_specgraph(full, cr, cycle, fn);
+
snprintf(fn, 63, "pr-logs/grid-crystal%i-cycle%i.dat", serial, cycle);
fh = fopen(fn, "w");
if ( fh != NULL ) {