aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/partialator.15
-rw-r--r--src/partialator.c70
-rw-r--r--src/post-refinement.c24
-rw-r--r--src/post-refinement.h2
4 files changed, 47 insertions, 54 deletions
diff --git a/doc/man/partialator.1 b/doc/man/partialator.1
index decaa07c..980af00f 100644
--- a/doc/man/partialator.1
+++ b/doc/man/partialator.1
@@ -132,6 +132,11 @@ Reject crystals if the absolute values of their relative Debye-Waller ("B") fact
.PD
Write out the per-crystal parameters and reflection lists after every cycle of refinement, instead of only at the end. The intermediate reflection lists and parameter filenames will be prefixed with \fBiter\fIN\fB_\fR (note the trailing underscore), where \fIN\fR is the iteration number. If you use \fB--custom-split\fR, intermediate results will also be output for each custom dataset.
+.PD 0
+.IP \fB--no-logs\fR
+.PD
+Do not write the extensive log files needed for plotting contour maps and spectrum graphs. This makes the process a lot faster, but you probably do want these logs to check that post-refinement is working reasonably.
+
.SH PARTIALITY MODELS
The available partiality models are:
diff --git a/src/partialator.c b/src/partialator.c
index 760af036..d548e956 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -40,6 +40,7 @@
#include <assert.h>
#include <pthread.h>
#include <gsl/gsl_errno.h>
+#include <sys/stat.h>
#include <image.h>
#include <utils.h>
@@ -325,7 +326,8 @@ static void show_help(const char *s)
" -j <n> Run <n> analyses in parallel.\n"
" --no-free Disable cross-validation (testing only).\n"
" --custom-split List of files for custom dataset splitting.\n"
-" --max-rel-B Maximum allowable relative |B| factor.\n");
+" --max-rel-B Maximum allowable relative |B| factor.\n"
+" --no-logs Do not write extensive log files.\n");
}
@@ -738,35 +740,6 @@ static void show_all_residuals(Crystal **crystals, int n_crystals,
}
-static void dump_parameters(const char *filename, Crystal **crystals,
- int n_crystals)
-{
- FILE *fh;
- fh = fopen(filename, "w");
- if ( fh == NULL ) {
- ERROR("Couldn't open partialator.params!\n");
- } else {
- fprintf(fh, " cr OSF relB div"
- " flag filename event\n");
- int i;
- for ( i=0; i<n_crystals; i++ ) {
- struct image *img;
- char *evt_str;
- img = crystal_get_image(crystals[i]);
- evt_str = get_event_string(img->event);
- fprintf(fh, "%4i %10.5f %10.2f %8.5e %-25s %s %s\n",
- i, crystal_get_osf(crystals[i]),
- crystal_get_Bfac(crystals[i])*1e20,
- crystal_get_image(crystals[i])->div,
- str_prflag(crystal_get_user_flag(crystals[i])),
- img->filename, evt_str);
- free(evt_str);
- }
- fclose(fh);
- }
-}
-
-
struct log_qargs
{
int iter;
@@ -878,6 +851,7 @@ int main(int argc, char *argv[])
double max_B = 1e-18;
char *rfile = NULL;
RefList *reference = NULL;
+ int no_logs = 0;
/* Long options */
const struct option longopts[] = {
@@ -910,6 +884,7 @@ int main(int argc, char *argv[])
{"polarization", 0, &polarisation, 1}, /* compat */
{"no-free", 0, &no_free, 1},
{"output-every-cycle", 0, &output_everycycle, 1},
+ {"no-logs", 0, &no_logs, 1},
{0, 0, NULL, 0}
};
@@ -1084,7 +1059,22 @@ int main(int argc, char *argv[])
if ( (pmodel == PMODEL_UNITY) && !no_pr ) {
no_pr = 1;
- STATUS("Setting --no-pr because we are not modelling partialities (--model=unity).\n");
+ STATUS("Setting --no-pr because we are not modelling "
+ "partialities (--model=unity).\n");
+ }
+
+ if ( !no_logs ) {
+ int r = mkdir("pr-logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ if ( r ) {
+ if ( errno == EEXIST ) {
+ ERROR("A folder called 'pr-logs' exists in the "
+ "working directory.\n");
+ ERROR("Please delete or move it first.\n");
+ } else {
+ ERROR("Failed to create pr-logs folder.\n");
+ }
+ return 1;
+ }
}
/* Read the custom split list (if applicable) */
@@ -1263,7 +1253,9 @@ 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, "");
- if ( !no_pr ) write_logs_parallel(crystals, n_crystals, full, 0, nthreads);
+ if ( !no_pr && !no_logs ) {
+ write_logs_parallel(crystals, n_crystals, full, 0, nthreads);
+ }
/* Iterate */
for ( i=0; i<n_iter; i++ ) {
@@ -1271,7 +1263,8 @@ int main(int argc, char *argv[])
STATUS("Scaling and refinement cycle %i of %i\n", i+1, n_iter);
if ( !no_pr ) {
- refine_all(crystals, n_crystals, full, nthreads, pmodel, 0, i+1);
+ refine_all(crystals, n_crystals, full, nthreads, pmodel,
+ 0, i+1, no_logs);
} else if ( !no_scale ) {
scale_all_to_reference(crystals, n_crystals, full, nthreads);
}
@@ -1313,10 +1306,6 @@ int main(int argc, char *argv[])
}
}
- /* Dump parameters */
- snprintf(tmp, 1024, "iter%.2d_partialator.params", i+1);
- dump_parameters(tmp, crystals, n_crystals);
-
}
}
@@ -1336,7 +1325,9 @@ 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, "");
- if ( !no_pr ) write_logs_parallel(crystals, n_crystals, full, -1, nthreads);
+ if ( !no_pr && !no_logs ) {
+ write_logs_parallel(crystals, n_crystals, full, -1, nthreads);
+ }
/* Output results */
STATUS("Writing overall results to %s\n", outfile);
@@ -1356,9 +1347,6 @@ int main(int argc, char *argv[])
}
}
- /* Dump parameters */
- dump_parameters("partialator.params", crystals, n_crystals);
-
/* Clean up */
gsl_rng_free(rng);
for ( i=0; i<n_crystals; i++ ) {
diff --git a/src/post-refinement.c b/src/post-refinement.c
index f2355756..1c33e211 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -3,11 +3,11 @@
*
* Post refinement
*
- * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2010-2017 Thomas White <taw@physics.org>
+ * 2010-2018 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -545,8 +545,6 @@ void write_specgraph(Crystal *crystal, const RefList *full,
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;
@@ -688,7 +686,7 @@ void write_gridscan(Crystal *cr, const RefList *full,
static void do_pr_refine(Crystal *cr, const RefList *full,
PartialityModel pmodel, int verbose, int serial,
- int cycle)
+ int cycle, int write_logs)
{
gsl_multimin_fminimizer *min;
struct rf_priv priv;
@@ -697,7 +695,6 @@ static void do_pr_refine(Crystal *cr, const RefList *full,
int r;
double G;
double residual_start, residual_free_start;
- int write_logs = 1;
FILE *fh = NULL;
try_reindex(cr, full);
@@ -710,8 +707,6 @@ static void do_pr_refine(Crystal *cr, const RefList *full,
residual_start, residual_free_start);
}
- if ( serial % 20 ) write_logs = 0;
-
min = setup_minimiser(cr, full, verbose, serial, &priv);
if ( verbose ) {
@@ -865,13 +860,13 @@ static void do_pr_refine(Crystal *cr, const RefList *full,
static struct prdata pr_refine(Crystal *cr, const RefList *full,
PartialityModel pmodel, int verbose, int serial,
- int cycle)
+ int cycle, int write_logs)
{
struct prdata prdata;
prdata.refined = 0;
- do_pr_refine(cr, full, pmodel, verbose, serial, cycle);
+ do_pr_refine(cr, full, pmodel, verbose, serial, cycle, write_logs);
if ( crystal_get_user_flag(cr) == 0 ) {
prdata.refined = 1;
@@ -890,6 +885,7 @@ struct refine_args
struct prdata prdata;
int verbose;
int cycle;
+ int no_logs;
};
@@ -907,9 +903,12 @@ static void refine_image(void *task, int id)
{
struct refine_args *pargs = task;
Crystal *cr = pargs->crystal;
+ int write_logs = 0;
+ write_logs = !pargs->no_logs && (pargs->serial % 20 == 0);
pargs->prdata = pr_refine(cr, pargs->full, pargs->pmodel,
- pargs->verbose, pargs->serial, pargs->cycle);
+ pargs->verbose, pargs->serial, pargs->cycle,
+ write_logs);
}
@@ -943,7 +942,7 @@ static void done_image(void *vqargs, void *task)
void refine_all(Crystal **crystals, int n_crystals,
RefList *full, int nthreads, PartialityModel pmodel,
- int verbose, int cycle)
+ int verbose, int cycle, int no_logs)
{
struct refine_args task_defaults;
struct queue_args qargs;
@@ -954,6 +953,7 @@ void refine_all(Crystal **crystals, int n_crystals,
task_defaults.prdata.refined = 0;
task_defaults.verbose = verbose;
task_defaults.cycle = cycle;
+ task_defaults.no_logs = no_logs;
qargs.task_defaults = task_defaults;
qargs.n_started = 0;
diff --git a/src/post-refinement.h b/src/post-refinement.h
index 13382623..3c4ac7ef 100644
--- a/src/post-refinement.h
+++ b/src/post-refinement.h
@@ -59,7 +59,7 @@ extern const char *str_prflag(enum prflag flag);
extern void refine_all(Crystal **crystals, int n_crystals,
RefList *full, int nthreads, PartialityModel pmodel,
- int verbose, int cycle);
+ int verbose, int cycle, int no_logs);
extern void write_gridscan(Crystal *cr, const RefList *full,
int cycle, int serial);