Name | pybaselines JSON |
Version |
1.1.0
JSON |
| download |
home_page | |
Summary | A library of algorithms for the baseline correction of experimental data. |
upload_time | 2024-02-18 20:00:51 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | BSD 3-Clause License Copyright (c) 2021-2024, Donald Erb All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
keywords |
materials characterization
materials science
baseline
background
baseline correction
baseline subtraction
chemistry
spectroscopy
raman
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
===========
pybaselines
===========
.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/logo.png
:alt: Logo
:align: center
.. image:: https://img.shields.io/pypi/v/pybaselines.svg
:target: https://pypi.python.org/pypi/pybaselines
:alt: Current Pypi Version
.. image:: https://img.shields.io/conda/vn/conda-forge/pybaselines.svg
:target: https://anaconda.org/conda-forge/pybaselines
:alt: Current conda Version
.. image:: https://github.com/derb12/pybaselines/actions/workflows/python-test.yml/badge.svg
:target: https://github.com/derb12/pybaselines/actions
:alt: GitHub Actions test status
.. image:: https://readthedocs.org/projects/pybaselines/badge/?version=latest
:target: https://pybaselines.readthedocs.io
:alt: Documentation Status
.. image:: https://img.shields.io/pypi/pyversions/pybaselines.svg
:target: https://pypi.python.org/pypi/pybaselines
:alt: Supported Python versions
.. image:: https://zenodo.org/badge/350510397.svg
:target: https://zenodo.org/badge/latestdoi/350510397
:alt: Zenodo DOI
pybaselines is a library of algorithms for the baseline correction of experimental data.
* For Python 3.8+
* Open Source: BSD 3-Clause License
* Source Code: https://github.com/derb12/pybaselines
* Documentation: https://pybaselines.readthedocs.io.
.. contents:: **Contents**
:depth: 1
Introduction
------------
pybaselines is a Python library that provides many different algorithms for
performing baseline correction on data from experimental techniques such as
Raman, FTIR, NMR, XRD, XRF, PIXE, etc. The aim of the project is to provide a
semi-unified API to allow quickly testing and comparing multiple baseline
correction algorithms to find the best one for a set of data.
pybaselines has 50+ baseline correction algorithms. These include popular algorithms,
such as AsLS, airPLS, ModPoly, and SNIP, as well as many lesser known algorithms. Most
algorithms are adapted directly from literature, although there are a few that are unique
to pybaselines, such as penalized spline versions of Whittaker-smoothing-based algorithms.
The full list of implemented algorithms can be found in the
`documentation <https://pybaselines.readthedocs.io/en/latest/introduction.html>`_.
Installation
------------
Stable Release
~~~~~~~~~~~~~~
pybaselines can be installed from `pypi <https://pypi.org/project/pybaselines>`_
using `pip <https://pip.pypa.io>`_, by running the following command in the terminal:
.. code-block:: console
pip install pybaselines
pybaselines can alternatively be installed from the
`conda-forge <https://anaconda.org/conda-forge/pybaselines>`_ channel using conda by running:
.. code-block:: console
conda install -c conda-forge pybaselines
Development Version
~~~~~~~~~~~~~~~~~~~
The sources for pybaselines can be downloaded from the `GitHub repo`_.
To install the current version of pybaselines from GitHub, run:
.. code-block:: console
pip install git+https://github.com/derb12/pybaselines.git#egg=pybaselines
.. _GitHub repo: https://github.com/derb12/pybaselines
Dependencies
~~~~~~~~~~~~
pybaselines requires `Python <https://python.org>`_ version 3.8 or later
and the following libraries:
* `NumPy <https://numpy.org>`_
* `SciPy <https://scipy.org>`_
All of the required libraries should be automatically installed when
installing pybaselines using any of the installation methods above.
The `optional dependencies <https://pybaselines.readthedocs.io/en/latest/installation.html#optional-dependencies>`_
for pybaselines are listed in the documentation . To also install the optional
dependencies when installing pybaselines with pip, run:
.. code-block:: console
pip install pybaselines[full]
If installing with conda, the optional dependencies have to be specified manually.
Quick Start
-----------
To use the various functions in pybaselines, simply input the measured
data and any required parameters. All baseline correction functions in pybaselines
will output two items: a numpy array of the calculated baseline and a
dictionary of potentially useful parameters. The main interface for all baseline correction
algorithms in pybaselines is through the ``Baseline`` object for one dimensional
data and ``Baseline2D`` for two dimensional data.
For more details on each baseline algorithm, refer to the `algorithms section`_ of
pybaselines's documentation. For examples of their usage, refer to the `examples section`_.
.. _algorithms section: https://pybaselines.readthedocs.io/en/latest/algorithms/index.html
.. _examples section: https://pybaselines.readthedocs.io/en/latest/examples/index.html
A simple example is shown below.
.. code-block:: python
import matplotlib.pyplot as plt
import numpy as np
from pybaselines import Baseline, utils
x = np.linspace(1, 1000, 1000)
# a measured signal containing several Gaussian peaks
signal = (
utils.gaussian(x, 4, 120, 5)
+ utils.gaussian(x, 5, 220, 12)
+ utils.gaussian(x, 5, 350, 10)
+ utils.gaussian(x, 7, 400, 8)
+ utils.gaussian(x, 4, 550, 6)
+ utils.gaussian(x, 5, 680, 14)
+ utils.gaussian(x, 4, 750, 12)
+ utils.gaussian(x, 5, 880, 8)
)
# exponentially decaying baseline
true_baseline = 2 + 10 * np.exp(-x / 400)
noise = np.random.default_rng(1).normal(0, 0.2, x.size)
y = signal + true_baseline + noise
baseline_fitter = Baseline(x_data=x)
bkg_1, params_1 = baseline_fitter.modpoly(y, poly_order=3)
bkg_2, params_2 = baseline_fitter.asls(y, lam=1e7, p=0.02)
bkg_3, params_3 = baseline_fitter.mor(y, half_window=30)
bkg_4, params_4 = baseline_fitter.snip(
y, max_half_window=40, decreasing=True, smooth_half_window=3
)
plt.plot(x, y, label='raw data', lw=1.5)
plt.plot(x, true_baseline, lw=3, label='true baseline')
plt.plot(x, bkg_1, '--', label='modpoly')
plt.plot(x, bkg_2, '--', label='asls')
plt.plot(x, bkg_3, '--', label='mor')
plt.plot(x, bkg_4, '--', label='snip')
plt.legend()
plt.show()
The above code will produce the image shown below.
.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/quickstart.jpg
:align: center
:alt: various baselines
Contributing
------------
Contributions are welcomed and greatly appreciated. For information on
submitting bug reports, pull requests, or general feedback, please refer
to the `contributing guide`_.
.. _contributing guide: https://github.com/derb12/pybaselines/tree/main/docs/contributing.rst
Changelog
---------
Refer to the changelog_ for information on pybaselines's changes.
.. _changelog: https://github.com/derb12/pybaselines/tree/main/CHANGELOG.rst
License
-------
pybaselines is open source and freely available under the BSD 3-clause license.
For more information, refer to the license_.
.. _license: https://github.com/derb12/pybaselines/tree/main/LICENSE.txt
Citing
------
If you use pybaselines for published research, please consider citing
by following the `guidelines in the documentation
<https://pybaselines.readthedocs.io/en/latest/citing.html>`_.
Author
------
* Donald Erb <donnie.erb@gmail.com>
Raw data
{
"_id": null,
"home_page": "",
"name": "pybaselines",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "materials characterization,materials science,baseline,background,baseline correction,baseline subtraction,chemistry,spectroscopy,raman",
"author": "",
"author_email": "Donald Erb <donnie.erb@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/dd/ea/101b9c6e3a830042fda9775d810318094d655eb8469cb51b324af4cb4a7c/pybaselines-1.1.0.tar.gz",
"platform": null,
"description": "===========\r\npybaselines\r\n===========\r\n\r\n.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/logo.png\r\n :alt: Logo\r\n :align: center\r\n\r\n.. image:: https://img.shields.io/pypi/v/pybaselines.svg\r\n :target: https://pypi.python.org/pypi/pybaselines\r\n :alt: Current Pypi Version\r\n\r\n.. image:: https://img.shields.io/conda/vn/conda-forge/pybaselines.svg\r\n :target: https://anaconda.org/conda-forge/pybaselines\r\n :alt: Current conda Version\r\n\r\n.. image:: https://github.com/derb12/pybaselines/actions/workflows/python-test.yml/badge.svg\r\n :target: https://github.com/derb12/pybaselines/actions\r\n :alt: GitHub Actions test status\r\n\r\n.. image:: https://readthedocs.org/projects/pybaselines/badge/?version=latest\r\n :target: https://pybaselines.readthedocs.io\r\n :alt: Documentation Status\r\n\r\n.. image:: https://img.shields.io/pypi/pyversions/pybaselines.svg\r\n :target: https://pypi.python.org/pypi/pybaselines\r\n :alt: Supported Python versions\r\n\r\n.. image:: https://zenodo.org/badge/350510397.svg\r\n :target: https://zenodo.org/badge/latestdoi/350510397\r\n :alt: Zenodo DOI\r\n\r\npybaselines is a library of algorithms for the baseline correction of experimental data.\r\n\r\n* For Python 3.8+\r\n* Open Source: BSD 3-Clause License\r\n* Source Code: https://github.com/derb12/pybaselines\r\n* Documentation: https://pybaselines.readthedocs.io.\r\n\r\n\r\n.. contents:: **Contents**\r\n :depth: 1\r\n\r\n\r\nIntroduction\r\n------------\r\n\r\npybaselines is a Python library that provides many different algorithms for\r\nperforming baseline correction on data from experimental techniques such as\r\nRaman, FTIR, NMR, XRD, XRF, PIXE, etc. The aim of the project is to provide a\r\nsemi-unified API to allow quickly testing and comparing multiple baseline\r\ncorrection algorithms to find the best one for a set of data.\r\n\r\npybaselines has 50+ baseline correction algorithms. These include popular algorithms,\r\nsuch as AsLS, airPLS, ModPoly, and SNIP, as well as many lesser known algorithms. Most\r\nalgorithms are adapted directly from literature, although there are a few that are unique\r\nto pybaselines, such as penalized spline versions of Whittaker-smoothing-based algorithms.\r\nThe full list of implemented algorithms can be found in the\r\n`documentation <https://pybaselines.readthedocs.io/en/latest/introduction.html>`_.\r\n\r\n\r\nInstallation\r\n------------\r\n\r\nStable Release\r\n~~~~~~~~~~~~~~\r\n\r\npybaselines can be installed from `pypi <https://pypi.org/project/pybaselines>`_\r\nusing `pip <https://pip.pypa.io>`_, by running the following command in the terminal:\r\n\r\n.. code-block:: console\r\n\r\n pip install pybaselines\r\n\r\npybaselines can alternatively be installed from the\r\n`conda-forge <https://anaconda.org/conda-forge/pybaselines>`_ channel using conda by running:\r\n\r\n.. code-block:: console\r\n\r\n conda install -c conda-forge pybaselines\r\n\r\n\r\nDevelopment Version\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\nThe sources for pybaselines can be downloaded from the `GitHub repo`_.\r\nTo install the current version of pybaselines from GitHub, run:\r\n\r\n.. code-block:: console\r\n\r\n pip install git+https://github.com/derb12/pybaselines.git#egg=pybaselines\r\n\r\n\r\n.. _GitHub repo: https://github.com/derb12/pybaselines\r\n\r\n\r\nDependencies\r\n~~~~~~~~~~~~\r\n\r\npybaselines requires `Python <https://python.org>`_ version 3.8 or later\r\nand the following libraries:\r\n\r\n* `NumPy <https://numpy.org>`_\r\n* `SciPy <https://scipy.org>`_\r\n\r\n\r\nAll of the required libraries should be automatically installed when\r\ninstalling pybaselines using any of the installation methods above.\r\n\r\nThe `optional dependencies <https://pybaselines.readthedocs.io/en/latest/installation.html#optional-dependencies>`_\r\nfor pybaselines are listed in the documentation . To also install the optional\r\ndependencies when installing pybaselines with pip, run:\r\n\r\n.. code-block:: console\r\n\r\n pip install pybaselines[full]\r\n\r\nIf installing with conda, the optional dependencies have to be specified manually.\r\n\r\nQuick Start\r\n-----------\r\n\r\nTo use the various functions in pybaselines, simply input the measured\r\ndata and any required parameters. All baseline correction functions in pybaselines\r\nwill output two items: a numpy array of the calculated baseline and a\r\ndictionary of potentially useful parameters. The main interface for all baseline correction\r\nalgorithms in pybaselines is through the ``Baseline`` object for one dimensional\r\ndata and ``Baseline2D`` for two dimensional data.\r\n\r\nFor more details on each baseline algorithm, refer to the `algorithms section`_ of\r\npybaselines's documentation. For examples of their usage, refer to the `examples section`_.\r\n\r\n.. _algorithms section: https://pybaselines.readthedocs.io/en/latest/algorithms/index.html\r\n\r\n.. _examples section: https://pybaselines.readthedocs.io/en/latest/examples/index.html\r\n\r\nA simple example is shown below.\r\n\r\n.. code-block:: python\r\n\r\n import matplotlib.pyplot as plt\r\n import numpy as np\r\n from pybaselines import Baseline, utils\r\n\r\n x = np.linspace(1, 1000, 1000)\r\n # a measured signal containing several Gaussian peaks\r\n signal = (\r\n utils.gaussian(x, 4, 120, 5)\r\n + utils.gaussian(x, 5, 220, 12)\r\n + utils.gaussian(x, 5, 350, 10)\r\n + utils.gaussian(x, 7, 400, 8)\r\n + utils.gaussian(x, 4, 550, 6)\r\n + utils.gaussian(x, 5, 680, 14)\r\n + utils.gaussian(x, 4, 750, 12)\r\n + utils.gaussian(x, 5, 880, 8)\r\n )\r\n # exponentially decaying baseline\r\n true_baseline = 2 + 10 * np.exp(-x / 400)\r\n noise = np.random.default_rng(1).normal(0, 0.2, x.size)\r\n\r\n y = signal + true_baseline + noise\r\n\r\n baseline_fitter = Baseline(x_data=x)\r\n\r\n bkg_1, params_1 = baseline_fitter.modpoly(y, poly_order=3)\r\n bkg_2, params_2 = baseline_fitter.asls(y, lam=1e7, p=0.02)\r\n bkg_3, params_3 = baseline_fitter.mor(y, half_window=30)\r\n bkg_4, params_4 = baseline_fitter.snip(\r\n y, max_half_window=40, decreasing=True, smooth_half_window=3\r\n )\r\n\r\n plt.plot(x, y, label='raw data', lw=1.5)\r\n plt.plot(x, true_baseline, lw=3, label='true baseline')\r\n plt.plot(x, bkg_1, '--', label='modpoly')\r\n plt.plot(x, bkg_2, '--', label='asls')\r\n plt.plot(x, bkg_3, '--', label='mor')\r\n plt.plot(x, bkg_4, '--', label='snip')\r\n\r\n plt.legend()\r\n plt.show()\r\n\r\n\r\nThe above code will produce the image shown below.\r\n\r\n.. image:: https://github.com/derb12/pybaselines/raw/main/docs/images/quickstart.jpg\r\n :align: center\r\n :alt: various baselines\r\n\r\n\r\nContributing\r\n------------\r\n\r\nContributions are welcomed and greatly appreciated. For information on\r\nsubmitting bug reports, pull requests, or general feedback, please refer\r\nto the `contributing guide`_.\r\n\r\n.. _contributing guide: https://github.com/derb12/pybaselines/tree/main/docs/contributing.rst\r\n\r\n\r\nChangelog\r\n---------\r\n\r\nRefer to the changelog_ for information on pybaselines's changes.\r\n\r\n.. _changelog: https://github.com/derb12/pybaselines/tree/main/CHANGELOG.rst\r\n\r\n\r\nLicense\r\n-------\r\n\r\npybaselines is open source and freely available under the BSD 3-clause license.\r\nFor more information, refer to the license_.\r\n\r\n.. _license: https://github.com/derb12/pybaselines/tree/main/LICENSE.txt\r\n\r\n\r\nCiting\r\n------\r\n\r\nIf you use pybaselines for published research, please consider citing\r\nby following the `guidelines in the documentation\r\n<https://pybaselines.readthedocs.io/en/latest/citing.html>`_.\r\n\r\n\r\nAuthor\r\n------\r\n\r\n* Donald Erb <donnie.erb@gmail.com>\r\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License Copyright (c) 2021-2024, Donald Erb All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
"summary": "A library of algorithms for the baseline correction of experimental data.",
"version": "1.1.0",
"project_urls": {
"Documentation": "https://pybaselines.readthedocs.io",
"Homepage": "https://github.com/derb12/pybaselines"
},
"split_keywords": [
"materials characterization",
"materials science",
"baseline",
"background",
"baseline correction",
"baseline subtraction",
"chemistry",
"spectroscopy",
"raman"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "913b38b660607a7a0d804518d639d36c51af34c2e447a82e5a858aa2f73f15e6",
"md5": "642f02e23cda4e5cc31ed3d74e8541ac",
"sha256": "b968f5addbca8b1c2b29cf4fb6a8ddf67a932ba92e4caab77fae0879b43d6f97"
},
"downloads": -1,
"filename": "pybaselines-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "642f02e23cda4e5cc31ed3d74e8541ac",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 199253,
"upload_time": "2024-02-18T20:00:49",
"upload_time_iso_8601": "2024-02-18T20:00:49.371815Z",
"url": "https://files.pythonhosted.org/packages/91/3b/38b660607a7a0d804518d639d36c51af34c2e447a82e5a858aa2f73f15e6/pybaselines-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ddea101b9c6e3a830042fda9775d810318094d655eb8469cb51b324af4cb4a7c",
"md5": "ad45a5ecc0f4b5a71e247a0d484f038a",
"sha256": "1f61ca378459af3983d6ca5813610ca587ac33d5b89e3c03bfb5f692bde61526"
},
"downloads": -1,
"filename": "pybaselines-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ad45a5ecc0f4b5a71e247a0d484f038a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 236449,
"upload_time": "2024-02-18T20:00:51",
"upload_time_iso_8601": "2024-02-18T20:00:51.226929Z",
"url": "https://files.pythonhosted.org/packages/dd/ea/101b9c6e3a830042fda9775d810318094d655eb8469cb51b324af4cb4a7c/pybaselines-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-18 20:00:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "derb12",
"github_project": "pybaselines",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pybaselines"
}