From df26c722cdcc68f4b3dcc09976ad0075b8e65537 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 27 Feb 2018 16:48:23 +0100 Subject: partialator: Tidy up old log files, and add --no-logs --- src/partialator.c | 70 +++++++++++++++++++++------------------------------ src/post-refinement.c | 24 +++++++++--------- src/post-refinement.h | 2 +- 3 files changed, 42 insertions(+), 54 deletions(-) (limited to 'src') 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 #include #include +#include #include #include @@ -325,7 +326,8 @@ static void show_help(const char *s) " -j Run 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; ievent); - 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 + * 2010-2018 Thomas White * * 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); -- cgit v1.2.3