fitspy


Namefitspy JSON
Version 2025.1 PyPI version JSON
download
home_pageNone
SummaryFitspy: a generic tool to fit spectra in python
upload_time2025-02-17 15:13:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseGPL v3
keywords fitspy fit spectra spectrum map 1d 2d decomposition gaussian lorentzian pseudovoigt gui
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://badge.fury.io/py/fitspy.svg)](https://pypi.org/project/fitspy/)
[![Github](https://img.shields.io/badge/GitHub-GPL--3.0-informational)](https://github.com/CEA-MetroCarac/fitspy)
[![Doc](https://img.shields.io/badge/%F0%9F%95%AE-docs-green.svg)](https://cea-metrocarac.github.io/fitspy/index.html)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10812333.svg)](https://doi.org/10.5281/zenodo.10812333)
[![status](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139/status.svg)](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139)


<p align="center" width="100%">
    <img align="center" width=250 src=https://cea-metrocarac.github.io/fitspy/logo.png>
</p>


**Fitspy** is a generic tool dedicated to **fit sp**ectra in **py**thon with GUIs that aims to be as simple and intuitive to use as possible.

<p align="center" width="100%">
    <img align="center" width="45%" src="https://cea-metrocarac.github.io/fitspy/_static/pyside/fitspy.png">
    <img align="center" width="45%" src="https://cea-metrocarac.github.io/fitspy/_static/tkinter/fitspy.png">
</p>
<p align="center">
    <em>Illustration of the PySide GUI (left) and Tkinter GUI (right).</em>
</p>

Processed spectra may be independent of each other or may result from 2D-maps
acquisitions.

<p align="center" width="100%">
    <img align="center" width="30%" src=https://cea-metrocarac.github.io/fitspy/2d-map.png> <br>
    <em>Example of fitspy 2D-map frame interacting with the main GUI.</em> 
</p>

The predefined peak models considered in Fitspy are  `Gaussian`, `Lorentzian`, `Asymetric Gaussian`, `Asymetric Lorentzian` and `Pseudovoigt`.

A `constant`, `linear`, `parabolic` or `exponential` background model can also be added in the fitting.

In both cases, `user-defined models` can be added.

Fitspy main features:

- Fitspy uses the [lmfit](https://github.com/lmfit/lmfit-py) library to fit the spectra
- The fit processing can be multi-threaded
- Bounds and constraints can be set on each peaks models parameter
- From an automatic noise level estimation, according to the local noise, peak models can be automatically deactivated
- Fitspy also includes automatic outlier detection to be excluded during the fitting process

All actions allowed with the GUI can be executed in script mode (see examples [here](https://github.com/CEA-MetroCarac/fitspy/tree/main/examples)).
These actions (like baseline and peaks definition, parameters constraints, ...) can be saved in a `Fitspy model` and replayed as-is or applied to other new spectra datasets.

## Installation

### From PyPI (recommended)

```bash
pip install fitspy
```

### From GitHub (latest version)

```bash
pip install git+https://github.com/CEA-MetroCarac/fitspy
```

*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/intro.html#install-and-launching) for more details)*

## Tests and examples execution

```
pip install pytest
git clone https://github.com/CEA-MetroCarac/fitspy.git
cd fitspy
pytest
python examples/ex_gui_auto_decomposition.py
python examples/ex_.......
```

*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/intro.html#install-and-launching) for more details)*

## Quick start

Since its 2025.1 version, Fitspy can be launched using two interfaces: either the one corresponding to the original GUI built with **Tkinter**, or a more recent and advanced one, using **PySide**. As of 2025, both GUIs offer nearly identical features, but future efforts regarding fixes and updates will primarily focus on the PySide GUI.

<u>**PySide GUI**</u>:

Launch the application:

```
fitspy
```

From the right to the left, select the files to work with (considering the drag and drop capabilities).
Then, use the **Model**  panel to set the model parameters to be used during the fitting process.
Peaks and an optional baseline associated with the model can be defined interactively by clicking on the desired position in the figure after activating **Peak points** (or **Baseline points** resp.) from the **Click Mode** radiobuttons located under the figure.
Once the model build, The **Fit** can be launched. The corresponding model can be saved (in the **Model** panel) to be reload later (from the bottom-central panel) as-it with the same spectra (if the pathnames are still available) or just as a model for other spectra to be processed.

<u>**Tkinter GUI**</u>:

Launch the application:

```
fitspy-tk
```

From the top to the bottom of the right panel:

- `Select` file(s)
- *(Optional)* Define the **X-range**
- Define the baseline to `subtract` *(left or right click on the figure to add or delete (resp.) a baseline point)*
- *(Optional)* Normalize the spectrum/spectra
- Click on the `Fitting` panel to activate it
- Select `Peak model` and add peaks *(left or right click on the figure to add or delete (resp.) a peak)*
- *(Optional)* Add a background (**BKG model**) to be fitted
- *(Optional)* Use **Parameters** to set bounds and constraints
- `Fit` the selected spectrum/spectra
- *(Optional)* **Save** the parameters in **.csv** format
- *(Optional)* **Save** the **Model** in a .json file (to be replayed later)

*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/workflow.html) for more details)*

## Acknowledgements

This work, carried out on the CEA - Platform for Nanocharacterisation (PFNC), was supported by the “Recherche Technologique de Base” program of the French National Research Agency (ANR).

Warm thanks to the [JOSS](https://joss.theoj.org/) reviewers ([@maurov](https://github.com/maurov) and [@FCMeng](https://github.com/FCMeng)) and editor ([@phibeck](https://github.com/phibeck)) for their contributions to enhancing Fitspy.

## Citations

In case you use the results of this code in an article, please cite:

- Quéméré P., (2024). Fitspy: A python package for spectral decomposition. Journal of Open Source Software. doi: [10.21105/joss.05868](https://doi.org/10.21105/joss.05868)

- Newville M., (2014). LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python. Zenodo. doi: [10.5281/zenodo.11813](https://doi.org/10.5281/zenodo.11813).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fitspy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Fitspy, fit, spectra, spectrum, map, 1D, 2D, decomposition, Gaussian, Lorentzian, Pseudovoigt, GUI",
    "author": null,
    "author_email": "Patrick Qu\u00e9m\u00e9r\u00e9 <patrick.quemere@cea.fr>, Killian Pavy <killian.pavy@cea.fr>",
    "download_url": "https://files.pythonhosted.org/packages/76/72/3835368a597e0c86773ffcc82f0968258e95afe0bc6bf39de16fc3781a7c/fitspy-2025.1.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://badge.fury.io/py/fitspy.svg)](https://pypi.org/project/fitspy/)\n[![Github](https://img.shields.io/badge/GitHub-GPL--3.0-informational)](https://github.com/CEA-MetroCarac/fitspy)\n[![Doc](https://img.shields.io/badge/%F0%9F%95%AE-docs-green.svg)](https://cea-metrocarac.github.io/fitspy/index.html)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10812333.svg)](https://doi.org/10.5281/zenodo.10812333)\n[![status](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139/status.svg)](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139)\n\n\n<p align=\"center\" width=\"100%\">\n    <img align=\"center\" width=250 src=https://cea-metrocarac.github.io/fitspy/logo.png>\n</p>\n\n\n**Fitspy** is a generic tool dedicated to **fit sp**ectra in **py**thon with GUIs that aims to be as simple and intuitive to use as possible.\n\n<p align=\"center\" width=\"100%\">\n    <img align=\"center\" width=\"45%\" src=\"https://cea-metrocarac.github.io/fitspy/_static/pyside/fitspy.png\">\n    <img align=\"center\" width=\"45%\" src=\"https://cea-metrocarac.github.io/fitspy/_static/tkinter/fitspy.png\">\n</p>\n<p align=\"center\">\n    <em>Illustration of the PySide GUI (left) and Tkinter GUI (right).</em>\n</p>\n\nProcessed spectra may be independent of each other or may result from 2D-maps\nacquisitions.\n\n<p align=\"center\" width=\"100%\">\n    <img align=\"center\" width=\"30%\" src=https://cea-metrocarac.github.io/fitspy/2d-map.png> <br>\n    <em>Example of fitspy 2D-map frame interacting with the main GUI.</em> \n</p>\n\nThe predefined peak models considered in Fitspy are  `Gaussian`, `Lorentzian`, `Asymetric Gaussian`, `Asymetric Lorentzian` and `Pseudovoigt`.\n\nA `constant`, `linear`, `parabolic` or `exponential` background model can also be added in the fitting.\n\nIn both cases, `user-defined models` can be added.\n\nFitspy main features:\n\n- Fitspy uses the [lmfit](https://github.com/lmfit/lmfit-py) library to fit the spectra\n- The fit processing can be multi-threaded\n- Bounds and constraints can be set on each peaks models parameter\n- From an automatic noise level estimation, according to the local noise, peak models can be automatically deactivated\n- Fitspy also includes automatic outlier detection to be excluded during the fitting process\n\nAll actions allowed with the GUI can be executed in script mode (see examples [here](https://github.com/CEA-MetroCarac/fitspy/tree/main/examples)).\nThese actions (like baseline and peaks definition, parameters constraints, ...) can be saved in a `Fitspy model` and replayed as-is or applied to other new spectra datasets.\n\n## Installation\n\n### From PyPI (recommended)\n\n```bash\npip install fitspy\n```\n\n### From GitHub (latest version)\n\n```bash\npip install git+https://github.com/CEA-MetroCarac/fitspy\n```\n\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/intro.html#install-and-launching) for more details)*\n\n## Tests and examples execution\n\n```\npip install pytest\ngit clone https://github.com/CEA-MetroCarac/fitspy.git\ncd fitspy\npytest\npython examples/ex_gui_auto_decomposition.py\npython examples/ex_.......\n```\n\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/intro.html#install-and-launching) for more details)*\n\n## Quick start\n\nSince its 2025.1 version, Fitspy can be launched using two interfaces: either the one corresponding to the original GUI built with **Tkinter**, or a more recent and advanced one, using **PySide**. As of 2025, both GUIs offer nearly identical features, but future efforts regarding fixes and updates will primarily focus on the PySide GUI.\n\n<u>**PySide GUI**</u>:\n\nLaunch the application:\n\n```\nfitspy\n```\n\nFrom the right to the left, select the files to work with (considering the drag and drop capabilities).\nThen, use the **Model**  panel to set the model parameters to be used during the fitting process.\nPeaks and an optional baseline associated with the model can be defined interactively by clicking on the desired position in the figure after activating **Peak points** (or **Baseline points** resp.) from the **Click Mode** radiobuttons located under the figure.\nOnce the model build, The **Fit** can be launched. The corresponding model can be saved (in the **Model** panel) to be reload later (from the bottom-central panel) as-it with the same spectra (if the pathnames are still available) or just as a model for other spectra to be processed.\n\n<u>**Tkinter GUI**</u>:\n\nLaunch the application:\n\n```\nfitspy-tk\n```\n\nFrom the top to the bottom of the right panel:\n\n- `Select` file(s)\n- *(Optional)* Define the **X-range**\n- Define the baseline to `subtract` *(left or right click on the figure to add or delete (resp.) a baseline point)*\n- *(Optional)* Normalize the spectrum/spectra\n- Click on the `Fitting` panel to activate it\n- Select `Peak model` and add peaks *(left or right click on the figure to add or delete (resp.) a peak)*\n- *(Optional)* Add a background (**BKG model**) to be fitted\n- *(Optional)* Use **Parameters** to set bounds and constraints\n- `Fit` the selected spectrum/spectra\n- *(Optional)* **Save** the parameters in **.csv** format\n- *(Optional)* **Save** the **Model** in a .json file (to be replayed later)\n\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/user_guide/workflow.html) for more details)*\n\n## Acknowledgements\n\nThis work, carried out on the CEA - Platform for Nanocharacterisation (PFNC), was supported by the \u201cRecherche Technologique de Base\u201d program of the French National Research Agency (ANR).\n\nWarm thanks to the [JOSS](https://joss.theoj.org/) reviewers ([@maurov](https://github.com/maurov) and [@FCMeng](https://github.com/FCMeng)) and editor ([@phibeck](https://github.com/phibeck)) for their contributions to enhancing Fitspy.\n\n## Citations\n\nIn case you use the results of this code in an article, please cite:\n\n- Qu\u00e9m\u00e9r\u00e9 P., (2024). Fitspy: A python package for spectral decomposition. Journal of Open Source Software. doi: [10.21105/joss.05868](https://doi.org/10.21105/joss.05868)\n\n- Newville M., (2014). LMFIT: Non-Linear Least-Square Minimization and Curve-Fitting for Python. Zenodo. doi: [10.5281/zenodo.11813](https://doi.org/10.5281/zenodo.11813).\n",
    "bugtrack_url": null,
    "license": "GPL v3",
    "summary": "Fitspy: a generic tool to fit spectra in python",
    "version": "2025.1",
    "project_urls": {
        "Documentation": "https://cea-metrocarac.github.io/fitspy/doc/index.html",
        "Homepage": "https://github.com/CEA-MetroCarac/fitspy"
    },
    "split_keywords": [
        "fitspy",
        " fit",
        " spectra",
        " spectrum",
        " map",
        " 1d",
        " 2d",
        " decomposition",
        " gaussian",
        " lorentzian",
        " pseudovoigt",
        " gui"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86eae84f0d2f8c178e6467c6215bfae84fe5ddf7c124bedb2e06b2a235117e53",
                "md5": "775367500b656c28251ffe34ba50c743",
                "sha256": "2b388fabd1afebdda29de9bb3e1e66f96887a56dfe74812fd783d9c945ace004"
            },
            "downloads": -1,
            "filename": "fitspy-2025.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "775367500b656c28251ffe34ba50c743",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 399736,
            "upload_time": "2025-02-17T15:13:33",
            "upload_time_iso_8601": "2025-02-17T15:13:33.760701Z",
            "url": "https://files.pythonhosted.org/packages/86/ea/e84f0d2f8c178e6467c6215bfae84fe5ddf7c124bedb2e06b2a235117e53/fitspy-2025.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76723835368a597e0c86773ffcc82f0968258e95afe0bc6bf39de16fc3781a7c",
                "md5": "873e1a92200c360944dc7bc0c5fb3935",
                "sha256": "a86079acfd74c66bf4cf2a6319db089e7f6463c5feb730ec22a3462a3eaa429b"
            },
            "downloads": -1,
            "filename": "fitspy-2025.1.tar.gz",
            "has_sig": false,
            "md5_digest": "873e1a92200c360944dc7bc0c5fb3935",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 15248204,
            "upload_time": "2025-02-17T15:13:36",
            "upload_time_iso_8601": "2025-02-17T15:13:36.746775Z",
            "url": "https://files.pythonhosted.org/packages/76/72/3835368a597e0c86773ffcc82f0968258e95afe0bc6bf39de16fc3781a7c/fitspy-2025.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-17 15:13:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CEA-MetroCarac",
    "github_project": "fitspy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fitspy"
}
        
Elapsed time: 1.69604s