From 45796383dfa3a2daccaee2069e644268d1276c1d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 24 Apr 2024 16:25:35 +0200 Subject: Julia: Add 'setreflections!' to add a RefList for a Crystal in an image --- julia/CrystFEL/src/CrystFEL.jl | 2 +- julia/CrystFEL/src/image.jl | 16 +++++++++++++++- 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) -- cgit v1.2.3