aboutsummaryrefslogtreecommitdiff
path: root/julia/CrystFEL
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-02-27 11:56:24 +0100
committerThomas White <taw@physics.org>2024-02-27 11:56:24 +0100
commitda9794d5775ca3af9bde78da830eaba5d71ffe2b (patch)
treea5c360e402b3159ad2dcfaf8e6df7af64f5f10da /julia/CrystFEL
parent0ebaf0eb0465be23d8fee4088271cb92154a606d (diff)
Julia: Do polarisation correction via CrystFEL function
The Julia-native correction was 50% slower.
Diffstat (limited to 'julia/CrystFEL')
-rw-r--r--julia/CrystFEL/src/mergeutils.jl21
1 files changed, 21 insertions, 0 deletions
diff --git a/julia/CrystFEL/src/mergeutils.jl b/julia/CrystFEL/src/mergeutils.jl
index b75bd2e8..701992db 100644
--- a/julia/CrystFEL/src/mergeutils.jl
+++ b/julia/CrystFEL/src/mergeutils.jl
@@ -1,9 +1,12 @@
module MergeUtils
+import ..CrystFEL: libcrystfel
using ..CrystFEL.RefLists
using ..CrystFEL.Symmetry
+import ..CrystFEL.UnitCells: InternalUnitCell
export @addmeasurement, cstddev, mergereflections
+
macro addmeasurement(measurement, weight,
mean, sumweight, wksp)
return quote
@@ -19,12 +22,28 @@ end
cstddev(nmeas, work1, work2) = sqrt(work2/work1)/sqrt(nmeas)
+struct Polarisation
+ fraction::Cdouble
+ angle::Cdouble
+ disable::Cint
+end
+
+function polarisation_correction!(reflist, cell, polfrac, polangle)
+ pol = Polarisation(polfrac, rad2deg(polangle), 0)
+ @ccall libcrystfel.polarisation_correction(reflist.internalptr::Ptr{InternalRefList},
+ cell.internalptr::Ptr{InternalUnitCell},
+ pol::Ref{Polarisation})::Cvoid
+end
+
+
function mergereflections(correction, crystalrefls, sym)
merged = RefList{MergedReflection}(sym)
for (cr,reflections) in crystalrefls
+ polarisation_correction!(reflections, cr.cell, 1.0, 0.0)
+
for refl in reflections
indices = asymmetricindices(sym, refl.indices)
@@ -53,5 +72,7 @@ function mergereflections(correction, crystalrefls, sym)
end
+mergereflections(crystalrefls, sym) = mergereflections((refl,cr)->refl.intensity, crystalrefls, sym)
+
end # of module