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

Reading files

RigakuFiles.RigakuFileMethod
RigakuFile(path::AbstractString) -> RigakuFile

Read 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

  • ArgumentError if the file is empty, or if a canonical .ras file contains no *RAS_HEADER_START scan blocks. (A .txt export with no data rows yields a single scan with empty x/y rather than throwing.)
  • SystemError if 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")
end
source

Types

RigakuFiles.AbstractRigakuSpectrumType
AbstractRigakuSpectrum

Abstract 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.

source
RigakuFiles.RigakuFileType
RigakuFile <: AbstractVector{RigakuScan}

Container for all scans in a Rigaku .ras or .txt file.

Construct with RigakuFile(path) and navigate with Base array verbs:

IntentExpression
strict "exactly one scan"only(file) — throws if length ≠ 1
first of manyfirst(file)
all as a Vectorcollect(file)
countlength(file)
indexfile[i]
iteratefor scan in file; …; end

See also RigakuScan.

source
RigakuFiles.RigakuScanType
RigakuScan <: AbstractRigakuSpectrum

A single scan from a Rigaku instrument file (.ras or exported .txt).

Fields

  • sample::String — sample name (FILE_SAMPLE); "" if not recorded
  • comment::String — file comment (FILE_COMMENT); "" if not recorded
  • instrument::String — instrument model (FILE_SYSTEM_NAME); "" if not recorded
  • target::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.0 if not recorded
  • scan_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 recorded
  • end_time::DateTime — scan end (MEAS_SCAN_END_TIME); DateTime(1) if not recorded
  • xunits::String — x-axis units (MEAS_SCAN_UNIT_X), defaults to "deg"
  • yunits::String — y-axis units (MEAS_SCAN_UNIT_Y or #Intensity_unit), "" if not recorded
  • x::Vector{Float64} — angle values (typically 2θ)
  • y::Vector{Float64} — intensity values
  • metadata::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 typeSentinel
String""
Float640.0
DateTimeDateTime(1) (year 0001)

For strict "present vs. missing" checks, inspect the raw metadata dict instead of relying on the sentinel.

source

Metadata accessors

RigakuFiles.detectorMethod
detector(s::AbstractRigakuSpectrum) → String

Return the detector name, or "" if not recorded.

source
RigakuFiles.scan_stepMethod
scan_step(s::AbstractRigakuSpectrum) → Float64

Return the scan step size, or 0.0 if not recorded.

source