Skip to main content

A Raman peak finder and model fitter

Project description

ramanfitter

This package seeks to provide and easy and efficient matter for fitting Raman data with Lorentzian, Gaussian, or Voigt models.

Developed by John Ferrier, NEU Physics (c) 2022

Quickstart Example

For a simple run,

import os
import numpy as np
from ramanfitter import RamanFitter

filename    = os.path.join( 'path', 'to', 'data.csv' )      # Get File
data        = np.genfromtxt( filename, delimiter = ',' )    # Open File

x           = data[ :, 0 ]                                  # Parse x-values
y           = data[ :, 1 ]                                  # Parse y-values

RF          = RamanFitter( x = x, y = y, autorun = True )   # Run Fitter automatically

components  = RF.comps                                      # Returns a dictionary of each curve plot
curveParams = RF.params                                     # Returns a dictionary of the parameters of each Lorentzian, Gaussian, or Voigt curve
bestFitLine = RF.fit_line                                   # Returns the plot data of the model

For more control over parameters

import os
import numpy as np
from ramanfitter import RamanFitter

filename    = os.path.join( 'path', 'to', 'data.csv' )      # Get File
data        = np.genfromtxt( filename, delimiter = ',' )    # Open File

x           = data[ :, 0 ]                                  # Parse x-values
y           = data[ :, 1 ]                                  # Parse y-values

RF          = RamanFitter( x = x, y = y, autorun = False )  # Run Fitter automatically


''' Each step ran when autorun = False '''
RF.NormalizeData()
RF.Denoise( ShowPlot = True )
RF.FindPeaks( showPlot = True )
RF.FitData( type = 'Voigt', showPlot = True )


components  = RF.comps                                      # Returns a dictionary of each curve plot
curveParams = RF.params                                     # Returns a dictionary of the parameters of each Lorentzian, Gaussian, or Voigt curve
bestFitLine = RF.fit_line                                   # Returns the plot data of the model

On 0.0.3, a new Mapper feature is added for handling mapped data. This example below creates a 4K video across a sweep of frequencies.

from ramanfitter.mapper import Mapper

here    = os.path.abspath( os.path.dirname( __file__ ) )
fname   = os.path.join( here, 'sample_map', 'sample.txt' )
MP      = Mapper( file = fname, display_name = "Sample 1", output_path = os.path.join( here, 'sample_map' ), delimiter = ',', provided_img=img, makePlot=False, makeVideo=True, plotType='imshow', resolution = '4k')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ramanfitter-0.0.3.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

ramanfitter-0.0.3-py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page