pybaselines
A library of algorithms for the baseline correction of experimental data.
What it is and what it does
pybaselines is a Python library for baseline correction—the removal of background signal from experimental measurements in spectroscopy and analytical chemistry. It implements over 50 algorithms including well-known methods like AsLS, airPLS, ModPoly, and SNIP, as well as specialized variants unique to the library. The library targets practitioners working with data from techniques such as Raman, FTIR, NMR, XRD, and similar analytical methods.
The main interface is the Baseline class for 1D data and Baseline2D for 2D data. Each algorithm returns both the calculated baseline and a dictionary of parameters, allowing users to quickly test multiple approaches on the same dataset to find the best fit. The library depends only on numpy and scipy, making it lightweight and easy to integrate into existing scientific Python workflows.
Use it for:
- Remove background noise from Raman spectroscopy measurements to isolate peak signals for chemical identification.
- Correct baseline drift in FTIR spectra before performing quantitative analysis or peak fitting.
- Compare multiple baseline correction algorithms on the same dataset to determine which produces the best result for your material.
- Preprocess XRD or XRF data to improve signal-to-noise ratio before downstream analysis.
- Integrate baseline correction into automated spectroscopy data pipelines for batch processing.
- Develop custom baseline correction workflows by combining different algorithms and parameters.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides 50+ baseline correction algorithms for experimental data from spectroscopy and analytical techniques, with a unified API for testing and comparing methods.
Yes. pybaselines is a mature, actively maintained library with no known vulnerabilities, low installation friction, and a permissive license. Install it if you work with spectroscopy or analytical data requiring baseline correction—the breadth of algorithms and unified API make it the natural choice for this task.
Install
pybaselines on PyPI
pip
pip install pybaselinesuv
uv add pybaselinespoetry
poetry add pybaselinesInstalling pybaselines
Before you install
Low friction installation with only numpy and scipy as runtime dependencies. Actively maintained with recent commits and stable production status.
License in practice
BSD-3-Clause permissive license allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install pybaselines
import numpy as np
from pybaselines import Baseline
x = np.linspace(1, 1000, 1000)
y = np.random.normal(0, 1, 1000) # your measured data
baseline_fitter = Baseline(x_data=x)
bkg, params = baseline_fitter.asls(y, lam=1e7, p=0.02)
Requires Python 3.9 or later.
Verify before relying
- Whether the 50+ algorithms cover all common spectroscopy techniques mentioned (Raman, FTIR, NMR, XRD, XRF, PIXE, MALDI-TOF, LIBS).
- Performance characteristics and computational cost for large datasets or real-time processing.
- Availability and scope of optional dependencies referenced in the documentation.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | actively maintained — 369 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 128,730/month — #11,697 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pybaselines-1.2.1-py3-none-any.whl
Keywords: background, baseline, baseline correction, baseline subtraction, chemistry, materials characterization, materials science, raman, spectroscopy
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
PeakUtilsPeakUtils detects peaks in 1D data and refines…
permissive · top 15,000 on PyPI
libhreelsLibhreels reads, analyzes, and simulates…
unclear · top 15,000 on PyPI
specutilsSpecutils provides Python representations of…
permissive · top 15,000 on PyPI
pyhdfePyHDFE absorbs high-dimensional fixed effects…
permissive · top 15,000 on PyPI
mypy_baselineA CLI tool that captures mypy type errors as a…
permissive · top 15,000 on PyPI
patchParses and applies unified diff patches to…
permissive · top 15,000 on PyPI
stable-baselines3Stable Baselines3 provides PyTorch…
permissive · top 5,000 on PyPI
colour-scienceColour provides algorithms and datasets for…
permissive · top 15,000 on PyPI
arm-pyartPy-ART provides weather radar data processing,…
permissive · top 15,000 on PyPI