diff options
author | Thomas White <taw@physics.org> | 2017-02-02 15:08:59 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-02-02 15:08:59 +0100 |
commit | 6ece93b3ab590da9da08fdc42e8177ca64056145 (patch) | |
tree | 3de5cd3bc4d193a40d28d5c19cc4ca85dd53c3b0 /libcrystfel/src/geometry.c | |
parent | 2cefd4a8807d87cbe459c83d4b944d32ee38d2af (diff) | |
parent | 80b54c66c36c46a247d6d015be60ea9e73aa025f (diff) |
Merge branch 'master' into taketwo
Diffstat (limited to 'libcrystfel/src/geometry.c')
-rw-r--r-- | libcrystfel/src/geometry.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 266d6267..b968dc06 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -52,16 +52,15 @@ static int locate_peak_on_panel(double x, double y, double z, double k, struct panel *p, double *pfs, double *pss) { - double r2, ctt, tta, phi; + double ctt, tta, phi; gsl_vector *v; gsl_vector *t; gsl_matrix *M; double fs, ss, one_over_mu; /* Calculate 2theta (scattering angle) and azimuth (phi) */ - r2 = x*x + y*y + z*z; - ctt = 1.0 - r2 / (2.0*k*k); /* cos(2theta) */ - tta = acos(ctt); + tta = atan2(sqrt(x*x+y*y), k+z); + ctt = cos(tta); phi = atan2(y, x); /* Set up matrix equation */ @@ -637,25 +636,18 @@ void polarisation_correction(RefList *list, UnitCell *cell, struct image *image) refl != NULL; refl = next_refl(refl, iter) ) { - double pol, pa, pb, phi, tt, ool; + double pol; double intensity; - double xl, yl, zl; + double xl, yl; signed int h, k, l; + const double P = 1.0; /* degree of polarisation */ get_indices(refl, &h, &k, &l); - /* Polarisation correction assuming 100% polarisation - * along the x direction */ - xl = h*asx + k*bsx + l*csx; - yl = h*asy + k*bsy + l*csy; - zl = h*asz + k*bsz + l*csz; + xl = (h*asx + k*bsx + l*csx)*image->lambda; + yl = (h*asy + k*bsy + l*csy)*image->lambda; - ool = 1.0 / image->lambda; - tt = angle_between(0.0, 0.0, 1.0, xl, yl, zl+ool); - phi = atan2(yl, xl); - pa = pow(sin(phi)*sin(tt), 2.0); - pb = pow(cos(tt), 2.0); - pol = 1.0 - 2.0*(1.0-pa) + (1.0+pb); + pol = P*(1.0 - xl*xl) + (1.0-P)*(1.0 - yl*yl); intensity = get_intensity(refl); set_intensity(refl, intensity / pol); |