aboutsummaryrefslogtreecommitdiff
path: root/julia/CrystFEL/src/diffcalc.jl
blob: 1c6aea9cc566be0859fe1285b211aa01c62a184a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module DiffractionCalculations

import ..CrystFEL: libcrystfel
import ..CrystFEL.Images: InternalImage, Image
import ..CrystFEL.Crystals: InternalCrystal, Crystal
import ..CrystFEL.RefLists: RefList, UnmergedReflection, InternalRefList
import ..CrystFEL.Symmetry: SymOpList
export predictreflections, calculatepartialities!
export PartialityModel, UnityModel, XSphereModel, OffsetModel, RandomModel, GeneralGaussianModel


"""
Enumeration of the available partiality models.
"""
@enum PartialityModel begin
    UnityModel
    XSphereModel
    OffsetModel
    RandomModel
    GeneralGaussianModel
end


function predictreflections(cr::Crystal, image::Image; maxres=1e10)

    refls = @ccall libcrystfel.predict_to_res(cr.internalptr::Ptr{InternalCrystal},
                                              image.internalptr::Ptr{InternalImage},
                                              maxres::Cdouble)::Ptr{InternalRefList}
    sym = SymOpList("1")
    return RefList{UnmergedReflection}(refls, sym)
end


function calculatepartialities!(reflist::RefList{UnmergedReflection},
        cr::Crystal, image::Image; model=XSphereModel, maxres=1e10)

    @ccall libcrystfel.calculate_partialities(reflist.internalptr::Ptr{InternalRefList},
                                              cr.internalptr::Ptr{InternalCrystal},
                                              image.internalptr::Ptr{InternalImage},
                                              model::Cint)::Cvoid
end


end   # of module