[AstroPy] Fwd: Help with finding absorption lines

Peter Dzwig pdzwig at summaventures.com
Thu May 28 10:01:33 EDT 2020


Xavier, Angela,

for absorption lines that looks like a good idea.

I still don't understand why astropy has such difficulties. Anyone any
comments on the code?

Xavier, I will look at ALIS for emission lines.

Peter



On 28/05/2020 13:22, J. Xavier Prochaska wrote:
> Consider
> 
> linetools -- https://github.com/linetools/linetools
> 
> and
> 
> ALIS -- https://github.com/rcooke-ast/ALIS
> 
> Built by scientists who study absorption lines for a living..
> 
> X
> 
> 
> On Thu, May 28, 2020 at 2:55 AM Angela Rodrigues
> <afonsoangelarodrigues at gmail.com
> <mailto:afonsoangelarodrigues at gmail.com>> wrote:
> 
>     Hi Dr. Peter
> 
>     Thank you kindly for your reply.
> 
>     Here's a folder with the file (it's an hdr file):
>     https://drive.google.com/file/d/1Rb25_mzAKq7ZqFI9fPyOX8TnTtspYxpF/view?usp=sharing
> 
>     I am looking for really small shifts that reflect chemistry, and
>     therefore, I cannot just eyeball it, I need the actual values.
>     Indeed it is a complicated task to do without specialized software.
>     Regarding the threshold, I've changed it multiple times between 0
>     and 20, and still no absorption values...
> 
>     Thank you so much for looking into it! :)
> 
> 
>     Peter Dzwig <pdzwig at summaventures.com
>     <mailto:pdzwig at summaventures.com>> escreveu no dia quinta,
>     28/05/2020 à(s) 19:15:
> 
>         Angela,
> 
>         first thing to be said is that I sympathize. :-)  I have had similar
>         issues although my datasets are very different (QSOs); the second is
>         that I can't open either of your files. Perhaps you tell us what
>         format
>         they are in.
> 
>         I tried running similar code to yours (despite the different
>         context). I
>         found that the answers, from both thresholding and derivative, I got
>         were quite sensitive to the data density per unit wavelength,
>         the amount
>         of noise in the data and the threshold that you set.
> 
>         Unless the data is sufficiently dense both thresholding and
>         derivative
>         will produce inaccurate or even false results.
> 
>         In the end I found the best solution was to make a table of all the
>         lines that I was interested in and simply overplot them on my
>         spectrum.
>         I can then see what's where and (using a combination of astropy and
>         numpy) re-plot and re-examine pertinent parts of the spectrum,
>         but as
>         ever the limiting factor is data density.
> 
>         I guess in your case the lines that you would plot would be Calcium,
>         Cerium, Lanthanum, Carbon, Flourine  - and Neodymium? and some
>         of their
>         molecular forms. Tables for most are available from NIST:
>         https://www.nist.gov/pml/atomic-spectra-database
> 
>         There probably is a best approach - a tutorial would be a good
>         idea -
>         and I will watch this space to see what solutions others offer.
> 
>         Regards,
> 
>         Peter Dzwig
> 
>         On 28/05/2020 08:43, Angela Rodrigues wrote:
>         > 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
>         >
>         > _______________________________________________
>         > AstroPy mailing list
>         > AstroPy at python.org <mailto:AstroPy at python.org>
>         > https://mail.python.org/mailman/listinfo/astropy
>         >
> 
>         -- 
> 
>         Dr. Peter Dzwig
> 
>     _______________________________________________
>     AstroPy mailing list
>     AstroPy at python.org <mailto:AstroPy at python.org>
>     https://mail.python.org/mailman/listinfo/astropy
> 
> 
> 
> -- 
> -- 
> ----------------------------------------------
> J. Xavier Prochaska
> UCO/Lick Observatory
> 1156 High St.
> UC Santa Cruz
> Santa Cruz, CA 95064
> 
> Affiliate of IPMU
> Affiliate of LBNL
> 
> http://www.ucolick.org/~xavier/
> https://aaii.ucsc.edu/
> http://www.ucolick.org/f-4 <https://www.ucolick.org/f-4>
> 
> 831-459-2135 (Direct)
> 831-459-2991 (UCO/Lick Main)
> 831-459-5244 (Fax)
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
> 

-- 

Dr. Peter Dzwig


More information about the AstroPy mailing list