aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-04-24 16:25:35 +0200
committerThomas White <taw@physics.org>2024-04-24 16:25:35 +0200
commit45796383dfa3a2daccaee2069e644268d1276c1d (patch)
tree8a3f3510418f6da590a0500a9e87e5e4f5c66161
parent35028ce34d3e31f23873730cd55e01b36b2cc1e2 (diff)
Julia: Add 'setreflections!' to add a RefList for a Crystal in an image
-rw-r--r--julia/CrystFEL/src/CrystFEL.jl2
-rw-r--r--julia/CrystFEL/src/image.jl16
2 files changed, 16 insertions, 2 deletions
diff --git a/julia/CrystFEL/src/CrystFEL.jl b/julia/CrystFEL/src/CrystFEL.jl
index 897d2614..7aa5b5fe 100644
--- a/julia/CrystFEL/src/CrystFEL.jl
+++ b/julia/CrystFEL/src/CrystFEL.jl
@@ -64,7 +64,7 @@ export Crystal, InternalCrystal
include("image.jl")
using .Images
-export Image
+export Image, setreflections!
include("diffcalc.jl")
using .DiffractionCalculations
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl
index 5ce056bd..d648dba4 100644
--- a/julia/CrystFEL/src/image.jl
+++ b/julia/CrystFEL/src/image.jl
@@ -9,7 +9,7 @@ import ..CrystFEL.PeakLists: PeakList, InternalPeakList
import ..CrystFEL.Crystals: Crystal, InternalCrystal
import ..CrystFEL.RefLists: RefList, InternalRefList, UnmergedReflection
import ..CrystFEL.Symmetry: SymOpList
-export Image
+export Image, setreflections!
const HEADER_CACHE_SIZE = 128
@@ -237,6 +237,20 @@ function Base.push!(image::Image, cr::Crystal, reflections::RefList{UnmergedRefl
end
+function setreflections!(image::Image, n, reflist)
+ idata = unsafe_load(image.internalptr)
+ ncryst = idata.n_crystals
+ if n > ncryst
+ throw(ArgumentError("Image does not have nominated crystal"))
+ end
+ pairptr = unsafe_load(idata.crystals, n)
+ pairptr.reflist = reflist.internalptr
+ pairptr.owns_reflist = 0
+ unsafe_store!(idata.crystals, pairptr, ncryst)
+ push!(getfield(image, :reflists), reflist)
+end
+
+
"""
Image(dtempl::DataTemplate)