envipat.resolution

Resolution interpolation (port of R’s getR).

R’s getR fits a smoothing spline to the instrument’s mass -> resolution calibration table and evaluates it at each formula’s mass. This port fits with scipy.interpolate.make_smoothing_spline() (smoothing parameter chosen by GCV) instead of reproducing R’s fixed-spar/fixed-nknots stats::smooth.spline.

Accuracy note: results are not bit-compatible with R. Against the frozen R reference the interpolated resolution deviates by up to ~17% relative error on the resolution_list curves. The nknots/spar arguments of R’s getR have no scipy equivalent and are therefore not supported.

envipat.resolution.get_resolution(checked, resmass)[source]

Interpolate instrument resolution at each checked formula’s mass.

Port of R’s getR, fitted with scipy.interpolate.make_smoothing_spline() (see the module docstring for the accuracy caveat versus R).

Parameters:
checked

The result of check_chemform: a DataFrame with (at least) boolean warning and numeric monoisotopic_mass columns, one row per formula.

resmass

Two-column mass/resolution calibration table, such as one entry of resolution_list (columns mz, R); only column position is used (mass first, resolution second), matching R’s resmass[, 1] / resmass[, 2]. At least 10 rows are required.

Returns:
pandas.Series

Interpolated resolutions, indexed like checked (name "resolution").

Notes

R’s getR also accepts nknots, spar and plotit; none of them are ported (no scipy equivalent / no plotting side effect).