/* * rejection.c * * Crystal rejection for scaling * * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: * 2010-2015 Thomas White * * This file is part of CrystFEL. * * CrystFEL is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CrystFEL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with CrystFEL. If not, see . * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "crystal.h" #include "reflist.h" #include "rejection.h" #include "cell-utils.h" #include "post-refinement.h" static double mean_intensity(RefList *list) { Reflection *refl; RefListIterator *iter; double total = 0.0; int n = 0; for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) { total += get_intensity(refl); n++; } return total/n; } /* Reject really obvious outliers */ void early_rejection(Crystal **crystals, int n) { int i; double m = 0.0; double mean_m; FILE *fh = fopen("reject.dat", "w"); int n_flag = 0; for ( i=0; i crystal_get_resolution_limit(cr) ) continue; match = find_refl(full, h, k, l); if ( match == NULL ) continue; /* Calculated partiality */ pcalc = get_partiality(refl); /* Observed partiality */ corr = exp(-G) * exp(B*res*res) * get_lorentz(refl); Ipart = get_intensity(refl) * corr; pobs = Ipart / get_intensity(match); vec1[i] = pobs; vec2[i] = pcalc; i++; } cc = gsl_stats_correlation(vec1, 1, vec2, 1, i); //printf("%f\n", cc); if ( cc < 0.5 ) crystal_set_user_flag(cr, PRFLAG_CC); free(vec1); free(vec2); } static UNUSED void check_ccs(Crystal **crystals, int n_crystals, RefList *full) { int i; for ( i=0; i max_B ) { crystal_set_user_flag(crystals[i], PRFLAG_BIGB); } if ( crystal_get_user_flag(crystals[i]) == 0 ) n_acc++; } show_duds(crystals, n); if ( n_acc < 2 ) { ERROR("Not enough crystals left to proceed (%i). Sorry.\n", n_acc); exit(1); } }