aboutsummaryrefslogtreecommitdiff
path: root/julia/CrystFEL/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-20 15:19:37 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:35 +0100
commitbb1bd3e18471d03cded733ff9b177c8fdeade0c8 (patch)
tree90f65b1296f6b404876d640303e7004b39c56140 /julia/CrystFEL/src
parenteff54a2c23ee1d0d29f1af11af77881bd0c44b1e (diff)
Julia: Add show method for Image
Diffstat (limited to 'julia/CrystFEL/src')
-rw-r--r--julia/CrystFEL/src/image.jl59
1 files changed, 59 insertions, 0 deletions
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl
index 494c5d27..f858dfa7 100644
--- a/julia/CrystFEL/src/image.jl
+++ b/julia/CrystFEL/src/image.jl
@@ -1,5 +1,7 @@
module Images
+using Printf
+
import ..CrystFEL: libcrystfel
import ..CrystFEL.DataTemplates: DataTemplate, InternalDataTemplate
import ..CrystFEL.DetGeoms: DetGeom
@@ -267,4 +269,61 @@ function Image(dtempl::DataTemplate,
end
+function Base.show(io::IO, mime::MIME"text/plain", image::Image)
+
+ idata = unsafe_load(image.internalptr)
+ @printf(io, "CrystFEL.Image(%p):\n\n", image.internalptr)
+
+ println(io, " Serial number: ", idata.serial)
+ write(io, " Filename: ")
+ if idata.filename == C_NULL
+ write(io, "<not set>")
+ else
+ write(io, unsafe_string(idata.filename))
+ end
+ write(io, "\n")
+
+ write(io, " Frame ID: ")
+ if idata.ev == C_NULL
+ write(io, "<not set>")
+ else
+ write(io, unsafe_string(idata.ev))
+ end
+ write(io, "\n")
+
+ write(io, "\n")
+ println(io, " Wavelength: ", idata.lambda*1e10, " Å")
+ println(io, " Bandwidth: ", idata.bw*100, " %")
+ println(io, " Divergence: ", idata.div*1e3, " mrad")
+
+ write(io, "\n")
+ if idata.peaklist != C_NULL
+ let npk = @ccall libcrystfel.image_feature_count(idata.peaklist::Ptr{InternalPeakList})::Cint
+ println(io, " Number of peaks: ", npk)
+ end
+ else
+ println(io, " Number of peaks: 0 (no peak list)")
+ end
+
+ println(io, " Estimated resolution: ", 1e10/idata.peak_resolution, " Å")
+ write(io, " Hit flag: ")
+ if idata.hit != 0
+ write(io, "set")
+ else
+ write(io, "not set")
+ end
+ write(io, "\n")
+
+ write(io, "\n")
+ println(io, " Number of crystals: ", idata.n_crystals)
+ println(io, " Number of indexing attempts made: ", idata.n_crystals)
+ println(io, " Indexed by algorithm: ", idata.indexed_by)
+end
+
+
+function Base.show(io::IO, image::Image)
+ @printf(io, "CrystFEL.Image(%p)", image.internalptr)
+end
+
+
end # of module