# How do we know which elements are in a galaxy spectra?

I know that each element has it's own distinct spectra (this is a good site that lists them: Periodic Table) but when looking at a spectra of a galaxy (or even a star) how do we match those elements to their distinct spectra? Looking at this image from Spectra in the Lab :

Some of the lines in the spectra overlap. The galaxies are also moving away, so it makes it more difficult to figure out the elements producing the emission/absprtion lines, right?

Also, each element usually has more than one absorption/emission line, so how can we say that just one line is the H-alpha line, or the K and H calcium lines, for example, as in this spectra:

Because the wavelength ratio of the lines remains constant despite any cosmological red shift.

For example, if the redshift is $$z$$, all the lines are shifted redward in wavelength by a factor $$(1+z)$$. This means that a pattern of lines can still be recognisable.

We also have a pretty good idea of what the spectra should look like, which chemical elements will produce visible absorption features with what relative strengths and so on (see below). This usually makes identification of line features straightforward.

Of course if there were just a single line visible in the spectrum (it does happen, usually in high redshift quasars) it can be difficult to pinpoint the redshift.

In terms of analysing what's in a Galaxy, well usually the light is dominated by the mixed spectrum of billions of stars. This spectrum is interpreted and modelled using galaxy evolution models and population synthesis models that predict a spectrum from a given ensemble.

If a Galaxy is near enough, the chemical abundances of its interstellar medium can be estimated from resolved spectra of emission nebulae.

In comparison, interpreting spectra from an individual star is trivial. Hundreds if not thousands of absorption lines can easily be identified and matched with the predictions of very detailed stellar atmosphere models to estimate chemical abundances. These models contain up to millions of possible radiative transitions as well as the various line strengths and broadening processes that affect the spectrum.

I think if you check out how to do spectrograph reduction, that will give you a better idea about how to identify line features from a real spectrograph. May be, you can start with this one, and go from there.

In summary, after you clean the spectrograph with a bunch of calibration techniques, you will end up with a data set of (flux, pixel number). The pixel number is equivalent to the continuous wavelength, that is (pixel number, wavelength), but you have to find the way to map it. So, what you do is to have another spectrograph of an object with known spectral profile (i.e., arc lamps) occupying the same (pixel number, wavelength). Therefore, you can establish the (pixel number, wavelength) map. Then, you apply the same map back to your science object.

The moving away effect is called "redshift." The redshift is easily predictable, and has been taken care of during the mapping process mentioned above.

There are blending effects as you mentioned. However, during the process since you identify the map by using an arc lamp, this is not a problem. This is how an arc lamp profile looks like (link). In your science object, you cannot separate the blending unless you perform further analysis such as simulation or fitting.