raman - Analysis of spontaneous and time-resolved Raman spectra

A collection of functions to process and analyze Raman spectra. These functions work both for spontaneous Raman as well as femtosecond stimulated Raman data. The import functions for spontaneous Raman are optimized for Princeton Instruments’ WinSpec ASCII files, while those for FSRS expect the files in the output format of pyFSRS or David Hoffman’s LabView FSRS.

Changelog:

10-13-2015:

  • Some bug fixes.
  • Added more functionality for analyzing TA data, e.g. automated kinetics stripping.

01-04-2016:

  • Changed type of padding in FT_baseline_correction.
  • Added moving-median based baseline correction (MM_baseline_correction).
  • Added support for analysis of shifted-excitation or frequency-modulated FSRS spectra (reconstruct_FM_spectrum).

Data Import Functions

loadRaman(filename) Load ASCII Raman (or other) data.
loadFSRS(basename[, wn, timesteps, excstr, ...]) Load and average all FSRS files matching the basename (e.g.
loadTA(basename[, wl, timesteps, excstr, ...]) Convenience function for loading transient absorption data.

Data Selection / Normalization

norm(y[, mode]) Normalize 1d spectrum.
cut(x, y, x0, x1) Cut out a subarray from x and y according to the closed interval [xfrom, xto].
at(x, y, x0) Return the value of y with x-coordinate closest to x0.

Calibration Functions

Raman2WL(lambda0, lines) Convert Raman shift (cm-1) to wavelength (nm) for given pump wavelength lambda0.
WL2Raman(lambda0, lines) Convert wavelength (nm) to Raman shift (cm-1) for given pump wavelength lambda0.
get_closest_maximum(x, y, x0) Returns the position and value of the (local) maximum closest to x0.
interpolate(x, y[, N, kind]) Convenience wrapper around SciPy’s interp1d() function.
mol_lines([mol, window, sorted]) Returns a list of vibrational frequencies for commonly used standards.
calibrate(y, lambda0, peaks, mol[, show]) Returns a calibrated x-axis in wavenumbers using a calibration spectrum and a list of vibrational modes.

Frequency-Modulated FSRS Reconstruction Functions

reconstruct_FM_spectrum(y, delta[, MMw, ...]) Reconstruct Raman spectrum A from a shifted-excitation of frequency-modulated spectrum A - B.

Filtering / SNR Improvement Functions

filter_outliers(y[, eps]) Returns a list of indices for datasets that NOT outliers.
savitzky_golay(y, window_size, order[, deriv]) Implementation of the Savitzky Golay filter.
noise_estimate(y) Estimate the standard deviation of Gaussian white noise contained in a spectrum.
denoise(y) Fully automatic optimized smoothing algorithm.
FT_denoise(y[, cutoff, filter]) Apply a Fourier low pass filter to the data to remove high frequency noise.

Baseline Correction Functions

rayleigh_correction(y) Remove the baseline arising from the Rayleigh line by fitting a Gauss-Lorentz curve to the data.
interpolated_bl_correction(x, y, px[, py, ...]) Remove a baseline obtained by interpolating a set of fulcrums.
baseline_correction(y[, n0, verbose, iterate]) Automated baseline removal algorithm.
FT_baseline_correction(y[, cutoff, filter]) Automatic baseline correction based on a Fourier high pass filter after removal of regression line.
MM_baseline_correction(y[, w]) Baseline correction based on a moving median filter.

Solvent / Ground State Subtraction Functions

solvent_subtract(y, solvent, peaks[, ...]) Subtract solvent or ground state spectrum from a spectrum or a list of spectra.
solvent_subtract_chi2(y, solvent[, scaling, ...]) Subtract a solvent or ground state spectrum from a spectrum or list of spectra.

Time Zero Functions

shift_data(x, y, dx) Smoothly translate 1d data by an arbitrary amount along the x-axis using Fourier transformation.
correct_t0(t, d, c) Shift all frequency columns in d along the time axis to correct t0 to 0.

Peak Fitting / Manipulation Functions

find_peaks(y[, wnd, ath, sth, bl, useMMBL, ...]) Automated peak finding algorithm based on zero crossings of smoothed derivative as well as on slope and amplitude thresholds.
pick_peaks(x[, y]) Utility function to quickly extract x coordinates of points from data by double clicking in a plot window.
pick_peaks_x_y(x[, y]) Utility function to quickly extract x and y coordinates of points from data by double clicking in a plot window.
get_peak_estimate(x, y, peaks) Returns a list of estimated peak parameters from a spectrum for each peak whose approximate x-coordinate is listed in peaks.
fit_peaks(x, y, popt0, fit_func[, bounds, ...]) Try to fit Raman peaks with (automatic) baseline fitting.
peak_remove(y, peaks) Remove (narrow) peaks like single pixel artefacts from Raman data by linear interpolation.
peak_area(y, peaks) Returns the area under the spectrum in a given interval after removing a linear baseline.

TA Analysis Functions

bandintegral(x, y, x0, x1) Calculate the band integral over time dependent data.
plotTA(t, wl, d[, showContour, filename, ...]) Convenience function to generate a fancy TA contour plot using matplotlib’s contour and contourf functions.
strip_kinetics(y[, Nmax, verbose, tryIRF, ...]) Automatically remove slow kinetics from a (single) TA trace.
TAFFT(t, y[, padlength, wnd]) Calculate the Fourier transform of a 2d transient absorption signal after stripping of the slow kinetics over the time axis.