GithubHelp home page GithubHelp logo

forjobs / spectrafit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anselmoo/spectrafit

0.0 1.0 0.0 6.72 MB

๐Ÿ“Š๐Ÿ”ฌ SpectraFit is a command-line tool for quick data-fitting based on the regular expression of distribution functions.

Home Page: https://anselmoo.github.io/spectrafit/

License: BSD 3-Clause "New" or "Revised" License

Python 99.39% Dockerfile 0.61%

spectrafit's Introduction

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

SpectraFit

SpectraFit is a command line tool for quick data fitting based on the regular expression of distribution and linear functions. Furthermore, it can be also used as a module in existing python code. A previous version of SpectraFit was used for the following publication:

Now, it is completely rewritten and is more flexible. It is supporting all common ASCII-data formats and it runs on Linux, Windows, and MacOS.

Scope

  • Fitting of 2D data
  • 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

Installation

via pip:

pip install spectrafit

# Upgrade

pip install spectrafit --upgrade

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
spectrafit data_file.txt -i input_file.json
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
                        'spectrafit_results'.
  -i INPUT, --input INPUT
                        Filename for the input parameter, default to set to
                        'fitting_input.toml'.Supported fileformats are:
                        '*.json', '*.yml', '*.yaml', and '*.toml'
  -ov, --oversampling   Oversampling the spectra by using factor of 5;
                        default to False.
  -e0 ENERGY_START, --energy_start ENERGY_START
                        Starting energy in eV; default to start of energy.
  -e1 ENERGY_STOP, --energy_stop ENERGY_STOP
                        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.
  -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`.

Documentation

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

spectrafit's People

Contributors

anselmoo avatar dependabot[bot] avatar pre-commit-ci[bot] avatar imgbotapp avatar

Watchers

qiwuxiaoyao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.