{"id":13605532,"url":"https://github.com/derb12/pybaselines","last_synced_at":"2026-02-22T19:03:52.601Z","repository":{"id":37313805,"uuid":"350510397","full_name":"derb12/pybaselines","owner":"derb12","description":"A Python library of algorithms for the baseline correction of experimental data.","archived":false,"fork":false,"pushed_at":"2024-02-19T00:45:34.000Z","size":1854,"stargazers_count":86,"open_issues_count":1,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-24T19:32:37.266Z","etag":null,"topics":["background-removal","baseline-correction","baseline-removal","chemistry","ftir","materials-characterization","materials-science","python","raman","spectroscopy"],"latest_commit_sha":null,"homepage":"https://pybaselines.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derb12.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"docs/contributing.rst","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-22T22:41:04.000Z","updated_at":"2024-04-20T04:52:09.000Z","dependencies_parsed_at":"2024-02-16T00:29:28.054Z","dependency_job_id":"e35c0da3-a608-4432-bc95-89e0b9426ef5","html_url":"https://github.com/derb12/pybaselines","commit_stats":{"total_commits":365,"total_committers":2,"mean_commits":182.5,"dds":0.005479452054794498,"last_synced_commit":"8a5c5e403400cedd8f9dc1a826c43b1e94d04a1b"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derb12%2Fpybaselines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derb12%2Fpybaselines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derb12%2Fpybaselines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derb12%2Fpybaselines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derb12","download_url":"https://codeload.github.com/derb12/pybaselines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223497908,"owners_count":17155218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-removal","baseline-correction","baseline-removal","chemistry","ftir","materials-characterization","materials-science","python","raman","spectroscopy"],"created_at":"2024-08-01T19:00:59.843Z","updated_at":"2025-10-21T19:54:57.867Z","avatar_url":"https://github.com/derb12.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"===========\npybaselines\n===========\n\n.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/logo.png\n    :alt: Logo\n    :align: center\n\n.. image:: https://img.shields.io/pypi/v/pybaselines.svg\n    :target: https://pypi.python.org/pypi/pybaselines\n    :alt: Current Pypi Version\n\n.. image:: https://img.shields.io/conda/vn/conda-forge/pybaselines.svg\n    :target: https://anaconda.org/conda-forge/pybaselines\n    :alt: Current conda Version\n\n.. image:: https://github.com/derb12/pybaselines/actions/workflows/python-test.yml/badge.svg\n    :target: https://github.com/derb12/pybaselines/actions\n    :alt: GitHub Actions test status\n\n.. image:: https://readthedocs.org/projects/pybaselines/badge/?version=latest\n    :target: https://pybaselines.readthedocs.io\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/pyversions/pybaselines.svg\n    :target: https://pypi.python.org/pypi/pybaselines\n    :alt: Supported Python versions\n\n.. image:: https://zenodo.org/badge/350510397.svg\n    :target: https://zenodo.org/badge/latestdoi/350510397\n    :alt: Zenodo DOI\n\npybaselines is a library of algorithms for the baseline correction of experimental data.\n\n* For Python 3.9 or later\n* Open Source: BSD 3-Clause License\n* Source Code: https://github.com/derb12/pybaselines\n* Documentation: https://pybaselines.readthedocs.io.\n\n\n.. contents:: **Contents**\n    :depth: 1\n\n\nIntroduction\n------------\n\npybaselines is a Python library that provides many different algorithms for\nperforming baseline correction on data from experimental techniques such as\nRaman, FTIR, NMR, XRD, XRF, PIXE, MALDI-TOF, LIBS, etc. The aim of the project is\nto provide a semi-unified API to allow quickly testing and comparing multiple baseline\ncorrection algorithms to find the best one for a set of data.\n\npybaselines has 50+ baseline correction algorithms. These include popular algorithms,\nsuch as AsLS, airPLS, ModPoly, and SNIP, as well as many lesser known algorithms. Most\nalgorithms are adapted directly from literature, although there are a few that are unique\nto pybaselines, such as penalized spline versions of Whittaker-smoothing-based algorithms.\nThe full list of implemented algorithms can be found in the\n`documentation \u003chttps://pybaselines.readthedocs.io/en/latest/api/Baseline.html\u003e`_.\n\n\nInstallation\n------------\n\nStable Release\n~~~~~~~~~~~~~~\n\npybaselines can be installed from `pypi \u003chttps://pypi.org/project/pybaselines\u003e`_\nusing `pip \u003chttps://pip.pypa.io\u003e`_, by running the following command in the terminal:\n\n.. code-block:: console\n\n    pip install pybaselines\n\npybaselines can alternatively be installed from the\n`conda-forge \u003chttps://anaconda.org/conda-forge/pybaselines\u003e`_ channel using conda by running:\n\n.. code-block:: console\n\n    conda install -c conda-forge pybaselines\n\n\nDevelopment Version\n~~~~~~~~~~~~~~~~~~~\n\nThe sources for pybaselines can be downloaded from the `GitHub repo`_.\nTo install the current version of pybaselines from GitHub, run:\n\n.. code-block:: console\n\n    pip install git+https://github.com/derb12/pybaselines.git\n\n\n.. _GitHub repo: https://github.com/derb12/pybaselines\n\n\nDependencies\n~~~~~~~~~~~~\n\npybaselines requires `Python \u003chttps://python.org\u003e`_ version 3.9 or later\nand the following libraries:\n\n* `NumPy \u003chttps://numpy.org\u003e`_\n* `SciPy \u003chttps://scipy.org\u003e`_\n\n\nAll of the required libraries should be automatically installed when\ninstalling pybaselines using any of the installation methods above.\n\nThe `optional dependencies \u003chttps://pybaselines.readthedocs.io/en/latest/installation.html#optional-dependencies\u003e`_\nfor pybaselines are listed in the documentation . To also install the optional\ndependencies when installing pybaselines with pip, run:\n\n.. code-block:: console\n\n    pip install pybaselines[full]\n\nIf installing with conda, the optional dependencies have to be specified manually.\n\nQuick Start\n-----------\n\nTo use the various functions in pybaselines, simply input the measured\ndata and any required parameters. All baseline correction functions in pybaselines\nwill output two items: a numpy array of the calculated baseline and a\ndictionary of potentially useful parameters. The main interface for all baseline correction\nalgorithms in pybaselines is through the ``Baseline`` object for one dimensional\ndata and ``Baseline2D`` for two dimensional data.\n\nFor more details on each baseline algorithm, refer to the `algorithms section`_ of\npybaselines's documentation. For examples of their usage, refer to the `examples section`_.\n\n.. _algorithms section: https://pybaselines.readthedocs.io/en/latest/algorithms/index.html\n\n.. _examples section: https://pybaselines.readthedocs.io/en/latest/examples/index.html\n\nA simple example is shown below.\n\n.. code-block:: python\n\n    import matplotlib.pyplot as plt\n    import numpy as np\n    from pybaselines import Baseline, utils\n\n    x = np.linspace(1, 1000, 1000)\n    # a measured signal containing several Gaussian peaks\n    signal = (\n        utils.gaussian(x, 4, 120, 5)\n        + utils.gaussian(x, 5, 220, 12)\n        + utils.gaussian(x, 5, 350, 10)\n        + utils.gaussian(x, 7, 400, 8)\n        + utils.gaussian(x, 4, 550, 6)\n        + utils.gaussian(x, 5, 680, 14)\n        + utils.gaussian(x, 4, 750, 12)\n        + utils.gaussian(x, 5, 880, 8)\n    )\n    # exponentially decaying baseline\n    true_baseline = 2 + 10 * np.exp(-x / 400)\n    noise = np.random.default_rng(1).normal(0, 0.2, x.size)\n\n    y = signal + true_baseline + noise\n\n    baseline_fitter = Baseline(x_data=x)\n\n    bkg_1, params_1 = baseline_fitter.modpoly(y, poly_order=3)\n    bkg_2, params_2 = baseline_fitter.asls(y, lam=1e7, p=0.02)\n    bkg_3, params_3 = baseline_fitter.mor(y, half_window=30)\n    bkg_4, params_4 = baseline_fitter.snip(\n        y, max_half_window=40, decreasing=True, smooth_half_window=3\n    )\n\n    plt.plot(x, y, label='raw data', lw=1.5)\n    plt.plot(x, true_baseline, lw=3, label='true baseline')\n    plt.plot(x, bkg_1, '--', label='modpoly')\n    plt.plot(x, bkg_2, '--', label='asls')\n    plt.plot(x, bkg_3, '--', label='mor')\n    plt.plot(x, bkg_4, '--', label='snip')\n\n    plt.legend()\n    plt.show()\n\n\nThe above code will produce the image shown below.\n\n.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/quickstart.jpg\n   :align: center\n   :alt: various baselines\n\n\nContributing\n------------\n\nContributions are welcomed and greatly appreciated. For information on\nsubmitting bug reports, pull requests, or general feedback, please refer\nto the `contributing guide`_.\n\n.. _contributing guide: https://github.com/derb12/pybaselines/tree/main/docs/contributing.rst\n\n\nChangelog\n---------\n\nRefer to the changelog_ for information on pybaselines's changes.\n\n.. _changelog: https://github.com/derb12/pybaselines/tree/main/CHANGELOG.rst\n\n\nLicense\n-------\n\npybaselines is open source and freely available under the BSD-3-Clause license.\nFor more information, refer to the license_.\n\n.. _license: https://github.com/derb12/pybaselines/tree/main/LICENSE.txt\n\n\nCiting\n------\n\nIf you use pybaselines for published research, please consider citing\nby following the `guidelines in the documentation\n\u003chttps://pybaselines.readthedocs.io/en/latest/citing.html\u003e`_.\n\n\nAuthor\n------\n\n* Donald Erb \u003cdonnie.erb@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderb12%2Fpybaselines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderb12%2Fpybaselines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderb12%2Fpybaselines/lists"}