qens.preprocessing¶
Preprocessing: align the elastic peak to ω = 0 and assign each measurement a resolution function.
elastic peak alignment, resolution assignment
- qens.preprocessing.fit_elastic_peak(d)[source]¶
Fit a Gaussian to the elastic peak of a low-Q detector average.
Updates
d["e"]to bed["e_raw"] - e0, and storesd["e0"],d["sig_raw"](the elastic-peak Gaussian sigma).- Parameters:
d (dict) – Output of
qens.io.read_nxspe().- Return type:
- Returns:
(e0, sig_raw) ((float, float)) – Fitted peak centre and width in meV.
- qens.preprocessing.assign_resolution(dataset, cfg=None, verbose=True)[source]¶
Decide which file is the resolution function for each loaded file.
Modifies each dict in place, adding:
sigma_res: Gaussian sigma in meV (Gaussian-fit fallback)fwhm_res: 2.355 x sigma_res, in meVres_source: one of “frozen_sample”, “coh_file”,“raw_inc_inflated”, “explicit_override”
res_filefilename of the resolution reference, or Noneif the file’s own peak fit is used
- Parameters:
dataset (dict[str, dict]) – Output of
qens.io.load_dataset(). Each entry must already have hadfit_elastic_peak()called on it.cfg (Config, optional) – If given,
cfg.resolution_fileandcfg.frozen_temp_thresholdare honoured.verbose (bool) – If True, print a per file summary.
- Return type: