aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-21 12:20:09 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:35 +0100
commitd371a2b753fd20da36ec6a46f06e4bc8f058f1fa (patch)
tree570791e3edcc7c5ec99743d3c6764f25795e1187
parent85a57decf6cafc353b792cd52f476eed4ade3915 (diff)
Julia: Add push!(image, crystal, reflections)
New method needed following "Crystals shouldn't own RefLists" patch series.
-rw-r--r--julia/CrystFEL/src/image.jl15
-rw-r--r--julia/partial_sim.jl4
2 files changed, 17 insertions, 2 deletions
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl
index 020117e7..33af3252 100644
--- a/julia/CrystFEL/src/image.jl
+++ b/julia/CrystFEL/src/image.jl
@@ -217,6 +217,21 @@ function Base.push!(image::Image, cr::Crystal)
end
+function Base.push!(image::Image, cr::Crystal, reflections::RefList{UnmergedReflection})
+ @ccall libcrystfel.image_add_crystal_refls(image.internalptr::Ptr{InternalImage},
+ cr.internalptr::Ptr{InternalCrystal},
+ reflections.internalptr::Ptr{InternalRefList})::Cvoid
+ idata = unsafe_load(image.internalptr)
+ ncryst = idata.n_crystals
+ pairptr = unsafe_load(idata.crystals, ncryst)
+ pairptr.owns_crystal = 0
+ pairptr.owns_reflist = 0
+ unsafe_store!(idata.crystals, pairptr, ncryst)
+ push!(getfield(image, :crystals), cr)
+ push!(getfield(image, :reflists), reflections)
+end
+
+
"""
Image(dtempl::DataTemplate)
diff --git a/julia/partial_sim.jl b/julia/partial_sim.jl
index 4ddec347..11384f47 100644
--- a/julia/partial_sim.jl
+++ b/julia/partial_sim.jl
@@ -10,8 +10,8 @@ let st = Stream("partials.stream", "w", dtempl)
image.filename = "simulation_" * string(i)
image.ev = "//"
cr = Crystal(rotatecell(cell))
- cr.reflections = predictreflections(cr, image)
- push!(image, cr)
+ reflections = predictreflections(cr, image)
+ push!(image, cr, reflections)
chunkwrite(st, image)
end
end