# How to calculate air temperature for given time, location and altitude?

I would like to calculate (estimate) air temperature at given time, location and altitude.

All I have is air pressure for 20°C. The formula based on NTP (Normal Temperature and Pressure) to calculate pressure.

=101325*(1 - 2,25577*10^-5*h)^5,25588

h is height in meters` result is in Pascals.

I expect that the formula for calculation of the temperature would depend on sun position or even solar radiation. I know that the formulas for calculation of the sun position or solar radiation are complicated but maybe there are source codes/programs which can do that? So I could use such program to calculate what I need? I have found SolTrack (C/C++) on SourceForge which calculates various data like rise time, transit time, azimuth, altitude, ecliptic longitude, latitude, right ascension, declination... However I cannot use these results to calculate temperature.

Purpose of the calculation

I would like to use the calculation for game, to generate air temperatures for map. The game is not simulator it is just game. So I need to add some values to the map so when the aircraft flies it can accept some temperature changes. The values are important in vicinity of terrain, mountains and hills. I don't need include winds into the calculation.

Calculation of Solar Radiation What I have found so far is calculation of solar radiation written in Visual Basic - it is xls table (Excel) ecy.wa.gov/programs/eap/models/solrad.zip. Where I have added the pressure for 20°C. Of sure the problem here is unsolved because I suppose the temperature and pressure changes during time. So I need to improve the formula to calculate the pressure for given location, time and altitude.

Site data and time info:
latitude in decimal degrees (positive in northern hemisphere)
longitude in decimal degrees (negative for western hemisphere)
ground surface elevation (m)
time zone in hours relative to GMT/UTC (PST= -8, MST= -7, CST= -6, EST= -5)
daylight savings time (no= 0, yes= 1)
start date to calculate solar position and radiation start time
time step (hours):
number of days to calculate solar position and radiation
Bird model parameters:
barometric pressure (mb, sea level = 1013)
ozone thickness of atmosphere (cm, typical 0.05 to 0.4 cm)
water vapor thickness of atmosphere (cm, typical 0.01 to 6.5 cm)
aerosol optical depth at 500 nm (typical 0.02 to 0.5)
aerosol optical depth at 380 nm (typical 0.1 to 0.5)
forward scattering of incoming radiation (typical 0.85)
surface albedo (typical 0.2 for land, 0.25 for vegetation, 0.9 for snow)
Bras model parameter:
Bras atmospheric turbidity factor (2=clear, 5=smoggy, default = 2)
Ryan-Stolzenbach model parameter
Ryan-Stolzenbach atmospheric transmission factor (0.70-0.91, default 0.8)
Cloud attenuation parameters:
Coefficient for cloud correction (default 0.65)
Exponent for cloud adjustment (default 2)
Cloud cover fraction (0-1)

• You need to include "day of year" with time.
– f.thorpe
Jul 22 '17 at 0:31
• With time I mean general definition of time including day/month/year hour:minutes; In the xls there is function to convert day/month/year hour:minutes to julian day. Jul 22 '17 at 1:19
• You could attempt to do some curve-fitting with historical data for Earth, but I don't think you'll find anything super-useful-- in addition to winds (which you want to ignore), there's cloud cover and precipitation that affect temperature.
– user967
Jul 22 '17 at 4:21
• Barry Carter: that's great idea. I wanted to calculate with clear sky for the begin. But where could I get the historical data for Earth and temperature? Such database would be very big. I am not game creator, but I am suggesting a change for game creator. Hence my resources which I can invest are limited. Jul 22 '17 at 9:46
• opendata.stackexchange.com/questions/10154/… has many free sources of weather data, but it would take some time and effort to run curve-fitting software on it. And, even though the data is free, it is fairly large and takes some storage space. Someone else may've already run curve-fitting software on it, so googling around may help (though I'm also interested in this and haven't found anything, so maybe not).
– user967
Jul 22 '17 at 13:26

The answer that you seek does not exist. There is no easy formula that might be useful. Deriving a temperature based on solar radiation is also unrealistic since the system has very large latencies and complex interactions so that you'd end up writing a full-blown weather model. This appears to be beyond the scope of your intentions.

The question you need to ask is which effects are relevant to you and how accurate you want your model to be. Also, which quantities do you require? The answers affect your course of action. Since you mention flying aircraft, you may likely want vertical profiles of atmospheric temperature above a given location. Also, which of the following effects do you need to include:

• Day/Night variation
• Clouds, rain
• Temperature inversions
• Effect of different terrains (ocean vs land for example)
• Large variations in geographical location
• possibly other things

A good starting point are standard atmospheres (c.f. https://en.wikipedia.org/wiki/International_Standard_Atmosphere). Another approach would be to find real-world locations that are sufficiently similar to the locations you are interested in and provide measurements. These might be adapted to your situation.

A simple approach might be to tabulate a base temperature and height for different climatic zones and seasons and then apply the atmospheric lapse rate (-6.5K per km height) to these values.

On a final note, I don't know what you need this information for. But be aware that for many thermodynamic purposes, the errors that you make are not going to be that large anyway since even an error of 20-30K is only an error of around 10% in absolute temperature. So be sure to evaluate your precision requirements.

• I used NTP - Normal Temperature and Pressure to calculate pressure for 20°C But I don't know how to correct it when the temperature changes. Jul 22 '17 at 10:44
• Don't bother too much. The change of pressure with altitude is not that heavily influenced by temperature. You may wish to check out the Barometric formula. Jul 22 '17 at 10:50
• Thank you. This is a good key. Term standard "temperature lapse rate" is new for me and it seems as a clue. Wikipedia states: "When the air contains little water, this lapse rate is known as the dry adiabatic lapse rate: the rate of temperature decrease is 9.8 °C/km (5.38 °F per 1,000 ft) (3.0 °C/1,000 ft). The reverse occurs for a sinking parcel of air." source: Danielson, Levin, and Abrams, Meteorology, McGraw Hill, 2003 Jul 22 '17 at 12:15
• The lapse rate is the rate at which temperature decreases with height. In average conditions it will be less extreme than the 9.8K/km. Standard atmospheres should provide you with decent values (although the barometric formula works well enough if you assume a lapse rate of 0). Jul 22 '17 at 12:47

Agreeing with Christoph that the model you seek does not exist. When I was in grad school I programmed a model that could calculate the surface temperature based on solar radiation plus a large number of factors including the current air temperature, slope and direction of the surface, amount of shading by vegetation, previous nightly low temperature plus some essentially unknowable quantities such as the thermal conductivity of the soil. About a dozen inputs if I remember correctly. The model showed a good match to observations but was not a climate or weather model which is what you are asking for in your game.