/* * hrs-scaling.c * * Intensity scaling using generalised HRS target function * * (c) 2006-2010 Thomas White * * Part of CrystFEL - crystallography with a FEL * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "image.h" #include "peaks.h" #include "symmetry.h" #include "geometry.h" #include "cell.h" static void show_matrix_eqn(gsl_matrix *M, gsl_vector *v, int r) { int i, j; for ( i=0; icpeaks; for ( h=0; hn_cpeaks; h++ ) { int g; double v_c, gr, I_full; hind = spots[h].h; kind = spots[h].k; lind = spots[h].l; /* Don't attempt to use spots with very small * partialities, since it won't be accurate. */ if ( spots[h].p < 0.1 ) continue; if ( integrate_peak(image, spots[h].x, spots[h].y, &xc, &yc, &I_partial, NULL, NULL, 1, 1) ) { continue; } get_asymm(hind, kind, lind, &ha, &ka, &la, sym); I_full = lookup_intensity(i_full, ha, ka, la); delta_I = I_partial - (spots[h].p * I_full / image->osf); for ( g=0; gprofile_radius) * gradient(image, k, spots[h], image->profile_radius); M_c *= pow(I_full, 2.0); gsl_matrix_set(M, g, k, M_curr + M_c); } gr = gradient(image, k, spots[h], image->profile_radius); v_c = delta_I * I_full * gr; gsl_vector_set(v, k, v_c); } } show_matrix_eqn(M, v, NUM_PARAMS); shifts = gsl_vector_alloc(NUM_PARAMS); gsl_linalg_HH_solve(M, v, shifts); for ( param=0; paramindexed_cell, n, 0); *pspots = spots; return mean_partial_dev(image, spots, *n, sym, i_full, NULL); #endif }