<p>Yes, there is are two python modules called <a href="http://www.astropy.org/" rel="noreferrer">astropy</a>, and <a href="http://pythonhosted.org/Astropysics/" rel="noreferrer">astropysics</a> that both claim to have spectral analysis tools. As a reference, here is a link for <a href="http://www.astropython.org/resources" rel="noreferrer">resources</a> for astronomers for the python programming language.  </p>

CC BY-SA 3.0
2013-10-21T22:33:06.297Z
2013-10-21T22:33:06.297Z
astromax
<p>There are plenty of software and tools available to do what you want:</p>

<ul>
<li><a href="http://iraf.noao.edu/" rel="nofollow noreferrer">IRAF</a>, by NOAO;</li>
<li><a href="http://www.eso.org/sci/software/esomidas/" rel="nofollow noreferrer">MIDAS</a> which is basically very similar to IRAF but developed by ESO;</li>
<li>in Python, either <a href="http://www.astropy.org" rel="nofollow noreferrer">astropy</a> or <a href="http://www.stsci.edu/institute/software_hardware/pyraf" rel="nofollow noreferrer">pyRAF</a> (to use IRAF with a Python interface).</li>
</ul>

<p>I would go with some Python tools (Python is more versatile than IRAF or MIDAS that are much more "single-purpose" oriented), to benefit from the other features offered by Python.</p>

<p>But to plot and process your spectrum is just the first part of the work, what you would probably want to do in the end is to use spectral synthesis, to analyze your spectrum. Spectral synthesis will allow you:</p>

<ul>
<li>to identify efficiently the chemical composition of the celestrial object you study;</li>
<li>to determine some properties of the celestial object you study.</li>
</ul>

<p>Among the existing tools for spectral synthesis (for stellar spectra for example), there are:</p>

<ul>
<li><a href="http://www.pages-perso-bertrand-plez.univ-montp2.fr/" rel="nofollow noreferrer">Turbospectrum</a> by Bertrand Plez;</li>
<li><a href="http://www.astro.mat.uc.pt/BaSeL2/" rel="nofollow noreferrer">BaSeL</a> by Thibault Lejeune</li>
</ul>

CC BY-SA 3.0
2013-10-22T14:12:41.590Z
Thanks. I just want to know the positions of line center.
questionhang
CC BY-SA 3.0
2013-10-22T13:35:42.963Z
2017-06-20T04:49:06.127Z
2017-06-20T04:49:06.127Z
MBR
<p>The programs I am aware of that you could use do require some programming expertise to operate. I would recommend looking at either <a href="http://iraf.noao.edu">IRAF</a> (or <a href="http://www.stsci.edu/institute/software_hardware/pyraf">PyRAF</a>, which uses Python to interface with IRAF), or <a href="http://www.as.utexas.edu/~chris/spectre.html">SPECTRE</a>. Unfortunately, I'm not aware of a "black box" solution where you can just press a button and go.</p>

<p>SPECTRE is written in FORTRAN77 and is quite easy to use once you get the hang of it, though it has a somewhat limited feature set and the documentation is brief. It will help you to manually fit Gaussians to spectral lines, giving their central wavelengths and equivalent widths. A caveat for SPECTRE is that it requires the plotting package <a href="http://www.astro.princeton.edu/~rhl/sm/">SuperMongo</a>, which is not free software. If you are affiliated with a university, most Physics and Astronomy departments should have a license.</p>

<p>IRAF is a quite fully-featured, free, cross-platform application purposefully built for astronomical image analysis. It can help you measure the spectral lines, and can analyse the spectrum to determine the object's radial velocity.</p>

CC BY-SA 3.0
2013-10-22T10:09:10.930Z
how about writing our own python code to do it?All we have to do is analyse lots of wavlength-flux data sets from lots of spectra.
questionhang
CC BY-SA 3.0
2013-10-22T11:03:43.003Z
Go for it. Often it's easiest to write your own code, especially if you have large data sets to crunch through.
Moriarty
CC BY-SA 3.0
2013-10-22T12:12:18.923Z
First find a local maximum and then fit it with a Gaussian profile. This method is too easy to believe. Anything  I miss?
questionhang
CC BY-SA 3.0
2013-10-22T21:55:20.683Z
Yep, that's just about it. If you want to find local maxima computationally, applying some median smoothing (depending on noise levels) and then using its derivatives can work well. This piece of code does just that (I don't think it would work well for what you want as-is, though it will serve as a working example of what you might want to do). http://adsabs.harvard.edu/abs/2007A%26A...469..783S
Moriarty
CC BY-SA 3.0
2013-10-22T09:07:13.330Z
2013-10-22T09:07:13.330Z
Moriarty
<p>Is there any handy module to detect emission lines in a spectrum like one we get from the Sloan Digital Sky Survey (SDSS)?</p>

<p>You can see there are many emission lines like Ha,OI in the spectrum below. In fact the spectrum is a two column data set, wavelength and flux. It is a combination of lots of scatter points. The typical interval between two points nearyby is 1.5 angstroms. I need to find all the Gaussian bumps and their line center.<br></p>

