THE HUMAN EYE AND THE COLOURFUL WORLD
If an object is observed through hot air above a fire or radiator, it shows random wavering or flickering.
The hotter air just above the fire is lighter (less dense) than the cooler air above it. So its refractive index is slightly less than that of the cooler air.
Here, the physical conditions of the refracting medium (air) are not stationary. So, the apparent position of the object fluctuates (wavering). It is an effect of atmospheric refraction of light.
It is due to atmospheric refraction of starlight.
When starlight enters the atmosphere, it undergoes continuous refraction. It occurs in a medium of gradually changing refractive index.
The atmosphere bends starlight towards the normal. So, the apparent position of star is slightly different from its actual position. The star appears slightly higher (above) than its actual position when viewed near the horizon.
Apparent position of the star is not stationary. It keeps on changing slightly due to varying physical conditions of the atmosphere.
The stars are very distant. So, they approximate point-sized sources of light. As the ray path of light coming from the star goes on varying slightly, the apparent position of the star fluctuates and the amount of starlight entering the eye flickers (sometimes appears brighter, some other time, fainter). It is the twinkling effect.
The planets do not twinkle because they are very close to the earth, and thus seen as extended sources. If a planet is considered as a collection of many point-sized sources of light, the net variation of light entering the eye will be zero. So it nullifies twinkling effect.
The Sun is visible to us about 2 minutes before the actual sunrise, and about 2 minutes after the actual sunset because of atmospheric refraction. Actual sunrise means the actual crossing of the horizon by the Sun.
The time difference between actual sunset and the apparent sunset is about 2 minutes. The apparent flattening of the Sun’s disc at sunrise and sunset is also due to the same phenomenon.