Skip to main content

Fitspy: a generic tool to fit spectra in python

Project description

PyPI Github Doc

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.

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


Example of fitspy 2D-map frame interacting with the main GUI.

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 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). 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 for more details)

Tests and examples execution

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

(See the documentation 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 for more details)

Authors information

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. (submitted)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fitspy-2024.4.tar.gz (20.7 MB view details)

Uploaded Source

Built Distribution

fitspy-2024.4-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

Details for the file fitspy-2024.4.tar.gz.

File metadata

  • Download URL: fitspy-2024.4.tar.gz
  • Upload date:
  • Size: 20.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for fitspy-2024.4.tar.gz
Algorithm Hash digest
SHA256 1f493a9fed8661ce2d84ec6cc025eaa0af48ff1852660dbb061a2dc21dbfe6e5
MD5 1e786fab694eb5a976ebfefda3bc20ab
BLAKE2b-256 10f9504109a6f386992ddd5011b4f88a407f2ba7cd3ffa44c9a9a4a01a0825ca

See more details on using hashes here.

File details

Details for the file fitspy-2024.4-py3-none-any.whl.

File metadata

  • Download URL: fitspy-2024.4-py3-none-any.whl
  • Upload date:
  • Size: 60.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for fitspy-2024.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8960f68735c1febc3e36d942a84c6d3c2dd4b0e7f22b0cba0870572d10f5f2
MD5 47c518de81f360d680b6566e689f89c3
BLAKE2b-256 68c75d4645e7a8555b9c192705a339737d23e150d74352d1e71896285886c610

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page