I have a fits datacube with galactic longitude, latitude and velocity in the 3 axis. To extract the spectrum from the datacube at a particular pixel value of longitude and latitude, I use the function
cube[:, 1935, 1407].quicklook()
plt.show()
and the image is extracted with the function
cube.to_pvextractor()
plt.show()
A sample spectrum and a zoomed image is attached here.
The bright spots are the detections. How do I use several pixels and average the spectra to get a mean spectrum so that I reduce the noise and analyze the peak? I have been trying to code this but I don't know how to proceed as I am new to python. Can anybody please give a hint?
You can use spectrapepper for this:
The library has also other tools for data set analysis. Check example 6 included in the
docs
for more options of similar nature.