CFit: An online curve fitting tool
December 30, 2023
CFit is a curve fitting tool written in Python, based on the method of least squares. It comes equipped with some standard functions used in physics, and a graphical user interface built using Streamlit. Some of the functions provided are: polynomials from linear upto quintic; periodic functions like sine and square waves; peaked functions such as Gaussian, Lorentzian, Poisson, Laplacian; and monotonic functions like exponential, power law, and logarithmic.
Under the hood, the code calls scipy.optimize.curve_fit, but the real strength of this tool lies in the fact that by looking at the range, scale and behaviour of the data, the code automatically provides a initial guess for the parameters for curve_fit to work with. Of course, if the user decides, they can also provide their own initial guess, which can be useful in cases where the code fails to work.
This initially started as a passion project during the COVID-19 lockdown in 2020, partly inspired by a similar, much more basic tool used at the University of Manchester called ‘LSFR.py’ (by Abie Marshall, 2016). The code was written in a few days, but the GUI took a couple weeks to get right (with a v2.0 built in 2023, and v3.0 built in 2026).