Public API
Only exported types and functions are considered part of the public API. Raw header fields not covered by the accessors below are still available through scan.metadata.
Index
RigakuFiles.AbstractRigakuSpectrumRigakuFiles.RigakuFileRigakuFiles.RigakuFileRigakuFiles.RigakuScanRigakuFiles.detectorRigakuFiles.scan_speedRigakuFiles.scan_stepRigakuFiles.wavelength_alpha1RigakuFiles.wavelength_alpha2RigakuFiles.wavelength_beta
Reading files
RigakuFiles.RigakuFile — Method
RigakuFile(path::AbstractString) -> RigakuFileRead a Rigaku .ras or exported .txt file into a RigakuFile container holding one or more RigakuScans.
Auto-detects the file format (canonical RAS, identified by *RAS_DATA_START / *RAS_HEADER_START markers, vs the simplified .txt export). Within a RAS scan block, intensity data is delimited by *RAS_INT_START / *RAS_INT_END.
Use Base array verbs to navigate: only(file) for a strict single-scan assertion, first(file), file[i], iteration, length(file).
Throws
ArgumentErrorif the file is empty, or if a canonical.rasfile contains no*RAS_HEADER_STARTscan blocks. (A.txtexport with no data rows yields a single scan with emptyx/yrather than throwing.)SystemErrorif the file cannot be read from disk.
Examples
# single-scan file (throws if the file actually contains >1 scan)
scan = only(RigakuFile("sample.ras"))
# multi-scan file
file = RigakuFile("multiscan.ras")
length(file) # number of scans
for scan in file
println(scan.sample, ": ", length(scan.x), " points")
endTypes
RigakuFiles.AbstractRigakuSpectrum — Type
AbstractRigakuSpectrumAbstract supertype for Rigaku instrument data.
Interface
Concrete subtypes must provide:
x::Vector{Float64}— independent-axis values (typically 2θ or angle)y::Vector{Float64}— dependent-axis values (typically intensity)metadata::Dict{String, String}— raw header key/value pairs, with annotation lines (#key=value) stored under"_" * key
Providing these three fields enables length, size, and the accessor helpers in this package (wavelength_alpha1, scan_step, detector, …) to work out of the box.
RigakuFiles.RigakuFile — Type
RigakuFile <: AbstractVector{RigakuScan}Container for all scans in a Rigaku .ras or .txt file.
Construct with RigakuFile(path) and navigate with Base array verbs:
| Intent | Expression |
|---|---|
| strict "exactly one scan" | only(file) — throws if length ≠ 1 |
| first of many | first(file) |
all as a Vector | collect(file) |
| count | length(file) |
| index | file[i] |
| iterate | for scan in file; …; end |
See also RigakuScan.
RigakuFiles.RigakuScan — Type
RigakuScan <: AbstractRigakuSpectrumA single scan from a Rigaku instrument file (.ras or exported .txt).
Fields
sample::String— sample name (FILE_SAMPLE);""if not recordedcomment::String— file comment (FILE_COMMENT);""if not recordedinstrument::String— instrument model (FILE_SYSTEM_NAME);""if not recordedtarget::String— X-ray target element (HW_XG_TARGET_NAME), e.g."Cu"wavelength::Float64— Kα1 wavelength in ångström (HW_XG_WAVE_LENGTH_ALPHA1);0.0if not recordedscan_axis::String— scan axis name (MEAS_SCAN_AXIS_X), e.g."TwoThetaTheta"scan_mode::String— scan mode (MEAS_SCAN_MODE), e.g."CONTINUOUS"start_time::DateTime— scan start (MEAS_SCAN_START_TIME);DateTime(1)if not recordedend_time::DateTime— scan end (MEAS_SCAN_END_TIME);DateTime(1)if not recordedxunits::String— x-axis units (MEAS_SCAN_UNIT_X), defaults to"deg"yunits::String— y-axis units (MEAS_SCAN_UNIT_Yor#Intensity_unit),""if not recordedx::Vector{Float64}— angle values (typically 2θ)y::Vector{Float64}— intensity valuesmetadata::Dict{String, String}— all raw header key/value pairs; annotation lines (#key=value) are stored under"_" * key
Sentinels for missing fields
To keep the struct concretely typed, missing fields use fixed sentinel values:
| Field type | Sentinel |
|---|---|
String | "" |
Float64 | 0.0 |
DateTime | DateTime(1) (year 0001) |
For strict "present vs. missing" checks, inspect the raw metadata dict instead of relying on the sentinel.
Metadata accessors
RigakuFiles.detector — Method
detector(s::AbstractRigakuSpectrum) → StringReturn the detector name, or "" if not recorded.
RigakuFiles.scan_speed — Method
scan_speed(s::AbstractRigakuSpectrum) → Float64Return the scan speed, or 0.0 if not recorded.
RigakuFiles.scan_step — Method
scan_step(s::AbstractRigakuSpectrum) → Float64Return the scan step size, or 0.0 if not recorded.
RigakuFiles.wavelength_alpha1 — Method
wavelength_alpha1(s::AbstractRigakuSpectrum) → Float64Return the Kα1 wavelength in Angstrom. Shorthand for s.wavelength.
RigakuFiles.wavelength_alpha2 — Method
wavelength_alpha2(s::AbstractRigakuSpectrum) → Float64Return the Kα2 wavelength in Angstrom, or 0.0 if not recorded.
RigakuFiles.wavelength_beta — Method
wavelength_beta(s::AbstractRigakuSpectrum) → Float64Return the Kβ wavelength in Angstrom, or 0.0 if not recorded.