diff options
Diffstat (limited to 'julia/CrystFEL/src/mergeutils.jl')
-rw-r--r-- | julia/CrystFEL/src/mergeutils.jl | 21 |
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 |