fitspy.baseline module
Class dedicated to spectrum baseline manipulation
- class fitspy.baseline.BaseLine
Bases:
object
Class dedicated to spectrum baseline manipulation
- points
List of the (x,y) baseline points coordinates
- Type:
list of 2 lists
- mode
Mode used to determine the baseline, among ‘Semi-Auto’ (semi-automatic baseline determination), ‘Linear’ (piecewise linear decomposition based on users points definition) and ‘Polynomial’. Default mode is ‘Linear’
- Type:
str
- coef
Smoothing coefficient used in the ‘Semi-Auto’ mode. The larger coef is, the smoother the resulting baseline
- Type:
int
- order_max
Maximum order of the baseline polynomial evaluation
- Type:
int
- distance
Minimum distance between baseline point to consider when doing automatic detection with ‘Spectrum.auto_baseline’
- Type:
float
- sigma
Smoothing coefficient (standard deviation) related to a gaussian filtering when defining baseline attached points to the spectrum
- Type:
float
- attached
Activation key for attach the baseline points to the spectrum
- Type:
bool
- is_subtracted
Key used to indicate whether the baseline has been subtracted from the spectrum
- Type:
bool
- y_eval
The baseline profile resulting from the ‘eval’ function
- Type:
numpy.ndarray(n)
- reinit()
Reinitialize the main attributes
- add_point(x, y)
Add point in the baseline
- attached_points(x, y)
Return baseline points attached to (x,y) ‘spectrum’ profile coords
- load_baseline(fname)
Load baseline from ‘fname’ with 1 header line and 2 (x,y) columns
- eval(x, y, attached=False)
Evaluate the baseline on a ‘x’ support and a ‘y’ profile possibly smoothed with a gaussian filter
- plot(ax, x, y, attached=False, label='Baseline', show_all=True)
Plot the baseline and its related points
- Parameters:
ax (Matplotlib.Axes) – Axis to work with
x (iterable of floats, optional) – Support to consider for the baseline plotting. If None, create a support from the baseline extrema points
y (iterable of floats, optional) – Values for baseline points attachment (if provided), sharing the same x coordinates
label (str, optional) – Label displays in the figure
show_all (bool, optional) – Activation key to display the primary baseline components (before attachment)
- fitspy.baseline.arpls(y, coef=4, ratio=0.05, itermax=10)
Asymmetrically Reweighted Penalized Least Squares smoothing extracted from: https://irfpy.irf.se/projects/ica/_modules/irfpy/ica/baseline.html#arpls
Original article
Sung-June Baek, Aaron Park, Young-Jin Ahna and Jaebum Choo, Analyst, 2015, 140, 250 (2015), https://doi.org/10.1039/C4AN01061B
- param y:
input data (i.e. spectrum intensity)
- type y:
numpy.ndarray(n)
- param coef:
parameter that can be adjusted by user. The larger coef is, the smoother the resulting background, y_smooth
- type coef:
float, optional
- param ratio:
wheighting deviations: 0 < ratio < 1, smaller values allow less negative values
- type ratio:
float, optional
- param itermax:
number of iterations to perform
- type itermax:
int, optional
- returns:
y_smooth – the fitted background
- rtype:
numpy.ndarray(n)