A theory of ionospheric thermal radiation