diff options
author | Thomas White <taw@physics.org> | 2023-10-26 14:00:43 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | ef0611804113ae6dfb66ee4168f2a22f51f81920 (patch) | |
tree | d0c06e38db3b71d9cb53d2235e2ba5a7572fef34 /julia | |
parent | f9fe0992b4f03eec44b51274a179aee64f172e5a (diff) |
Julia: Get rid of DetGeom construction from panels
It's theoretically possible, but rather complicated from Julia. It's
not something that's really supported from the C API either, so I don't
see much reason to bend over backwards to make it work from Julia.
We will keep the access to the detgeom panel structure elements, though.
Diffstat (limited to 'julia')
-rw-r--r-- | julia/CrystFEL/src/detgeom.jl | 78 | ||||
-rw-r--r-- | julia/CrystFEL/src/image.jl | 30 | ||||
-rw-r--r-- | julia/alignment-test.geom | 49 | ||||
-rw-r--r-- | julia/alignment-test.jl | 10 |
4 files changed, 52 insertions, 115 deletions
diff --git a/julia/CrystFEL/src/detgeom.jl b/julia/CrystFEL/src/detgeom.jl index d394ee7b..ba943d98 100644 --- a/julia/CrystFEL/src/detgeom.jl +++ b/julia/CrystFEL/src/detgeom.jl @@ -1,21 +1,5 @@ module DetGeoms -export Panel, DetGeom - -guardian = [] - -function protect(guardian, obj) - push!(guardian, obj) - obj -end - -function unprotect(guardian, obj) - let pos = findfirst(==(obj), guardian) - if pos !== nothing - deleteat!(guardian, pos) - end - end -end - +export Panel mutable struct Panel name::Cstring @@ -44,44 +28,6 @@ mutable struct DetGeom end -""" - Panel(name, width, height, (cnx, cny), clen, (fsx,fsy,fsz), (ssx,ssy,ssz), pixelsize, aduperphoton) - -Create a panel for a CrystFEL `DetGeom`. - -* `cnx` and `cny`: Corner position in pixel units -* `clen`: Corner z-position in meters -* `(fsx,fsy,fsz)`: Fast scan vector in pixel units -* `(ssx,ssy,ssz)`: Slow scan vector in pixel units -* `pixelsize`: Conversion factor from pixels to meters -* `aduperphoton`: Detector units per quantum, for error estimation - -Additional keyword arguments: - -* `max_adu`=Inf: Saturation value -* `group`: Panel group (for hierarchy) -""" -function Panel(name, width, height, corner::Tuple{Real, Real}, clen, - fs::Tuple{Real,Real,Real}, ss::Tuple{Real,Real,Real}, - pixel_pitch, adu_per_photon, - max_adu=Inf, group=C_NULL) - - myname = protect(guardian, deepcopy(name)) - - p = Panel(pointer(myname), - corner[1], corner[2], clen/pixel_pitch, - pixel_pitch, adu_per_photon, max_adu, - fs[1], fs[2], fs[3], - ss[1], ss[2], ss[3], - width, height, group) - - finalizer(p) do x - unprotect(guardian, myname) - end - -end - - function Base.show(io::IO, p::Panel) write(io, "Panel(") write(io, "name=\"") @@ -98,26 +44,4 @@ function Base.show(io::IO, p::Panel) end -""" - DetGeom(panels; topgroup=g) - -Create a CrystFEL `DetGeom` from a vector of `Panel`s. Optionally set the -panel group which should be the top of the hierarchy. -""" -function DetGeom(panels; topgroup=C_NULL) - - pmem = Base.Libc.malloc(sizeof(panels[1])*length(panels)) - - for (i,panel) in enumerate(panels) - Base.unsafe_copyto!(pmem, pointer(panel), 1) - end - - dg = DetGeom(pmem, length(panels), topgroup) - - finalize(dg) do x - Base.Libc.free(dg.panels) - end - -end - end # of module diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl index e73e5f9a..3e4ff3a7 100644 --- a/julia/CrystFEL/src/image.jl +++ b/julia/CrystFEL/src/image.jl @@ -1,34 +1,4 @@ module Images export Image -guardian = [] - -function protect(guardian, obj) - push!(guardian, obj) - obj -end - -function unprotect(guardian, obj) - let pos = findfirst(==(obj), guardian) - if pos !== nothing - deleteat!(guardian, pos) - end - end -end - - -mutable struct Image -end - - -""" - Image() - -Create a CrystFEL image structure -""" -function Image(panels) - - -end - end # of module diff --git a/julia/alignment-test.geom b/julia/alignment-test.geom new file mode 100644 index 00000000..11668fca --- /dev/null +++ b/julia/alignment-test.geom @@ -0,0 +1,49 @@ +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 = -1054 +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 diff --git a/julia/alignment-test.jl b/julia/alignment-test.jl index df1e1fbc..21aff531 100644 --- a/julia/alignment-test.jl +++ b/julia/alignment-test.jl @@ -1,13 +1,7 @@ using CrystFEL -panels = [Panel("q1", 512, 512, (-530, -530), 0.1, (1, 0, 0), (0, 1, 0), 100e-6, 1), - Panel("q2", 512, 512, (28, -530), 0.1, (1, 0, 0), (0, 1, 0), 100e-6, 1), - Panel("q3", 512, 512, (-530, 28), 0.1, (1, 0, 0), (0, 1, 0), 100e-6, 1), - Panel("q4", 512, 512, (28, 28), 0.1, (1, 0, 0), (0, 1, 0), 100e-6, 1)] - -detgeom = DetGeom(panels) - -image = Image(detgeom) +dtempl = loaddatatemplate("julia/alignment-test.geom") +image = Image(dtempl) cell = UnitCell(123, 45, 80, 90, 97, 90) |