[AstroPy] Fwd: Help with finding absorption lines

Angela Rodrigues afonsoangelarodrigues at gmail.com
Thu May 28 03:43:46 EDT 2020


Hello,

I have been trying to use astropy to extract lines of absorption from a
mineral spectrum.
so I have the attached hdr file with the spectral analysis from a mineral.
The code to extract the data from the file is as follows:

import spectral.io.envi as envi
lib = envi.open('GFZ_HySpex_REMin.hdr')

a=lib.metadata
wvl = a.get('wavelength')
wvl = [int(float(i)) for i in wvl]

import matplotlib.pyplot as plt
plt.plot(wvl,spectra[13])

#grab spectra for parisite
names = lib.names

spectra_parisite = spectra[8]
plt.plot(wvl, spectra_parisite)


I wanted to extract the absorption lines as in the documentation example
here <https://specutils.readthedocs.io/en/stable/fitting.html>.
Here's what I've done:


w = np.array(wvl)

import astropy.units as u
w = w*u.nm
spectra_parisite = spectra_parisite*u.Jy
from specutils import Spectrum1D, SpectralRegion
spectrum = Spectrum1D(spectral_axis = w, flux = spectra_parisite)

from matplotlib import pyplot as plt
plt.plot(spectrum.spectral_axis, spectrum.flux)
plt.xlabel('Spectral Axis ({})'.format(spectrum.spectral_axis.unit))
plt.ylabel('Flux Axis({})'.format(spectrum.flux.unit))
plt.grid(True)

from specutils.manipulation import noise_region_uncertainty
noise_region = SpectralRegion(450*u.nm, 2500*u.nm)
spectrum2 = noise_region_uncertainty(spectrum, noise_region)

from specutils.fitting import find_lines_threshold
lines = find_lines_threshold(spectrum2, noise_factor=0)
lines[lines['line_type'] == 'absorption']
lines[lines['line_type'] == 'emission']

# Derivative technique
from specutils.fitting import find_lines_derivative
lines = find_lines_derivative(spectrum2, flux_threshold=0)
lines[lines['line_type'] == 'absorption']


However, I get no absorption feature lines. Am I doing something wrong? The
emission zones seem to be alright, but I really need the absorption loci.
Thank you so much for your help!!
Warm regards,
Angela Rodrigues
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20200528/73bbc2fc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GFZ_HySpex_REMin
Type: application/octet-stream
Size: 45696 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20200528/73bbc2fc/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GFZ_HySpex_REMin.hdr
Type: application/octet-stream
Size: 6193 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20200528/73bbc2fc/attachment-0003.obj>


More information about the AstroPy mailing list