diff options
author | Thomas White <taw@physics.org> | 2023-10-09 14:50:02 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | d84acbbb0cfdd8156f318fadf05c176f1922d28a (patch) | |
tree | e6b2c93fcbe83e2bdaa08b7bc6e6a8d03e079914 | |
parent | 355246a6197ad2fcd7a030eb4dd5890f0c32ce8e (diff) |
Add wrapper for detector panels
-rw-r--r-- | julia/CrystFEL/src/CrystFEL.jl | 4 | ||||
-rw-r--r-- | julia/CrystFEL/src/detgeom.jl | 81 |
2 files changed, 85 insertions, 0 deletions
diff --git a/julia/CrystFEL/src/CrystFEL.jl b/julia/CrystFEL/src/CrystFEL.jl index 6e72757a..859c8833 100644 --- a/julia/CrystFEL/src/CrystFEL.jl +++ b/julia/CrystFEL/src/CrystFEL.jl @@ -11,6 +11,10 @@ Julia bindings for CrystFEL data structures and routines """ module CrystFEL +include("detgeom.jl") +using .DetGeoms +export Panel, DetGeom + include("symmetry.jl") using .Symmetry export SymOpList diff --git a/julia/CrystFEL/src/detgeom.jl b/julia/CrystFEL/src/detgeom.jl new file mode 100644 index 00000000..b370b302 --- /dev/null +++ b/julia/CrystFEL/src/detgeom.jl @@ -0,0 +1,81 @@ +module DetGeoms +export Panel, DetGeom + +mutable struct Panel + name::Cstring + cx::Cdouble + cy::Cdouble + cz::Cdouble + pixel_pitch::Cdouble + adu_per_photon::Cdouble + max_adu::Cdouble + fsx::Cdouble + fsy::Cdouble + fsz::Cdouble + ssx::Cdouble + ssy::Cdouble + ssz::Cdouble + w::Cint + h::Cint + group::Ptr{Cvoid} +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) + + @Base.GC.preserve name return Panel(pointer(name), + 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) + +end + + +function Base.show(io::IO, p::Panel) + write(io, "Panel(") + write(io, "name=\"") + write(io, unsafe_string(p.name)) + write(io, "\", center=(") + show(io, p.cx); write(io, ", "); show(io, p.cy); write(io, ", "); show(io, p.cz) + write(io, "), fs=(") + show(io, p.fsx); write(io, ", "); show(io, p.fsy); write(io, ", "); show(io, p.fsz) + write(io, "), ss=(") + show(io, p.ssx); write(io, ", "); show(io, p.ssy); write(io, ", "); show(io, p.ssz) + write(io, "), size=(") + show(io, p.w); write(io, ", "); show(io, p.h) + write(io, "))") +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=nothing) +end + +end # of module |