skillfed

pybaselines

A library of algorithms for the baseline correction of experimental data.

pybaselines v1.2.1 128.7K downloads/30d#11,697 on PyPI193
Permissive license BSD-3-Clause Active released

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 pybaselines

uv

uv add pybaselines

poetry

poetry add pybaselines

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: ChemistryTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: Physics

Tags

baseline correction algorithmsspectroscopy data processingraman spectrum baseline subtractionexperimental data baseline removalasls airpls modpoly snipftir xrd baseline fittingsignal preprocessing spectroscopy
spectroscopysignal-processingchemistry

More Scientific/Engineering packages