aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/geometry.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src/geometry.c')
-rw-r--r--libcrystfel/src/geometry.c26
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);