spectrafit

📊📈🔬 SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.

https://github.com/anselmoo/spectrafit

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • ✓
    CITATION.cff file
    Found CITATION.cff file
  • ✓
    codemeta.json file
    Found codemeta.json file
  • ✓
    .zenodo.json file
    Found .zenodo.json file
  • ✓
    DOI references
    Found 2 DOI reference(s) in README
  • ✓
    Academic publication links
    Links to: acs.org
  • â—‹
    Committers with academic emails
  • â—‹
    Institutional organization owner
  • â—‹
    JOSS paper metadata
  • â—‹
    Scientific vocabulary similarity
    Low similarity (17.9%) to scientific vocabulary

Keywords

curve-fitting data-analysis-python data-science data-visualization fitting juypter-notebook lmfit moessbauer peak-analysis python raman science scientific-plotting spectroscopy uv-vis

Keywords from Contributors

annotation yolov5 transformation energy-system-model distributed embedded meshes climate hydrology sequencers
Last synced: 4 months ago · JSON representation ·

Repository

📊📈🔬 SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.

Basic Info
Statistics
  • Stars: 30
  • Watchers: 4
  • Forks: 8
  • Open Issues: 3
  • Releases: 0
Topics
curve-fitting data-analysis-python data-science data-visualization fitting juypter-notebook lmfit moessbauer peak-analysis python raman science scientific-plotting spectroscopy uv-vis
Created over 4 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Codeowners Security

README.md

CI - Python Package codecov PyPI Conda PyPI - Python Version pre-commit.ci status doi

SpectraFit


Data Analysis Tool for All Kinds of Spectra

SpectraFit is a Python tool for quick data fitting based on the regular expression of distribution and linear functions via the command line (CMD) or Jupyter Notebook It is designed to be easy to use and supports all common ASCII data formats. SpectraFit runs on Linux, Windows, and MacOS.

Scope

  • Fitting of 2D data, also with multiple columns as global fitting
  • Using established and advanced solver methods
  • Extensibility of the fitting function
  • Guarantee traceability of the fitting results
  • Saving all results in a SQL-like-format (CSV) for publications
  • Saving all results in a NoSQL-like-format (JSON) for project management
  • Having an API interface for Graph-databases

SpectraFit is a tool designed for researchers and scientists who require immediate data fitting to a model. It proves to be especially beneficial for individuals working with vast datasets or who need to conduct numerous fits within a limited time frame. SpectraFit's adaptability to various platforms and data formats makes it a versatile tool that caters to a broad spectrum of scientific applications.

Installation

via pip:

```bash pip install spectrafit

with support for Jupyter Notebook

pip install spectrafit[jupyter]

with support for the dashboard in the Jupyter Notebook

pip install spectrafit[jupyter-dash]

with support to visualize pkl-files as graph

pip install spectrafit[graph]

with all upcomming features

pip install spectrafit[all]

Upgrade

pip install spectrafit --upgrade ```

via conda, see also conda-forge:

```bash conda install -c conda-forge spectrafit

with support for Jupyter Notebook

conda install -c conda-forge spectrafit-jupyter

with all upcomming features

conda install -c conda-forge spectrafit-all ```

Usage

SpectraFit needs as command line tool only two things:

  1. The reference data, which should be fitted.
  2. The input file, which contains the initial model.

As model files json, toml, and yaml are supported. By making use of the python **kwargs feature, the input file can call most of the following functions of LMFIT. LMFIT is the workhorse for the fit optimization, which is macro wrapper based on:

  1. NumPy
  2. SciPy
  3. uncertainties

In case of SpectraFit, we have further extend the package by:

  1. Pandas
  2. statsmodels
  3. numdifftools
  4. Matplotlib in combination with Seaborn

bash spectrafit data_file.txt -i input_file.json