<p>So,first I need to find the the bumps and then I need to fit them to get their centers.</p>

<p><img src="https://i.sstatic.net/u0gKm.png" alt="enter image description here"></p>

CC BY-SA 3.0
2013-10-22T03:21:58.943Z
I could probably give you a detailed answer if you tell me what you want to do with the spectrum. Rigorous spectrum analysis is not usually a trivial affair.
Moriarty
CC BY-SA 3.0
2013-10-22T08:29:25.160Z
I have updated my post.Maybe it is easy to understand now.
questionhang
<spectra><sky-survey>
How to detect emission lines in optical spectra?
questionhang
# How to detect emission lines in optical spectra?

(Asked by: username_0 on 2013-10-21)

Is there any handy module to detect emission lines in a spectrum like one we get from the Sloan Digital Sky Survey (SDSS)?

You can see there are many emission lines like Ha,OI in the spectrum below. In fact the spectrum is a two column data set, wavelength and flux. It is a combination of lots of scatter points. The typical interval between two points nearyby is 1.5 angstroms. I need to find all the Gaussian bumps and their line center.

So,first I need to find the the bumps and then I need to fit them to get their centers.

![enter image description here](https://i.sstatic.net/u0gKm.png)

**Tags:** spectra, sky-survey

> **Comments:**
> **username_1**: I could probably give you a detailed answer if you tell me what you want to do with the spectrum. Rigorous spectrum analysis is not usually a trivial affair.  
> **username_0**: I have updated my post.Maybe it is easy to understand now.  

---

## 3 answers

### Answer by username_1 on 2013-10-22. Score: 8

The programs I am aware of that you could use do require some programming expertise to operate. I would recommend looking at either [IRAF](http://iraf.noao.edu) (or [PyRAF](http://www.stsci.edu/institute/software_hardware/pyraf), which uses Python to interface with IRAF), or [SPECTRE](http://www.as.utexas.edu/~chris/spectre.html). Unfortunately, I'm not aware of a "black box" solution where you can just press a button and go.

SPECTRE is written in FORTRAN77 and is quite easy to use once you get the hang of it, though it has a somewhat limited feature set and the documentation is brief. It will help you to manually fit Gaussians to spectral lines, giving their central wavelengths and equivalent widths. A caveat for SPECTRE is that it requires the plotting package [SuperMongo](http://www.astro.princeton.edu/~rhl/sm/), which is not free software. If you are affiliated with a university, most Physics and Astronomy departments should have a license.

IRAF is a quite fully-featured, free, cross-platform application purposefully built for astronomical image analysis. It can help you measure the spectral lines, and can analyse the spectrum to determine the object's radial velocity.

> **Comments:**
> **username_0**: how about writing our own python code to do it?All we have to do is analyse lots of wavlength-flux data sets from lots of spectra.  
> **username_1**: Go for it. Often it's easiest to write your own code, especially if you have large data sets to crunch through.  
> **username_0**: First find a local maximum and then fit it with a Gaussian profile. This method is too easy to believe. Anything  I miss?  
> **username_1**: Yep, that's just about it. If you want to find local maxima computationally, applying some median smoothing (depending on noise levels) and then using its derivatives can work well. This piece of code does just that (I don't think it would work well for what you want as-is, though it will serve as a working example of what you might want to do). http://adsabs.harvard.edu/abs/2007A%26A...469..783S  

---

### Answer by username_2 on 2013-10-21. Score: 6

Yes, there is are two python modules called [astropy](http://www.astropy.org/), and [astropysics](http://pythonhosted.org/Astropysics/) that both claim to have spectral analysis tools. As a reference, here is a link for [resources](http://www.astropython.org/resources) for astronomers for the python programming language.


---

### Answer by username_3 on 2013-10-22. Score: 6

There are plenty of software and tools available to do what you want:

* [IRAF](http://iraf.noao.edu/), by NOAO;
* [MIDAS](http://www.eso.org/sci/software/esomidas/) which is basically very similar to IRAF but developed by ESO;
* in Python, either [astropy](http://www.astropy.org) or [pyRAF](http://www.stsci.edu/institute/software_hardware/pyraf) (to use IRAF with a Python interface).

I would go with some Python tools (Python is more versatile than IRAF or MIDAS that are much more "single-purpose" oriented), to benefit from the other features offered by Python.

But to plot and process your spectrum is just the first part of the work, what you would probably want to do in the end is to use spectral synthesis, to analyze your spectrum. Spectral synthesis will allow you:

* to identify efficiently the chemical composition of the celestrial object you study;
* to determine some properties of the celestial object you study.

Among the existing tools for spectral synthesis (for stellar spectra for example), there are:

* [Turbospectrum](http://www.pages-perso-bertrand-plez.univ-montp2.fr/) by Bertrand Plez;
* [BaSeL](http://www.astro.mat.uc.pt/BaSeL2/) by Thibault Lejeune

> **Comments:**
> **username_0**: Thanks. I just want to know the positions of line center.  

---

