The Higher We Go, the Cooler it Gets--Why??
When the atmosphere is stable, the higher we go, the cooler the air is.
Air is warmest near the ground, which absorbs receives heat from sunlight. It is coldest above the level where jetliners fly, at 10-15 kilometers, the region from where it radiates most of its heat into space. That is why mountaintops are cold and the highest mountains have snow on their tops.
(Still higher layers may get quite hot again, by absorbing UV and "extreme UV," but they have little effect on what goes on below them).
How exactly does this happen?
One could argue that it must be so, because heat enters the atmosphere at its bottom, where sunlight heats the ground, and is radiated away again at the top, at the beginning of space. And a well known principle (aka second law of thermodynamics) asserts that the energy of heat only travels by itself from hot to cold, never the other direction.
But it is still interesting to see how it happens.
Suppose some "parcel of air" (dry air, for now--humidity is an additional factor, considered later) is heated by the ground and rises. Higher up pressure is lower, so the air expands: but expansion cools it.
Similarly, if for some reason the parcel is blown down, it is compressed again and heated by the compression. Such up-and-down motions happen all the time, and the net result is that when conditions are stable, the temperature drops at a steady rate as we go higher.
The motion of the rising parcel of air depends on its surroundings. It always cools by expansion--but is it still warmer than the still air around it? If it is, it continues to rise; if not, it stops. As will be seen, this is where the humidity of air has an important effect.
[ On an ordinary day, direct heating by the ground only carries the air a few hundred meters, perhaps a kilometer, creating above the ground a "boundary layer" with many small convective flows. Large scale motions like thunderstorms usually occur higher up (see below).]
Instead of heating the Earth, sunlight can evaporate water from it--especially from the oceans, which cover most of the Earth's surface. Humid air may be viewed as containing additional energy, invested by the Sun when its heat evaporated the water. While heat drives convection, humidity may amplify it.
Hot humid air is what drives thunderstorms, and a warm ocean surface is also the traditional birthplace of violent tropical storms, known as hurricanes in America and typhoons in Asia.