```bash usage: spectrafit [-h] [-o OUTFILE] [-i INPUT] [-ov] [-e0 ENERGY_START] [-e1 ENERGY_STOP] [-s SMOOTH] [-sh SHIFT] [-c COLUMN COLUMN] [-sep { ,,,;,:,|, ,s+}] [-dec {.,,}] [-hd HEADER] [-g {0,1,2}] [-auto] [-np] [-v] [-vb {0,1,2}] infile

Fast Fitting Program for ascii txt files.

positional arguments: infile Filename of the spectra data

optional arguments: -h, --help show this help message and exit -o OUTFILE, --outfile OUTFILE Filename for the export, default to set to 'spectrafitresults'. -i INPUT, --input INPUT Filename for the input parameter, default to set to 'fittinginput.toml'.Supported fileformats are: '.json', '.yml', '.yaml', and '.toml' -ov, --oversampling Oversampling the spectra by using factor of 5; default to False. -e0 ENERGYSTART, --energystart ENERGYSTART Starting energy in eV; default to start of energy. -e1 ENERGYSTOP, --energystop ENERGYSTOP Ending energy in eV; default to end of energy. -s SMOOTH, --smooth SMOOTH Number of smooth points for lmfit; default to 0. -sh SHIFT, --shift SHIFT Constant applied energy shift; default to 0.0. -c COLUMN COLUMN, --column COLUMN COLUMN Selected columns for the energy- and intensity-values; default to '0' for energy (x-axis) and '1' for intensity (y-axis). In case of working with header, the column should be set to the column names as 'str'; default to 0 and 1. -sep { ,,,;,:,|, ,s+}, --separator { ,,,;,:,|, ,s+} Redefine the type of separator; default to ' '. -dec {.,,}, --decimal {.,,} Type of decimal separator; default to '.'. -hd HEADER, --header HEADER Selected the header for the dataframe; default to None. -cm COMMENT, --comment COMMENT Lines with comment characters like '#' should not be parsed; default to None. -g {0,1,2}, --global_ {0,1,2} Perform a global fit over the complete dataframe. The options are '0' for classic fit (default). The option '1' for global fitting with auto-definition of the peaks depending on the column size and '2' for self-defined global fitting routines. -auto, --autopeak Auto detection of peaks in the spectra based on SciPy. The position, height, and width are used as estimation for the Gaussian models.The default option is 'False' for manual peak definition. -np, --noplot No plotting the spectra and the fit of SpectraFit. -v, --version Display the current version of SpectraFit. -vb {0,1,2}, --verbose {0,1,2} Display the initial configuration parameters and fit results, as a table '1', as a dictionary '2', or not in the terminal '0'. The default option is set to 1 for table printout. ```

Jupyter Notebook

Open the Jupyter Notebook and run the following code:

bash spectrafit-jupyter

or via Docker Image for <cpu> with amd64 and arm64:

bash docker pull ghcr.io/anselmoo/spectrafit-<cpu>:latest docker run -it -p 8888:8888 spectrafit-<cpu>:latest

or just:

bash docker run -p 8888:8888 ghcr.io/anselmoo/spectrafit-<cpu>:latest

Next define your initial model and the reference data:

```python from spectrafit.plugins.notebook import SpectraFitNotebook import pandas as pd

df = pd.read_csv( "https://raw.githubusercontent.com/Anselmoo/spectrafit/main/Examples/data.csv" )

initialmodel = [ { "pseudovoigt": { "amplitude": {"max": 2, "min": 0, "vary": True, "value": 1}, "center": {"max": 2, "min": -2, "vary": True, "value": 0}, "fwhmg": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, "fwhml": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, } }, { "pseudovoigt": { "amplitude": {"max": 2, "min": 0, "vary": True, "value": 1}, "center": {"max": 2, "min": -2, "vary": True, "value": 1}, "fwhmg": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, "fwhml": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, } }, { "pseudovoigt": { "amplitude": {"max": 2, "min": 0, "vary": True, "value": 1}, "center": {"max": 2, "min": -2, "vary": True, "value": 1}, "fwhmg": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, "fwhml": {"max": 0.4, "min": 0.1, "vary": True, "value": 0.21}, } }, ] spf = SpectraFitNotebook(df=df, xcolumn="Energy", ycolumn="Noisy") spf.solvermodel(initial_model) ```

Which results in the following output:

img_jupyter

Documentation

Please see the extended documentation for the full usage of SpectraFit.

The documentation is generated by Built with Material for MkDocs .

Owner

  • Name: Anselm Hahn
  • Login: Anselmoo
  • Kind: user
  • Location: Switzerland

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- given-names: Anselm W.
  family-names: Hahn
  email: anselm.hahn@gmail.com
  orcid: 'https://orcid.org/0000-0003-4543-4833'
- given-names: Joseph
  family-names: Zsombor-Pindera
  orcid: 'https://orcid.org/0000-0002-9051-1319'
- given-names: Pierre
  family-names: Kennepohl
  orcid: 'https://orcid.org/0000-0003-3408-9157'
- given-names: Serena
  family-names: DeBeer
  orcid: 'https://orcid.org/0000-0002-5196-3400'
title: "SpectraFit"
version: 1.x
doi: '10.1021/acsomega.3c09262'
date-released: 2024-05-20
url: 'https://anselmoo.github.io/spectrafit/'
repository-code: 'https://github.com/Anselmoo/spectrafit/tree/main/spectrafit'
repository: 'https://github.com/Anselmoo/spectrafit'
repository-artifact: >-
  'https://github.com/Anselmoo/spectrafit/pkgs/container/spectrafit'
license: BSD-3-Clause
keywords:
  - spectroscopy
  - python
  - chemistry
  - fitting
  - X-ray
