# How to plot graph the intensity versus wavelength for the spectrum?

0 Votes
378 Views

Need to plot graph the intensity versus wavelength for the spectrum. Also, me need to determine the wavelengths from the graph (the image below): With which program I can do this? I searched in Google program, but they all work with video (example theremino spectrometer)?. I need to work the image.

## Answers

1. That’s not a graph but a picture. Anyhow you can get started as follows.

You can load the image with `scipy`. Then, in the simplest case, do a horizontal cut which will give you intensity vs pixel position.

``````import scipy.misc as misc
import matplotlib.pyplot as plt

img = misc.imread('spectrum.png', mode='L')
mid_line = img[len(img)//2]
plt.plot(mid_line)
plt.show()
``````

There is quite some background luminosity there. Doing a vertical averaging would give a smoother spectra (`img_mean = img.mean(axis=0)`).

Then you have to find a way to “calibrate” the pixel positions to wavelength. For that you need an external source of “truth”, which I don’t know what you have available. For example you can say that the maximum at the green line is 510 nm (pixel 405) and the bright blue one 460 nm (pixel 302). Then, depending on your experimental setup you might be able to say that the distance in pixels is linear with wavelength and then you have you conversion.

Hope this guides you a bit. Ignacio Vergara Kausel