aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-19 14:09:11 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:35 +0100
commit93a6a827f115f27ed9e148aa635ec9400ffa700d (patch)
treee928a99fb3ffea887827e8e1b6ec2104af4af7c6
parent9a907d58a931472eb1178c42bfa1e7629e30ab00 (diff)
Julia: add translategroup() (and use it)
-rw-r--r--julia/CrystFEL/src/CrystFEL.jl2
-rw-r--r--julia/CrystFEL/src/datatemplates.jl22
-rw-r--r--julia/alignment-test-moved.geom51
-rw-r--r--julia/alignment-test.jl5
4 files changed, 26 insertions, 54 deletions
diff --git a/julia/CrystFEL/src/CrystFEL.jl b/julia/CrystFEL/src/CrystFEL.jl
index 27ee8b0b..63b636b1 100644
--- a/julia/CrystFEL/src/CrystFEL.jl
+++ b/julia/CrystFEL/src/CrystFEL.jl
@@ -46,7 +46,7 @@ export SymOpList
include("datatemplates.jl")
using .DataTemplates
-export DataTemplate, loaddatatemplate, wavelength, cameralength
+export DataTemplate, loaddatatemplate, wavelength, cameralength, translategroup
include("peaklist.jl")
using .PeakLists
diff --git a/julia/CrystFEL/src/datatemplates.jl b/julia/CrystFEL/src/datatemplates.jl
index 16433d9f..b76a272e 100644
--- a/julia/CrystFEL/src/datatemplates.jl
+++ b/julia/CrystFEL/src/datatemplates.jl
@@ -3,6 +3,7 @@ module DataTemplates
import ..CrystFEL: libcrystfel
export DataTemplate, InternalDataTemplate, loaddatatemplate
export wavelength, cameralength
+export translategroup
# Represents the real C-side (opaque) structure.
mutable struct InternalDataTemplate end
@@ -83,4 +84,25 @@ function cameralength(dtempl::DataTemplate)
end
+"""
+ translategroup(datatemplate, groupname, xshift, yshift, zshift)
+
+Modifies `DataTemplate` by moving the specified panel group by the specified
+amount (in metres).
+
+Corresponds to CrystFEL C API function `data_template_translate_group`.
+"""
+function translategroup(dtempl::DataTemplate, groupname, xshift, yshift, zshift)
+ r = @ccall libcrystfel.data_template_translate_group_m(dtempl.internalptr::Ptr{InternalDataTemplate},
+ groupname::Cstring,
+ xshift::Cdouble,
+ yshift::Cdouble,
+ zshift::Cdouble)::Cint
+ if r != 0
+ throw(ErrorException("Failed to shift DataTemplate"))
+ end
+
+end
+
+
end # of module
diff --git a/julia/alignment-test-moved.geom b/julia/alignment-test-moved.geom
deleted file mode 100644
index c834973b..00000000
--- a/julia/alignment-test-moved.geom
+++ /dev/null
@@ -1,51 +0,0 @@
-adu_per_photon = 1
-res = 10000
-clen = 100.0 mm
-photon_energy = 9000 eV
-
-dim0 = %
-dim1 = ss
-dim2 = fs
-data = /data/data
-
-q0/dim0 = 0
-q0/min_fs = 0
-q0/min_ss = 0
-q0/max_fs = 1024
-q0/max_ss = 1024
-q0/fs = x
-q0/ss = y
-q0/corner_x = -1056
-q0/corner_y = 30
-
-q1/dim0 = 1
-q1/min_fs = 0
-q1/min_ss = 0
-q1/max_fs = 1024
-q1/max_ss = 1024
-q1/fs = x
-q1/ss = y
-q1/corner_x = 30
-q1/corner_y = 30
-
-q2/dim0 = 2
-q2/min_fs = 0
-q2/min_ss = 0
-q2/max_fs = 1024
-q2/max_ss = 1024
-q2/fs = x
-q2/ss = y
-q2/corner_x = 30
-q2/corner_y = -1054
-
-q3/dim0 = 3
-q3/min_fs = 0
-q3/min_ss = 0
-q3/max_fs = 1024
-q3/max_ss = 1024
-q3/fs = x
-q3/ss = y
-q3/corner_x = -1054
-q3/corner_y = -1054
-
-group_all = q0,q1,q2,q3
diff --git a/julia/alignment-test.jl b/julia/alignment-test.jl
index ead812c3..4316755f 100644
--- a/julia/alignment-test.jl
+++ b/julia/alignment-test.jl
@@ -46,9 +46,10 @@ end
dtempl_true = loaddatatemplate("julia/alignment-test.geom")
image_true = Image(dtempl_true)
cell = UnitCell(MonoclinicLattice, PrimitiveCell, 123, 45, 80, 90, 97, 90)
-dtempl_moved = loaddatatemplate("julia/alignment-test-moved.geom")
+dtempl_moved = loaddatatemplate("julia/alignment-test.geom")
+translategroup(dtempl_moved, "q0", 200e-6, 0, 0)
let mille = Mille("mille.dat")
- simulate_and_index(cell, image_true, dtempl_true, mille, 100)
+ simulate_and_index(cell, image_true, dtempl_moved, mille, 100)
close(mille)
end