We all now that green is a mixture of blue and yellow, and that purple is a mixture of red and blue. In astronomical spectroscopy the chemical composition of a planet’s atmosphere is determined, by the planets light reflection. My question is: “In an atmosphere with two major layers, one reflecting for example blue and the other red light. How can spectroscopy know if it is looking at one single purple layer or two layers, a blue an a red, one above the other?
We all know that green is a mixture of blue and yellow, and that purple is a mixture of red and blue.
Only humans (and other animals with human-like color perception) know that.
For a spectrometer a mixture of red and blue light will look exactly like that, a mixture. It will not get confused with purple color:
However, we aren't looking at just the color - each element such as hydrogen, oxygen etc. will cause spectral lines in the result. With multiple layers, we can still identify the elements, but may not have good information on which layer they are in.
This NASA presentation has a good explanation of spectroscopy on exoplanets.
You cannot estimate the detailed composition of a planetary atmosphere just by taking a spectrum, though you can get indications of what species it contains. The detailed composition only comes from a complete modelling of the radiative processes and physical structure of the atmosphere.
Planets reflect visible light, they don't intrinsically emit (much) visible light.
In both cases, the answer is the same. What we observe, at any particular wavelength, is light travelling from the deepest layer from which it can escape without being absorbed.
The spectrum of a planet is therefore constructed of light coming from a variety of depths in the atmosphere. Wavelengths that are strongly absorbed will emerge from higher in the planetary atmosphere.
The composition of a planetary atmosphere is reconstructed via a detailed modelling of these radiative processes, combined with a physical model of the planet's atmosphere (density, temperature and composition with height, possibly including dust and clouds). The details of the composition and atmospheric structure are altered until the predicted emergent spectrum matches what is observed. This is how it is "normally done" (for planets in the Solar System).
Your hypothetical scenario requires a layer that reflects red light, but which is transparent to blue light, to overlie a layer that reflects blue light but is transparent (or absorbs) red light.
We will see it as two different peak wavelengths, since it will be split by the diffraction grating/prism. For example, a transit spectroscopy, if the planet has two distinct atmospheric layers, made of different composition and density, the red and blue light scattered by the atmosphere, will appear as purple to the human eye as it is just red light and blue light coming in the light cones/photoreceptors of the human eye, however a spectrometer and a diffraction grating will not fuse it together. It will perceive it as a blend of both the wavelengths, the peak wavelengths, blue and red will split, it will appear as a smooth wavelength, except with 2 peaks at the blue and red part of the electromagnetic spectrum rather than violet.
Thank you, Hope it helps you!