aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-05-15 14:47:47 +0200
committerThomas White <taw@physics.org>2013-05-15 14:47:47 +0200
commit54f704a4458eab9c9266fcdcb0d7d4db5ec69048 (patch)
tree9a32b99e079e569eb1ed75fbf66c857c2ce9008a /libcrystfel/src
parentb431c940907e5b9891b8eed7261a4a8bb922146d (diff)
Move polarisation_correction() to geometry.c
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/geometry.c42
-rw-r--r--libcrystfel/src/geometry.h2
2 files changed, 44 insertions, 0 deletions
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);
+ }
+}
diff --git a/libcrystfel/src/geometry.h b/libcrystfel/src/geometry.h
index 2ac5982b..a6708b2d 100644
--- a/libcrystfel/src/geometry.h
+++ b/libcrystfel/src/geometry.h
@@ -63,6 +63,8 @@ extern RefList *find_intersections(struct image *image, Crystal *cryst);
extern RefList *select_intersections(struct image *image, Crystal *cryst);
extern void update_partialities(Crystal *cryst, PartialityModel pmodel);
+extern void polarisation_correction(RefList *list, UnitCell *cell,
+ struct image *image);
#ifdef __cplusplus
}