{"library":"pybaselines","title":"pybaselines","description":"pybaselines is a Python library providing a comprehensive collection of algorithms for baseline correction of experimental data, particularly useful in fields like spectroscopy and chromatography. It is currently at version 1.2.1 and maintains an active release cadence with minor versions and patches released every few months, and major versions less frequently.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pybaselines","pip install pybaselines[full]"],"cli":null},"imports":["from pybaselines.api import Baseline","from pybaselines.api import Baseline2D","from pybaselines.whittaker import asls","import pybaselines.smooth as smooth_algos"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom pybaselines.api import Baseline\n\n# 1. Generate some example data\nx = np.linspace(0, 100, 500)\ny_peak = 10 * np.exp(-((x - 50)**2) / 20) # A simple peak\ny_baseline = 0.1 * x + 5 # A sloping baseline\ny_data = y_peak + y_baseline + np.random.normal(0, 0.5, x.shape)\n\n# 2. Initialize the Baseline object (using the class-based API, recommended for v1.0.0+)\nbaseline_fitter = Baseline()\n\n# 3. Apply a baseline correction algorithm, e.g., Asymmetric Least Squares (ASLS)\n# The first return value is the estimated baseline, the second is a dictionary of parameters\nestimated_baseline, params = baseline_fitter.asls(y_data, lam=1e6, p=0.01)\n\n# 4. The corrected signal is the original data minus the estimated baseline\ncorrected_signal = y_data - estimated_baseline\n\nprint(\"Baseline estimation complete.\")\nprint(f\"First 5 original data values: {y_data[:5].round(2)}\")\nprint(f\"First 5 estimated baseline values: {estimated_baseline[:5].round(2)}\")\nprint(f\"First 5 corrected signal values: {corrected_signal[:5].round(2)}\")\n","lang":"python","description":"This quickstart demonstrates how to use the recommended class-based API (available since v1.0.0) to perform baseline correction using the Asymmetric Least Squares (ASLS) algorithm. It generates synthetic data with a peak and a sloping baseline, then applies the correction to estimate and remove the baseline.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}