Read Rigaku X-ray diffractometer output files (SmartLab, MiniFlex, Ultima) in Julia.
- Canonical
.ras(with*RAS_HEADER_START/*RAS_INT_STARTmarkers) and simplified.txtexports - Multi-scan files in a single read
- Common metadata surfaced as typed fields; the full raw header is preserved too
- Three-column attenuator data tolerated
- Works with either Unix or Windows line endings
using Pkg
Pkg.add(url="https://github.com/garrekstemo/RigakuFiles.jl")using RigakuFilesusing RigakuFiles
# Single-scan file; throws if the file actually contains >1 scan
scan = only(RigakuFile("mysample.ras"))
scan.sample # "ZIF-62 Test"
scan.target # "Cu"
scan.wavelength # 1.540593 (Kα1, Å)
scan.x # Vector{Float64} of 2θ values
scan.y # Vector{Float64} of intensitiesRigakuFile is an AbstractVector{RigakuScan}, so iteration, indexing, and length all work directly:
file = RigakuFile("multiscan.ras")
length(file) # number of scans
file[1] # first scan
for s in file
println(s.comment, ": ", length(s), " points")
endIf you want the first scan of a possibly-multi-scan file and are fine ignoring the rest:
scan = first(RigakuFile("maybe_multi.ras"))wavelength_alpha1(scan) # Kα1 wavelength (Å)
wavelength_alpha2(scan) # Kα2 wavelength (Å), or 0.0 if not recorded
wavelength_beta(scan) # Kβ wavelength (Å), or 0.0 if not recorded
scan_step(scan) # Scan step size
scan_speed(scan) # Scan speed
detector(scan) # Detector name, e.g. "HyPix3000(H)"Anything not exposed by the accessors is available in scan.metadata (a Dict{String, String}). See the documentation for the full field list and file-format notes.
If you run into a Rigaku file this package mis-parses — especially one from a firmware version or instrument line not yet covered — please open an issue. A minimal excerpt of the offending file (sample names can be redacted) is the most helpful thing to attach.