Maps
Rampy offers the possiblity to analyse maps from Raman spectrometers using the rampy.maps
module.
Line and 2D Maps saved in CSV or TXT format from Horiba and Renishaw spectrometers can be loaded, and various data treatments can be performed afterwards.
Below you will find the documentation of the rampy.maps
module, and have a look at the example notebooks too for further examples of use: Example notebooks
- class rampy.maps(file, spectrometer_type='horiba', map_type='2D', despiking=False, neigh=4, threshold=3)
Bases:
object
Class for handling and analyzing Raman spectral maps.
This class provides methods for reading, processing, and analyzing 1D or 2D Raman spectral maps from Horiba or Renishaw spectrometers.
- Parameters:
file (str) – Path to the map file.
spectrometer_type (str, optional) – Type of spectrometer. Must be either ‘horiba’ or ‘renishaw’. Defaults to ‘horiba’.
map_type (str, optional) – Type of map. Must be either ‘2D’ or ‘1D’. Defaults to ‘2D’.
despiking (bool, optional) – Whether to perform despiking on the spectra. Defaults to False.
neigh (int, optional) – Number of neighboring points for despiking. Defaults to 4.
threshold (float, optional) – Threshold for spike detection. Defaults to 3.
- Raises:
ValueError – If map_type is not ‘1D’ or ‘2D’.
- area(y, region_to_investigate)
Calculates the area under the curve in a specified region.
The area is computed via trapezoidal integration (np.trapz).
- Parameters:
y (ndarray) – Intensities to analyze (e.g., self.I_normalised).
region_to_investigate (array-like) – [min, max] values of the region to integrate.
- Returns:
None. Sets self.A with the integrated areas for the map.
- area_ratio(y, region_to_investigate)
Calculates the area ratio between two regions of interest.
The ratio is computed as the integrated area in region 1 divided by the area in region 2.
- Parameters:
y (ndarray) – Intensities to analyze (e.g., self.I_normalised).
region_to_investigate (ndarray) – 2x2 array, each row [min, max] for the two regions.
- Returns:
None. Sets self.A_ratio with the area ratios for the map.
- background(bir, method='poly', **kwargs)
Corrects background from the signal using rampy.baseline.
Applies baseline correction to each spectrum in the map using the specified method.
- Parameters:
bir (ndarray) – Regions of interest for baseline fitting.
method (str, optional) –
Baseline correction method. Defaults to ‘poly’. Supported methods include:
’poly’: Polynomial fitting.
’unispline’: Spline fitting (UnivariateSpline).
’gcvspline’: GCVSpline fitting.
’gaussian’: Gaussian function fitting.
’exp’: Exponential fitting.
’log’: Logarithmic fitting.
’rubberband’: Rubberband correction.
’als’: Asymmetric Least Squares.
’arPLS’: Asymmetrically Reweighted Penalized Least Squares.
’drPLS’: Doubly Reweighted Penalized Least Squares.
’whittaker’: Whittaker smoothing.
’GP’: Gaussian process method.
**kwargs – Additional method-specific parameters, such as: roi (ndarray): Regions of interest (default: full range). polynomial_order (int): Polynomial degree for ‘poly’. s (float): Spline smoothing parameter. ese_y (ndarray): Errors for ‘gcvspline’. lam (float): Smoothness parameter for ‘als’, ‘arPLS’, etc. p (float): Weighting parameter for ‘als’. ratio (float): Convergence ratio for ‘arPLS’, ‘drPLS’. niter (int): Number of iterations for ‘als’, ‘drPLS’. eta (float): Roughness for ‘drPLS’. p0_gaussian (list): Initial params for ‘gaussian’. p0_exp (list): Initial params for ‘exp’. p0_log (list): Initial params for ‘log’.
- Returns:
None. Sets self.I_background and self.I_corrected with the background and background-corrected spectra.
- centroid(y, region_to_investigate)
Calculates the centroid in a given region of interest.
- Parameters:
y (ndarray) – Intensities to analyze (e.g., self.I_normalised).
region_to_investigate (array-like) – [min, max] values of the region where the centroid is measured.
- Returns:
None. Sets self.centroid_position with the centroid positions for the map.
- intensity(y, region_to_investigate)
Finds the maximum intensity in a specified region.
The maximum is estimated using np.max within the region.
- Parameters:
y (ndarray) – Intensities to analyze (e.g., self.I_normalised).
region_to_investigate (array-like) – [min, max] values of the region to search for the maximum.
- Returns:
None. Sets self.I_max with the intensity maxima for the map.
- intensity_ratio(y, region_to_investigate)
Calculates the intensity ratio between two regions of interest.
The ratio is computed as the maximum intensity in region 1 divided by the maximum in region 2.
- Parameters:
y (ndarray) – Intensities to analyze (e.g., self.I_normalised).
region_to_investigate (ndarray) – 2x2 array, each row [min, max] for the two regions.
- Returns:
None. Sets self.I_ratio with the intensity ratios for the map.
- normalise(y, method='intensity')
Normalises the spectra using rampy.normalise.
- Parameters:
y (ndarray) – Intensities to normalise (e.g., self.I_corrected).
method (str, optional) – Normalisation method. One of ‘area’, ‘intensity’, or ‘minmax’. Defaults to ‘intensity’.
- Returns:
None. Sets self.I_normalised with the normalised spectra.
- smooth(y, method='whittaker', **kwargs)
Smooths spectra using rampy.smooth.
- Parameters:
y (ndarray) – Intensities to smooth (e.g., self.I_corrected).
method (str, optional) – Smoothing method. Supported methods include: ‘savgol’, ‘GCVSmoothedNSpline’, ‘MSESmoothedNSpline’, ‘DOFSmoothedNSpline’, ‘whittaker’, ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’. Defaults to ‘whittaker’.
**kwargs – Additional method-specific parameters, such as: window_length (int): Length of the filter window (for Savitzky-Golay). polyorder (int): Polynomial order (for Savitzky-Golay). Lambda (float): Smoothing parameter for Whittaker filter. d (int): Parameter for Whittaker filter. ese_y (ndarray): Errors for spline algorithms.
- Returns:
None. Sets self.y_smoothed with the smoothed spectra.
The following functions are also available and used in the rampy.maps
class to load spectra from different spectrometers.
- rampy.read_renishaw(file)
read Renishaw csv maps
- Parameters:
file (str) – filename, including path
- Returns:
X (m by n array) – X positions
Y (m by n array) – Y position
lambdas (m by n array) – Raman shift
intensities (m by n array) – Intensities
- rampy.read_horiba(file, map_type='2D')
read Horiba csv maps (1D, 2D)
- Parameters:
file (str) – filename, including path
map_type (str) – 1D map (line) or 2D map, default: 2D
- Returns:
X (m by n array) – X positions
Y (m by n array) – Y position
lambdas (n array) – Raman shift
intensities (m by n array) – Intensities