Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

spectrochempy.autosub

autosub(dataset, ref, *ranges, dim='x', method='vardiff', return_coefs=False, inplace=False)[source]

Automatic subtraction of a reference to the dataset.

The subtraction coefficient are adjusted to either minimise the variance of the subtraction (method = ‘vardiff’) which will minimize peaks due to ref or minimize the sum of squares of the subtraction (method = ‘ssdiff’).

Parameters
  • dataset (NDDataset) – Dataset to which we want to subtract the reference data.

  • ref (NDDataset) – 1D reference data, with a size matching the axis to subtract. (axis parameter). # TODO : optionally use title of axis.

  • *ranges (pair(s) of values) – Any number of pairs is allowed. Coord range(s) in which the variance is minimized.

  • dim (str or int , optional, default=’x’) – Tells on which dimension to perform the subtraction. If dim is an integer it refers to the axis index.

  • method (str, optional, default=’vardiff’) – ‘vardiff’: minimize the difference of the variance. ‘ssdiff’: minimize the sum of squares difference of sum of squares.

  • return_coefs (bool , optional, default=`False`) – Returns the table of coefficients.

  • inplace (bool , optional, default=`False`) – True if the subtraction is done in place. In this case we do not need to catch the function output.

Returns

  • out (NDDataset) – The subtracted dataset.

  • coefs (ndarray .) – The table of subtraction coefficients (only if return_coefs is set to True ).

See also

Baseline

Manual baseline corrections.

abc

Automatic baseline corrections.

Examples

>>> path_A = 'irdata/nh4y-activation.spg'
>>> A = scp.read(path_A, protocol='omnic')
>>> ref = A[0, :]  # let's subtrack the first row
>>> B = A.autosub(ref, [3900., 3700.], [1600., 1500.], inplace=False)
>>> B
NDDataset: [float64]  a.u. (shape: (y:55, x:5549))