preferred-citation:
  type: article
  authors:
  - given-names: Anselm W.
    family-names: Hahn
    email: anselm.hahn@gmail.com
    orcid: 'https://orcid.org/0000-0003-4543-4833'
  - given-names: Joseph
    family-names: Zsombor-Pindera
    orcid: 'https://orcid.org/0000-0002-9051-1319'
  - given-names: Pierre
    family-names: Kennepohl
    orcid: 'https://orcid.org/0000-0003-3408-9157'
  - given-names: Serena
    family-names: DeBeer
    orcid: 'https://orcid.org/0000-0002-5196-3400'
  doi: '10.1021/acsomega.3c09262'
  journal: 'ACS Omega'
  month: 5
  start: 23252 # First page number
  end: 23265 # Last page number
  issue: 22
  volume: 9
  title: >-
    'Introducing SpectraFit: An Open-Source Tool for Interactive Spectral Analysis'
  year: 2024

GitHub Events

Total
  • Create event: 320
  • Commit comment event: 1
  • Release event: 6
  • Issues event: 8
  • Watch event: 4
  • Delete event: 310
  • Member event: 1
  • Issue comment event: 1,697
  • Push event: 872
  • Pull request review comment event: 35
  • Pull request review event: 237
  • Pull request event: 589
Last Year
  • Create event: 320
  • Commit comment event: 1
  • Release event: 6
  • Issues event: 8
  • Watch event: 4
  • Delete event: 310
  • Member event: 1
  • Issue comment event: 1,697
  • Push event: 872
  • Pull request review comment event: 35
  • Pull request review event: 237
  • Pull request event: 589

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 1,548
  • Total Committers: 11
  • Avg Commits per committer: 140.727
  • Development Distribution Score (DDS): 0.496
Past Year
  • Commits: 364
  • Committers: 5
  • Avg Commits per committer: 72.8
  • Development Distribution Score (DDS): 0.585
Top Committers
Name Email Commits
Anselm Hahn A****n@g****m 780
dependabot[bot] 4****] 447
renovate[bot] 2****] 151
pre-commit-ci[bot] 6****] 124
github-actions[bot] g****] 28
ImgBotApp I****p@g****m 12
Sourcery AI 2
snyk-bot s****t@s****o 1
josephzsombor j****r@u****a 1
imgbot[bot] 3****] 1
fossabot b****s@f****o 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 53
  • Total pull requests: 1,851
  • Average time to close issues: 8 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 4
  • Total pull request authors: 7
  • Average comments per issue: 0.75
  • Average comments per pull request: 3.06
  • Merged pull requests: 964
  • Bot issues: 7
  • Bot pull requests: 1,388
Past Year
  • Issues: 11
  • Pull requests: 675
  • Average time to close issues: 4 days
  • Average time to close pull requests: 4 days
  • Issue authors: 4
  • Pull request authors: 5
  • Average comments per issue: 2.0
  • Average comments per pull request: 3.86
  • Merged pull requests: 395
  • Bot issues: 4
  • Bot pull requests: 467
Top Authors
Issue Authors
  • Anselmoo (46)
  • renovate[bot] (3)
  • dependabot[bot] (2)
  • pre-commit-ci[bot] (2)
Pull Request Authors
  • dependabot[bot] (619)
  • renovate[bot] (607)
  • Anselmoo (461)
  • pre-commit-ci[bot] (105)
  • github-actions[bot] (56)
  • Copilot (2)
  • imgbot[bot] (1)
Top Labels
Issue Labels
enhancement (17) bug (7) documentation (6) wontfix (6) size/XS (5) maintenance (4) root (4) dependencies (3) pre-commit (2) github-actions (2) bug Code Quality (1) github_actions (1) python (1)
Pull Request Labels
dependencies (1,118) root (950) size/XS (708) github-actions (472) python (404) maintenance (401) github_actions (135) pre-commit (126) weekly-update (88) release (80) testing (77) documentation (72) changelog (49) size/L (39) size/M (38) size/S (35) Extra Small (30) wontfix (29) enhancement (27) codespaces (12) vendor (12) size/XXL (11) security (8) docker (4) size/XL (4) license (3) Code Quality (1) bug (1)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 304 last-month
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 125
  • Total maintainers: 1
pypi.org: spectrafit

Fast fitting of 2D- and 3D-Spectra with established routines

  • Versions: 111
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 304 Last month
Rankings
Dependent packages count: 10.1%
Downloads: 11.7%
Forks count: 14.2%
Average: 14.6%
Stargazers count: 15.6%
Dependent repos count: 21.5%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: spectrafit

SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.

  • Versions: 8
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Dependent packages count: 19.5%
Dependent repos count: 34.0%
Average: 39.9%
Stargazers count: 51.9%
Forks count: 54.2%
Last synced: 4 months ago
conda-forge.org: spectrafit-jupyter

SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.

  • Versions: 3
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Average: 47.6%
Stargazers count: 50.9%
Dependent packages count: 51.2%
Forks count: 54.2%
Last synced: 4 months ago
conda-forge.org: spectrafit-all

SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Average: 47.6%
Stargazers count: 50.9%
Dependent packages count: 51.2%
Forks count: 54.2%
Last synced: 4 months ago