Note
Go to the end to download the full example code
Storing imaging data
The management of imaging Raman spectroscopic data in RamanSPy is guided through the ramanspy.SpectralImage class.
See also
As the ramanspy.SpectralImage class extends the ramanspy.SpectralContainer class, most of its
functionality is inherited from this class. Hence, users are advised to first check the documentation of
the ramanspy.SpectralImage class and the Generic data container tutorial.
Below, we will inspect some of the main features the ramanspy.SpectralImage class provides on top of those inherited
through the ramanspy.SpectralContainer class.
import numpy as np
import ramanspy
We can define a spectral image by providing the relevant 3D intensity data array and the corresponding Raman wavenumber
axis, just as we initialise ramanspy.SpectralContainer instances. As an example, we will create a 50x50 spectroscopic
image, each point of which contains a Raman spectrum containing 1500 spectral points.
spectral_data = np.random.rand(50, 50, 1500)
spectral_axis = np.linspace(100, 3600, 1500)
raman_image = ramanspy.SpectralImage(spectral_data, spectral_axis)
Then, we can use all features of the ramanspy.SpectralContainer class as usual. For instance,
raman_image.shape
(50, 50)
At the moment, the only functionality the ramanspy.SpectralImage class provides over ramanspy.SpectralContainer
is the highly-customisable ramanspy.SpectralImage.plot(), which can be used to quickly visualise spectral slices
across Raman spectroscopic images.
# spectral slices across 1500 cm^-1 and 2500 cm^-1
raman_image.plot(bands=[1500, 2500])
[<Axes: title={'center': 'Raman image'}>, <Axes: title={'center': 'Raman image'}>]
We can also plot individual spectra within the image using indexing and ramanspy.Spectrum’s plot method.
raman_image[25, 25].plot()

<Axes: title={'center': 'Raman spectra'}, xlabel='Raman shift (cm$^{{{-1}}}$)', ylabel='Intensity (a.u.)'>
Total running time of the script: ( 0 minutes 0.157 seconds)

