Internal gravity waves in atmospheres with realistic dissipation and temperature part I. Mathematical development and propagation of waves into the thermosphere