Little python library for the data analysis of simple university experiments (mainly electronics and gamma spectroscopy experiments)
Benedetta Rasera
benedetta.rasera@studenti.unipd.it, raserab3nedetta@gmail.com
Developed as part of the Master's Degree in Physics at the University of Padua
If you need any clarification or want to annotate possibile errors in the library please write me an email with "BASICFUNC LIBRARY - GitHub" in the object. If you are an UNIPD student please write me with your institutional account.
So far some comments are still in Italian, I will translate them into English as soon as possible.
It is so far provided with
- gaussian fitting,
- background subtraction (for example of background spectra from emission spectra)
- Compton edge fitting (with an errorfunction)
- linear fitting
- exponential fitting
- parabolic fitting
- Lorentzian fitting
- Breit-Wigner fitting
- lognormal fitting
- Bode diagram fitting
A fit of a gaussian and an exponential convoluted will be added soon.
numpymatplotlibscipy
After importing the file in your code (e.g. as import basicfunc as bf), you can use any function directly.
In the repository you can also find a Jupyter Notebook called bfexamples.ipynb where there is an example for each of the functions of the library, please have a look at it.
For example if you want to use the function called normal to fit a gaussian function over some data with a normal trend you can write in your code what follows:
bf.normal(data=data_to_fit, xlabel="X-axis", ylabel="Y-axis", titolo='title', xmin=xmi, xmax=xma, x1=x_1, x2=x_2, b=k, n=n_i, plot=True)
and it will return you:
1. A numpy array with the parameters
2. A numpy array with the uncertainties
3. A numpy array with the residuals
4. The chi squared
5. The reduced chi squared
6. The integral of the histogram in the range mu ± n*sigma
7. The plot data (x_fit, y_fit, bin_centers, counts) if you need to plot other thing
Morevoer it will provide you the plot within x1 and x2 with the labels and title you set, with a gaussian fitted on top within xmin and xmax
If you want to use the linear regression function your code will be:
bf.linear(datax, datay, errorx, errory, 'xlabel', 'ylabel', titolo='title', plot=True)