This Python script is designed to analyze RAMAN spectroscopy data. It processes raw data files, splits them into header and data sections, performs peak detection, and fits multiple Lorentzian models to the detected peaks.
Loved the project? Please consider giving a Star ⭐️ to help it improve!
- Automatic encoding detection for input files
- Splitting of input files into header and data sections
- Data visualization of raw RAMAN spectra
- Peak detection
- Multiple Lorentzian peak fitting
- Generation of fitted spectra plots
- Extraction and reporting of fitted peak parameters
- Python 3.x
- Required Python packages:
- csv
- chardet
- matplotlib
- numpy
- lmfit
- scipy
- Place your RAMAN data files in a folder named 'Data' in the same directory as the script.
- Run the script. It will process all files in the 'Data' folder.
- Results will be saved in a 'Results' folder, with subfolders for each processed file.
For each processed file, the script generates:
- A header file with the equipment parameters(header.txt)
- A CSV file with the raw data (data.csv)
- A plot of the raw spectrum (.png and .svg formats)
- A plot of the fitted spectrum with individual peak components (.png and .svg formats)
- A text file with detailed fit results (results_fitted.txt)
- A text file with summarized peak information (results_peaks_info.txt)
files_path_searcher
: Finds all files in the specified folderpath_helper
: Generates necessary file paths for outputdetect_encoding
: Automatically detects the encoding of input filessplit_file
: Splits the input file into header and data sectionsread_data
: Reads the data and generates a raw spectrum plotlorentzian
: Defines the Lorentzian function for peak fittinganalyze_data
: Performs peak detection, fitting, and generates result plots and files