[![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/doc/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 a GUI that aims to be as simple and intuitive to use as possible.
<p align="center" width="100%">
<img align="center" width="75%" src=https://cea-metrocarac.github.io/fitspy/fitspy.png>
</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
```
pip install fitspy
```
*(See the [documentation](https://cea-metrocarac.github.io/fitspy/doc/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/doc/user_guide/intro.html#install-and-launching) for more details)*
## Quick start
Launch the application:
```
fitspy
```
Then, 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/doc/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.7",
"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>",
"download_url": "https://files.pythonhosted.org/packages/81/b4/3f10c7ffe29b0d54e8af6b7a3e1993e7c3ab2da9c4b6a7bb8c30d7f2e623/fitspy-2024.5.tar.gz",
"platform": null,
"description": "[![PyPI](https://badge.fury.io/py/fitspy.svg)](https://pypi.org/project/fitspy/)\r\n[![Github](https://img.shields.io/badge/GitHub-GPL--3.0-informational)](https://github.com/CEA-MetroCarac/fitspy)\r\n[![Doc](https://img.shields.io/badge/%F0%9F%95%AE-docs-green.svg)](https://cea-metrocarac.github.io/fitspy/doc/index.html)\r\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10812333.svg)](https://doi.org/10.5281/zenodo.10812333)\r\n[![status](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139/status.svg)](https://joss.theoj.org/papers/971a02868d903c0b7c0cbc3d1cd3d139)\r\n\r\n\r\n<p align=\"center\" width=\"100%\">\r\n <img align=\"center\" width=250 src=https://cea-metrocarac.github.io/fitspy/logo.png>\r\n</p>\r\n\r\n\r\n**Fitspy** is a generic tool dedicated to **fit sp**ectra in **py**thon with a GUI that aims to be as simple and intuitive to use as possible.\r\n\r\n<p align=\"center\" width=\"100%\">\r\n <img align=\"center\" width=\"75%\" src=https://cea-metrocarac.github.io/fitspy/fitspy.png>\r\n</p>\r\n\r\nProcessed spectra may be independent of each other or may result from 2D-maps\r\nacquisitions.\r\n\r\n<p align=\"center\" width=\"100%\">\r\n <img align=\"center\" width=\"30%\" src=https://cea-metrocarac.github.io/fitspy/2d-map.png> <br>\r\n <em>Example of fitspy 2D-map frame interacting with the main GUI.</em> \r\n</p>\r\n\r\nThe predefined peak models considered in Fitspy are `Gaussian`, `Lorentzian`, `Asymetric Gaussian`, `Asymetric Lorentzian` and `Pseudovoigt`.\r\n\r\nA `constant`, `linear`, `parabolic` or `exponential` background model can also be added in the fitting.\r\n\r\nIn both cases, `user-defined models` can be added.\r\n\r\nFitspy main features:\r\n\r\n- Fitspy uses the [lmfit](https://github.com/lmfit/lmfit-py) library to fit the spectra\r\n- The fit processing can be multi-threaded\r\n- Bounds and constraints can be set on each peaks models parameter\r\n- From an automatic noise level estimation, according to the local noise, peak models can be automatically deactivated\r\n- Fitspy also includes automatic outlier detection to be excluded during the fitting process\r\n\r\nAll actions allowed with the GUI can be executed in script mode (see examples [here](https://github.com/CEA-MetroCarac/fitspy/tree/main/examples)).\r\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.\r\n\r\n## Installation\r\n\r\n```\r\npip install fitspy\r\n```\r\n\r\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/doc/user_guide/intro.html#install-and-launching) for more details)*\r\n\r\n## Tests and examples execution\r\n\r\n```\r\npip install pytest\r\ngit clone https://github.com/CEA-MetroCarac/fitspy.git\r\ncd fitspy\r\npytest\r\npython examples/ex_gui_auto_decomposition.py\r\npython examples/ex_.......\r\n```\r\n\r\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/doc/user_guide/intro.html#install-and-launching) for more details)*\r\n\r\n## Quick start\r\n\r\nLaunch the application:\r\n\r\n```\r\nfitspy\r\n```\r\n\r\nThen, from the top to the bottom of the right panel:\r\n\r\n- `Select` file(s)\r\n- *(Optional)* Define the **X-range**\r\n- Define the baseline to `subtract` *(left or right click on the figure to add or delete (resp.) a baseline point)*\r\n- *(Optional)* Normalize the spectrum/spectra\r\n- Click on the `Fitting` panel to activate it\r\n- Select `Peak model` and add peaks *(left or right click on the figure to add or delete (resp.) a peak)*\r\n- *(Optional)* Add a background (**BKG model**) to be fitted\r\n- *(Optional)* Use **Parameters** to set bounds and constraints\r\n- `Fit` the selected spectrum/spectra\r\n- *(Optional)* **Save** the parameters in **.csv** format\r\n- *(Optional)* **Save** the **Model** in a .json file (to be replayed later)\r\n\r\n*(See the [documentation](https://cea-metrocarac.github.io/fitspy/doc/user_guide/workflow.html) for more details)*\r\n\r\n## Acknowledgements\r\n\r\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).\r\n\r\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.\r\n\r\n## Citations\r\n\r\nIn case you use the results of this code in an article, please cite:\r\n\r\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)\r\n\r\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).\r\n",
"bugtrack_url": null,
"license": "GPL v3",
"summary": "Fitspy: a generic tool to fit spectra in python",
"version": "2024.5",
"project_urls": {
"Documentation": "https://cea-metrocarac.github.io/fitspy/doc/index.html",
"Homepage": "https://github.dev/CEA-MetroCarac/fitspy"
},
"split_keywords": [
"fitspy",
" fit",
" spectra",
" spectrum",
" map",
" 1d",
" 2d",
" decomposition",
" gaussian",
" lorentzian",
" pseudovoigt",
" gui"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f6d08a597617082b6c0e5cd7ace62356af1bd0dab2b11e391dd17bdd2cee6cff",
"md5": "fbeae70f81604da2fad920b83f427bb6",
"sha256": "1f9f3b22014432aac03c1a3d6fe622782fd0fafdc8a87b3f91ceed9a4510e3d4"
},
"downloads": -1,
"filename": "fitspy-2024.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fbeae70f81604da2fad920b83f427bb6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 60879,
"upload_time": "2024-09-04T10:08:35",
"upload_time_iso_8601": "2024-09-04T10:08:35.561384Z",
"url": "https://files.pythonhosted.org/packages/f6/d0/8a597617082b6c0e5cd7ace62356af1bd0dab2b11e391dd17bdd2cee6cff/fitspy-2024.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "81b43f10c7ffe29b0d54e8af6b7a3e1993e7c3ab2da9c4b6a7bb8c30d7f2e623",
"md5": "36b8372ab541bdecd39ff5e678be6b5a",
"sha256": "276cb83c14f461ae9ee38df81c176acadbd63282e94e840b2c30aba6a119be76"
},
"downloads": -1,
"filename": "fitspy-2024.5.tar.gz",
"has_sig": false,
"md5_digest": "36b8372ab541bdecd39ff5e678be6b5a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 20201450,
"upload_time": "2024-09-04T10:08:43",
"upload_time_iso_8601": "2024-09-04T10:08:43.159605Z",
"url": "https://files.pythonhosted.org/packages/81/b4/3f10c7ffe29b0d54e8af6b7a3e1993e7c3ab2da9c4b6a7bb8c30d7f2e623/fitspy-2024.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 10:08:43",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fitspy"
}