When one observes the spectrum of a source of light, the x-axis of the spectrum is in pixels. To convert this to wavelengths, it is used a spectrum of a well know source of light, e.g., the light of a lamp of ThAr. The spectrum of the lamp has known emission lines, thus it is possible to convert from pixel to wavelngth.
From theory, the emission lines of the lamp spectrum should be infinitely narrow. Unfortunately, this does not happens because of the optics of the instrument, which broadens the spectrum. When studying spectral lines of unknown sources, this broadeing effect has to be considered.
I have copied a spectrum of a real lamp and it can be seen in the plot below.
Let's first start with a slice of this spectrum and try to see if it detects the peaks. The value of the delta threhsold in flux is very important. It defines which peaks are chosen. If the values increases, only the strong lines are picked.
The detection is OK. We can now obtain the instrumental profile of the entire spectrum.
But note that it is not perfect and can obtain very strange values of FWHM. We can manually set an upper limit.