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
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.5%) to scientific vocabulary
Last synced: 11 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: Cjorn
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Size: 453 MB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 10
  • Releases: 0
Created over 1 year ago · Last pushed over 1 year 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: Toledo_PVO
  • Login: Cjorn
  • Kind: user
  • Location: São Paulo - BR

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
  • Watch event: 1
  • Delete event: 27
  • Issue comment event: 26
  • Pull request review event: 1
  • Pull request event: 58
  • Create event: 43
Last Year
  • Watch event: 1
  • Delete event: 27
  • Issue comment event: 26
  • Pull request review event: 1
  • Pull request event: 58
  • Create event: 43

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 25
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.76
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 25
Past Year
  • Issues: 0
  • Pull requests: 25
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.76
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 25
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (32)
Top Labels
Issue Labels
Pull Request Labels
dependencies (32) python (16) github_actions (16) github-actions (10) root (9) maintenance (2)

Dependencies

.github/workflows/codeql.yml actions
  • actions/checkout v4 composite
  • github/codeql-action/analyze v3 composite
  • github/codeql-action/autobuild v3 composite
  • github/codeql-action/init v3 composite
.github/workflows/dependency-review.yml actions
  • actions/checkout v4 composite
  • actions/dependency-review-action v4 composite
.github/workflows/devcontainer-ci.yml actions
  • actions/checkout v4 composite
  • devcontainers/ci v0.3 composite
  • docker/login-action v3.3.0 composite
.github/workflows/docker-cd.yml actions
  • actions/checkout v4.2.2 composite
  • docker/build-push-action v6.10.0 composite
  • docker/login-action v3.3.0 composite
  • docker/metadata-action v5.6.1 composite
  • docker/setup-buildx-action v3.7.1 composite
  • docker/setup-qemu-action v3.2.0 composite
  • sigstore/cosign-installer v3.7.0 composite
.github/workflows/docker-ci.yml actions
  • actions/checkout v4 composite
  • dorny/paths-filter v3.0.2 composite
.github/workflows/greetings.yml actions
  • actions/first-interaction v1.3.0 composite
.github/workflows/labeler.yml actions
  • actions/labeler v5 composite
.github/workflows/pylint.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/python-ci.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • codecov/codecov-action v5.0.7 composite
  • devcontainers/ci v0.3 composite
.github/workflows/release-cd.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • pypa/gh-action-pypi-publish e7723a410eb01c55f02a75cf26a230ed14f1b19e composite
.github/workflows/release-drafter.yml actions
  • release-drafter/release-drafter v6 composite
.github/workflows/update-changelog.yaml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • stefanzweifel/changelog-updater-action v1 composite
  • stefanzweifel/git-auto-commit-action v5 composite
.github/workflows/weekly-poetry-bot.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.devcontainer/Dockerfile docker
  • mcr.microsoft.com/vscode/devcontainers/python 0-${VARIANT} build
Dockerfile docker
  • $BASE_CONTAINER latest build
poetry.lock pypi
  • 271 dependencies
pyproject.toml pypi
  • bandit ^1.7.5 develop
  • black ^24.0 develop
  • bump-pydantic ^0.8.0 develop
  • dash ^2.7.1 develop
  • mypy ^1.9.0 develop
  • pre-commit [{"version"=>"<=3.7.1", "markers"=>"python_version < '3.9'"}, {"version"=>"^3.7.1", "markers"=>"python_version >= '3.9'"}] develop
  • pytest >=7.1.3,<9.0.0 develop
  • pytest-clarity ^1.0.1 develop
  • pytest-console-scripts ^1.3.1 develop
  • pytest-cov >=3,<7 develop
  • pytest-mock ^3.10.0 develop
  • pytest-plt ^1.1.0 develop
  • pytest-xdist >=2.5,<4.0 develop
  • ruff ^0.8.0 develop
  • types-PyYAML ^6.0.11 develop
  • types-mock >=4.0.15,<6.0.0 develop
  • types-setuptools >=75.5.0.20241116,<75.7.0.0 develop
  • types-tabulate >=0.8.11,<0.10.0 develop
  • types-toml ^0.10.8 develop
  • jupytext ^1.14.5 docs
  • mathjax ^0.1.2 docs
  • mike ^2.0.0 docs
  • mkdocs-autorefs ^1.0.1 docs
  • mkdocs-jupyter [{"version"=>"<=0.25.0", "markers"=>"python_version < '3.9'"}, {"version"=>"^0.25.0", "markers"=>"python_version >= '3.9'"}] docs
  • mkdocs-literate-nav >=0.4.1,<0.7.0 docs
  • mkdocs-material ^9.5.0 docs
  • mkdocs-minify-plugin ^0.8.0 docs
  • mkdocs-section-index ^0.3.4 docs
  • mkdocs-table-reader-plugin ^3.0.0 docs
  • mkdocstrings >=0.26.0,<0.28.0 docs
  • PyYAML ^6.0
  • art >=5.8,<7.0
  • dash-bootstrap-components ^1.3.0
  • dash-bootstrap-templates [{"version"=>"<=1.1.2", "markers"=>"python_version < '3.10'"}, {"version"=>"^1.2.0", "markers"=>"python_version >= '3.10'"}]
  • dtale ^3.9.0
  • emcee ^3.1.2
  • ipywidgets ^8.0.4
  • itables ^2.1.1
  • jupyter-dash ^0.4.2
  • jupyterlab >=3.5.2,<5.0.0
  • kaleido [{"version"=>"^0.2.1", "markers"=>"python_version < '3.9'"}, {"version"=>"^0.4.1", "markers"=>"python_version >= '3.9'"}]
  • lmfit ^1.2.2
  • networkx ^3.0
  • numdifftools ^0.9.41
  • numpy [{"version"=>"<1.26.4", "markers"=>"python_version < '3.9'"}, {"version"=>"^1.26.4", "markers"=>"python_version >= '3.9'"}]
  • openpyxl ^3.0.9
  • pandas [{"version"=>"<2.2.1", "markers"=>"python_version < '3.9'"}, {"version"=>"^2.2.2", "markers"=>"python_version >= '3.9'"}]
  • plotly ^5.21.0
  • pydantic ^2.7.0
  • pydot ^3.0.0
  • python >=3.8,<3.13
  • python-pptx >=0.6.22,<1.1.0
  • scikit-learn [{"version"=>"<1.5.0", "markers"=>"python_version < '3.9'"}, {"version"=>"^1.5.0", "markers"=>"python_version >= '3.9'"}]
  • scipy [{"version"=>"^1.10.1", "markers"=>"python_version < '3.9'"}, {"version"=>"^1.13.0", "markers"=>"python_version >= '3.9'"}]
  • seaborn ^0.13.0
  • tabulate ^0.9.0
  • tomli ^2.0.1
  • tomli-w ^1.0.0
  • tqdm ^4.64.0