qens.io¶
Reader for ISIS Mantid ‘.nxspe’ (NeXus / HDF5) files.
Filename convention (lowercase, underscore-separated)¶
<sample>_<temperature_K>_<Ei_x_100>_<kind>.nxspe
Example: “benzene_290_360_inc.nxspe” >>> benzene, 290 K, Ei = 3.60 meV, incoherent measurement.
- qens.io.read_nxspe(path)[source]¶
Load a single ‘.nxspe’ file.
- Parameters:
path (str) – Path to the file.
- Return type:
- Returns:
dict with keys – “name” : filename “sample”, “temp”, “ei”, “kind” : metadata “e_raw” : energy axis (meV) before elastic-peak alignment “e” : energy axis (meV) — initially copy of e_raw, gets shifted
by :func:’qens.preprocessing.fit_elastic_peak’
”data”, “errs” : (n_det, n_E) arrays of intensity and 1σ errors “q” : (n_det,) momentum transfer at elastic line, Å⁻¹ “good” : (n_good,) integer indices of detectors with usable data
- qens.io.read_nxspe_with_overrides(path, *, sample=None, temp=None, ei=None, kind=None)[source]¶
Like :func:’read_nxspe’ but lets you override metadata.
Useful when filenames don’t follow the convention.
- qens.io.load_dataset(file_list, data_dir='.', critical_files=None, verbose=True)[source]¶
Load several .nxspe files into a dict keyed by filename.
- Parameters:
file_list (iterable of str) – Filenames to load (relative to “data_dir”).
data_dir (str) – Directory containing the files.
critical_files (iterable of str, optional) – Files that must load — raises if any are missing/unreadable. Other failures are warnings.
verbose (bool) – If True, print a one-line summary per file.
- Return type:
- Returns:
dict[str, dict] – Keys are filenames, values are the dicts returned by :func:’read_nxspe’.