Package: raman-fitting
raman-fittingA Python framework that performs a deconvolution on typical parts of interest on the spectrum of carbonaceous materials.
The deconvolutions are done with models which are composed of collections of lineshapes or peaks that are typically assigned to these spectra in scientific literature.In batch processing mode this package will index the raman data files in a chosen folder.
First, it will try to extract a sample ID and position number from the filenames and create an index of the files in a dataframe. Over this index a preprocessing, fitting and exporting loop will start.
There are several models, each with a different combination of typical peaks, used for fitting. Each individual typical peak is defined as a class in the deconvolution/default_peaks folder with some added literature reference in the docstring. Here, the individual peak parameter settings can also be easily adjusted for initial values, limits, shape (eg. Lorentzian, Gaussian and Voigt) or be fixed at certain initial values.
Export is done with plots and excel files for the spectral data and fitting parameters for further analysis.Example plotshttps://github.com/MyPyDavid/raman-fitting/wikiSet up virtual environment and install the packageA release is now available on PyPI, installation can be done with these commands in a terminal.# Setting up and activating a virtual environmentpython-mvenvenv# python 3.11 is recommendedsourceenv/bin/activate# Installation from PyPIpython-mpipinstallraman_fittingFrom source installationThe following shows how to install the package from this source repository.
Download or clone this repository in a certain folder.gitclonehttps://github.com/MyPyDavid/raman-fitting.git# set up and activate venv ...# regular installpython-mpipinstallraman-fitting/# editable/develop modepython-mpipinstall-eraman-fitting/UsagePost installation test runIn order to test the package after installation, please try the following command in a terminal CLI.raman_fitting-Mmake_examplesor these commands in the Python interpreter or in a Jupyter Notebook.importraman_fittingraman_fitting.make_examples()This test run should yield the resulting plots and files in the following folder. Where home means the local user home directory depending on the OS.# Linuxhome/.raman_fitting/example_results# For Other OSs, log messages will show:# Results saved in ...Fitting your own datafilesPlace your data files in the default location or change this default setting in the config.home/.raman_fitting/datafilesThe following command will attempt the indexing, preprocessing, fitting and plotting on all the files found in this folder.# default run mode is "normal" means over all the files found in the indexraman_fitting# If you add a lot of files, try to check if the index is properly constructed# before fitting them.raman_fitting-Mmake_index# Location of indexhome/.raman_fitting/datafiles/results/raman_fitting_index.csvDatafilesThe raman data files should be .txt files with two columns of data values.
The first column should contain the Raman shift values and the second one the measured intensity.
Filenames will be parsed into a sampleID and position, in order to take the mean of the measured intensity
of several positions on the same sample.An example of filename formatting and parsing result:samplename1_pos1.txt=>sampleID='samplename1',position=1sample2-100_3.txt=>sampleID='sample2-100',position=3VersionThe current version is v0.7.0Dependenciespython >= 3.11lmfit >= 1.2.0pandas >= 2.0.0scipy >= 1.10.1matplotlib >= 3.7.2numpy >= 1.24.2