Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

fitPlot

A simple lab 1-stop-shop utility for all plot fitting purposes.

Installation

In the cloned repository,

# Create and activate virtual environment
python -m venv .
source bin/activate  # On Windows: bin\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Use

It supports plotting the following predefined functions:

  • Lorentzian
  • Gaussian
  • Exponential
  • Exponential Decay
  • Power law
  • Linear
  • Quadratic
  • Cubic
  • Sinusoidal
  • Damped oscillation
  • Logarithmic
  • Stretched Exponential

As well as the ability to input custom functions.

You can input all information in the cli or simply use a csv file.

To start fitting,

source bin/activate  # On Windows: bin\Scripts\activate
python fitPlot.py

and follow the CLI to fit your needs.

You can fit multiple datasets, each with its unique fitting function with automatic estimation and statistical output.

Embedding

Beyond the CLI, fitPlot can be imported and used programmatically. The predefined model functions and a non-interactive fit() core are importable directly:

from fitPlot import gaussian, fit

result = fit(gaussian, x_data, y_data, p0=[A, mu, sigma, c], func_name="Gaussian")
print(result["params"])      # fitted parameters
print(result["perr"])        # 1-sigma uncertainties
print(result["r_squared"])   # goodness of fit
print(result["formula"])     # formatted formula string (when func_name given)

fit() runs no interactive prompts, so it is safe to call from other scripts. The CLI (python fitPlot.py) is guarded under if __name__ == "__main__", so importing the module does not trigger it.

Test

1 test file was provided. It contains 3 datasets of 50 points, each. These datasets are fitted by the logarithmic, exponantial decay and quadratic options.

This test is simple but showcases the capability of this utility.

About

A flexible all-in-one tool for plot fitting using python. Supports multiple datasets, functions and csv inputs with statistical output.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages