From 54f704a4458eab9c9266fcdcb0d7d4db5ec69048 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 15 May 2013 14:47:47 +0200 Subject: Move polarisation_correction() to geometry.c --- libcrystfel/src/geometry.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'libcrystfel/src/geometry.c') diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index cdc62ab5..efb3f2ce 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -442,3 +442,45 @@ void update_partialities(Crystal *cryst, PartialityModel pmodel) reflist_free(predicted); } + + +void polarisation_correction(RefList *list, UnitCell *cell, struct image *image) +{ + Reflection *refl; + RefListIterator *iter; + double asx, asy, asz; + double bsx, bsy, bsz; + double csx, csy, csz; + + cell_get_reciprocal(cell, &asx, &asy, &asz, + &bsx, &bsy, &bsz, + &csx, &csy, &csz); + + for ( refl = first_refl(list, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) + { + double pol, pa, pb, phi, tt, ool; + double intensity; + double xl, yl, zl; + signed int h, k, l; + + 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; + + 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); + + intensity = get_intensity(refl); + set_intensity(refl, intensity / pol); + } +} -- cgit v1.2.3