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 be d["e_raw"] - e0, and stores d["e0"], d["sig_raw"] (the elastic-peak Gaussian sigma).

Parameters:

d (dict) – Output of qens.io.read_nxspe().

Return type:

tuple[float, float]

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 meV res_source : one of “frozen_sample”, “coh_file”,

“raw_inc_inflated”, “explicit_override”

res_filefilename of the resolution reference, or None

if the file’s own peak fit is used

Parameters:
Return type:

None