aboutsummaryrefslogtreecommitdiff
path: root/src/partialator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/partialator.c')
-rw-r--r--src/partialator.c91
1 files changed, 82 insertions, 9 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 6d10bc37..86431e4c 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -199,12 +199,14 @@ static void write_split(Crystal **crystals, int n_crystals, const char *outfile,
STATUS("Writing two-way split to %s ", tmp);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
snprintf(tmp, 1024, "%s2", outfile);
split = merge_intensities(crystals2, n_crystals2, nthreads,
min_measurements, push_res, 1, 0);
STATUS("and %s\n", tmp);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
}
@@ -291,6 +293,7 @@ static void write_custom_split(struct custom_split *csplit, int dsn,
split = merge_intensities(crystalsn, n_crystalsn, nthreads,
min_measurements, push_res, 1, 0);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
write_split(crystalsn, n_crystalsn, tmp, nthreads, pmodel,
@@ -318,10 +321,12 @@ static void show_help(const char *s)
" --no-scale Disable scale factor (G, B) refinement.\n"
" --no-Bscale Disable B factor scaling.\n"
" --no-pr Disable orientation/physics refinement.\n"
+" --no-deltacchalf Disable rejection based on deltaCChalf.\n"
" -m, --model=<model> Specify partiality model.\n"
" --min-measurements=<n> Minimum number of measurements to require.\n"
" --no-polarisation Disable polarisation correction.\n"
" --max-adu=<n> Saturation value of detector.\n"
+" --min-res=<n> Merge only crystals which diffract above <n> A.\n"
" --push-res=<n> Merge higher than apparent resolution cutoff.\n"
" -j <n> Run <n> analyses in parallel.\n"
" --no-free Disable cross-validation (testing only).\n"
@@ -702,9 +707,15 @@ static void write_pgraph(RefList *full, Crystal **crystals, int n_crystals,
static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
double *presidual, double *pfree_residual,
- double *plog_residual, double *pfree_log_residual)
+ double *plog_residual, double *pfree_log_residual,
+ int *pn_used)
{
int i;
+ int n_used = 0;
+ int n_nan_linear = 0;
+ int n_nan_linear_free = 0;
+ int n_nan_log = 0;
+ int n_nan_log_free = 0;
*presidual = 0.0;
*pfree_residual = 0.0;
@@ -723,6 +734,11 @@ static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
log_r = log_residual(crystals[i], full, 0, NULL, NULL);
free_log_r = log_residual(crystals[i], full, 1, NULL, NULL);
+ if ( isnan(r) ) n_nan_linear++;
+ if ( isnan(free_r) ) n_nan_linear_free++;
+ if ( isnan(log_r) ) n_nan_log++;
+ if ( isnan(free_log_r) ) n_nan_log_free++;
+
if ( isnan(r) || isnan(free_r)
|| isnan(log_r) || isnan(free_log_r) ) continue;
@@ -730,7 +746,28 @@ static void all_residuals(Crystal **crystals, int n_crystals, RefList *full,
*pfree_residual += free_r;
*plog_residual += log_r;
*pfree_log_residual += free_log_r;
+
+ n_used++;
+ }
+
+ if ( n_nan_linear ) {
+ ERROR("WARNING: %i crystals had NaN linear residuals\n",
+ n_nan_linear);
+ }
+ if ( n_nan_linear_free ) {
+ ERROR("WARNING: %i crystals had NaN linear free residuals\n",
+ n_nan_linear_free);
+ }
+ if ( n_nan_log ) {
+ ERROR("WARNING: %i crystals had NaN log residuals\n",
+ n_nan_log);
}
+ if ( n_nan_log_free ) {
+ ERROR("WARNING: %i crystals had NaN log free residuals\n",
+ n_nan_log_free);
+ }
+
+ *pn_used = n_used;
}
@@ -738,13 +775,15 @@ static void show_all_residuals(Crystal **crystals, int n_crystals,
RefList *full)
{
double dev, free_dev, log_dev, free_log_dev;
+ int n;
all_residuals(crystals, n_crystals, full,
- &dev, &free_dev, &log_dev, &free_log_dev);
+ &dev, &free_dev, &log_dev, &free_log_dev, &n);
STATUS("Residuals:"
" linear linear free log log free\n");
STATUS(" ");
- STATUS("%15e %15e %15e %15e\n", dev, free_dev, log_dev, free_log_dev);
+ STATUS("%15e %15e %15e %15e (%i crystals)\n",
+ dev, free_dev, log_dev, free_log_dev, n);
}
@@ -875,6 +914,9 @@ int main(int argc, char *argv[])
double force_radius = -1.0;
char *audit_info;
int scaleflags = 0;
+ double min_res = 0.0;
+ int do_write_logs = 0;
+ int no_deltacchalf = 0;
/* Long options */
const struct option longopts[] = {
@@ -901,6 +943,7 @@ int main(int argc, char *argv[])
{"operator", 1, NULL, 9},
{"force-bandwidth", 1, NULL, 10},
{"force-radius", 1, NULL, 11},
+ {"min-res", 1, NULL, 12},
{"no-scale", 0, &no_scale, 1},
{"no-Bscale", 0, &no_Bscale, 1},
@@ -912,6 +955,7 @@ int main(int argc, char *argv[])
{"no-free", 0, &no_free, 1},
{"output-every-cycle", 0, &output_everycycle, 1},
{"no-logs", 0, &no_logs, 1},
+ {"no-deltacchalf", 0, &no_deltacchalf, 1},
{0, 0, NULL, 0}
};
@@ -1059,6 +1103,16 @@ int main(int argc, char *argv[])
force_radius *= 1e9;
break;
+ case 12 :
+ errno = 0;
+ min_res = strtod(optarg, &rval);
+ if ( *rval != '\0' ) {
+ ERROR("Invalid value for --min-res.\n");
+ return 1;
+ }
+ min_res = 1e10/min_res;
+ break;
+
case 0 :
break;
@@ -1159,7 +1213,14 @@ int main(int argc, char *argv[])
scaleflags |= SCALE_NO_B;
}
- if ( !no_logs ) {
+ /* Decide whether or not to create stuff in the pr-logs folder */
+ if ( !(no_logs || (no_pr && pmodel == PMODEL_UNITY)) ) {
+ do_write_logs = 1;
+ } else {
+ do_write_logs = 0;
+ }
+
+ if ( do_write_logs ) {
int r = mkdir("pr-logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if ( r ) {
if ( errno == EEXIST ) {
@@ -1170,6 +1231,12 @@ int main(int argc, char *argv[])
return 1;
}
}
+ } else {
+ struct stat s;
+ if ( stat("pr-logs", &s) != -1 ) {
+ ERROR("WARNING: pr-logs folder exists, but I will not "
+ "write anything in it with these settings.\n");
+ }
}
/* Read the custom split list (if applicable) */
@@ -1251,6 +1318,8 @@ int main(int argc, char *argv[])
n_crystals_seen++;
if ( n_crystals_seen <= start_after ) continue;
+ if ( crystal_get_resolution_limit(cur.crystals[i]) < min_res ) continue;
+
crystals_new = realloc(crystals,
(n_crystals+1)*sizeof(Crystal *));
if ( crystals_new == NULL ) {
@@ -1349,9 +1418,10 @@ int main(int argc, char *argv[])
}
/* Check rejection and write figures of merit */
- check_rejection(crystals, n_crystals, full, max_B);
+ check_rejection(crystals, n_crystals, full, max_B, no_deltacchalf);
show_all_residuals(crystals, n_crystals, full);
- if ( !no_pr && !no_logs ) {
+
+ if ( do_write_logs ) {
write_pgraph(full, crystals, n_crystals, 0, "");
write_logs_parallel(crystals, n_crystals, full, 0, nthreads,
scaleflags);
@@ -1369,6 +1439,7 @@ int main(int argc, char *argv[])
/* Create new reference if needed */
if ( reference == NULL ) {
+ free_contribs(full);
reflist_free(full);
if ( !no_scale ) {
scale_all(crystals, n_crystals, nthreads,
@@ -1379,10 +1450,10 @@ int main(int argc, char *argv[])
push_res, 1, 0);
} /* else full still equals reference */
- check_rejection(crystals, n_crystals, full, max_B);
+ check_rejection(crystals, n_crystals, full, max_B, no_deltacchalf);
show_all_residuals(crystals, n_crystals, full);
- if ( !no_logs ) {
+ if ( do_write_logs ) {
write_pgraph(full, crystals, n_crystals, i+1, "");
}
@@ -1417,6 +1488,7 @@ int main(int argc, char *argv[])
/* Final merge */
STATUS("Final merge...\n");
if ( reference == NULL ) {
+ free_contribs(full);
reflist_free(full);
if ( !no_scale ) {
scale_all(crystals, n_crystals, nthreads, scaleflags);
@@ -1431,7 +1503,7 @@ int main(int argc, char *argv[])
/* Write final figures of merit (no rejection any more) */
show_all_residuals(crystals, n_crystals, full);
- if ( !no_pr && !no_logs ) {
+ if ( do_write_logs ) {
write_pgraph(full, crystals, n_crystals, -1, "");
write_logs_parallel(crystals, n_crystals, full, -1, nthreads,
scaleflags);
@@ -1463,6 +1535,7 @@ int main(int argc, char *argv[])
reflist_free(crystal_get_reflections(crystals[i]));
crystal_free(crystals[i]);
}
+ free_contribs(full);
reflist_free(full);
free_symoplist(sym);
free(outfile);