I want to preface this by saying that I am working for a professor as a student software developer. I have no/little knowledge of spectroscopy so I may misuse or misunderstand scientific terms around the subject.
We have primarily worked with the Radis library to generate spectra based on user input. We then modify these spectra using different functions. Because of this, the portion (peaks) the user wants to see can be easily masked by noise in the spectrum.
If curious, here is our GitHub Repository for the front-end. We unfortunately do not have a working version yet that is hosted.
The important part is for this post is the code around finding the peaks. That can be found in this GitHub Repository.
find_peaks = spectrum.to_specutils()
noise_region = SpectralRegion((1 / data["minWave"]) / u.cm, (1 / data["maxWave"]) / u.cm)
find_peaks = noise_region_uncertainty(find_peaks, noise_region)
lines = find_lines_threshold(find_peaks, noise_factor=2)
From my current understanding, to_specutils()
converts our Radis spectrum into a specutils object. SpectralRegion()
then takes the starting and ending point (in our case the min and max) values and creates a variable that holds them. noise_region_uncertainty()
still does not make complete sense to me, this was in the Radis example of finding peaks. Then the last line find_lines_threshold()
finds the peaks.
My current guess is that because I am looking at a transmittance spectrum (which the peaks go down instead of up), the function is unable to find anything. However, I may not understand what I am doing.
Thank you for reading!
Since I am a new user I could only include two links in the previous post. Here are two more that I was unable to share:
The Radis Library
The Radis documentation we used to attempt to find the peaks
Hi, thanks for reaching out! I think I see a couple things that might be the source of the trouble you’re having. The find_lines_threshold
function attempts to find both emission and absorption lines (peaks up or down), but expects a continuum-subtracted spectrum as input. So you may need to subtract a fit to the continuum from your spectra before trying to find the lines (note that the spectrum in the Radis example is continuum-subtracted, you can see that the baseline is 0).
A related but separate problem might be your selection of the noise region. It looks like you’re using the whole spectrum as the noise region, which might mean that it’s calculating noise (which is just based on the standard deviation of the flux in the region selected) that is large enough (especially when multiplied by your noise factor of 2) that the algorithm doesn’t see any lines bigger than that. You may be able to use the whole spectrum as your noise region just fine - I would see if subtracting out the continuum fit before this step helps, and if it doesn’t you could try either decreasing your noise factor or selecting a region of the spectrum without lines as your noise region.
I hope this helps point you in the direction of a solution, let me know if you have more questions.
Regards,
Ricky
Hello Ricky,
Sorry for the delayed response. It has taken me a few days of looking and trying to understand your post. Unfortunately I do not understand much of anything your have stated when it comes to emission and absorption lines, continuum-subtracted spectrum, baseline, noise region, and standard deviation of the flux. If you could provide a description that is more designed for a layman that would be great.
When reading through the documentation for the functions they don’t appear to do anything similar to what I am trying for the entire range.
Thanks!