<p>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.</p>

<p>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:</p>

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

<p>A good starting point are standard atmospheres (c.f. <a href="https://en.wikipedia.org/wiki/International_Standard_Atmosphere" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/International_Standard_Atmosphere</a>). 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. </p>

<p>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. </p>

<p>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.</p>

CC BY-SA 3.0
2017-07-22T10:44:04.870Z
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.
user1141649
CC BY-SA 3.0
2017-07-22T10:50:34.430Z
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](https://en.wikipedia.org/wiki/Barometric_formula).
Christoph
CC BY-SA 3.0
2017-07-22T12:15:23.107Z
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
user1141649
CC BY-SA 3.0
2017-07-22T12:47:30.933Z
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).
Christoph
CC BY-SA 3.0
2017-07-22T08:22:01.093Z
2017-07-22T10:44:07.247Z
2017-07-22T10:44:07.247Z
Christoph
<p>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.</p>

CC BY-SA 3.0
2017-07-23T10:54:55.347Z
I am not creator of the game. I have found great thread where the problem of thermal energy loss and heat transfer is discussed too. http://www.eng-tips.com/viewthread.cfm?qid=264134 Many formulas. To calculate solar radiation I am gonna use Bird and Hulstrom's Solar Irradiance Model: http://www.instesre.org/Solar/BirdModelNew.htm
user1141649
CC BY-SA 3.0
2017-07-23T05:50:44.003Z
2017-07-23T05:50:44.003Z
verisimilidude
<p>I would like to calculate (estimate) air temperature at given time, location and altitude.</p>

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

<p>=101325*(1 - 2,25577*10^-5*h)^5,25588</p>

<p>h is height in meters` result is in Pascals.</p>

<p>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.</p>

<p><strong>Purpose of the calculation</strong></p>

<p>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.</p>

<p><strong>Calculation of Solar Radiation</strong>
What I have found so far is calculation of solar radiation written in Visual Basic - it is xls table (Excel) <a href="http://ecy.wa.gov/programs/eap/models/solrad.zip" rel="nofollow noreferrer">ecy.wa.gov/programs/eap/models/solrad.zip</a>. 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.</p>

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

CC BY-SA 3.0
2017-07-22T00:31:20.560Z
You need to include "day of year" with time.
f.thorpe
CC BY-SA 3.0
2017-07-22T01:19:37.370Z
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.
user1141649
CC BY-SA 3.0
2017-07-22T09:46:00.747Z
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.
user1141649
<weather-forecasting>
How to calculate air temperature for given time, location and altitude?
user1141649
# How to calculate air temperature for given time, location and altitude?

(Asked by: username_0 on 2017-07-22)

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](http://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.

**Additional information:**
  
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)

**Tags:** weather-forecasting

> **Comments:**
> **username_1**: You need to include "day of year" with time.  
> **username_0**: 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.  
> **username_0**: 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.  

---

## 2 answers

### Answer by username_2 on 2017-07-22. Score: 1

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.

> **Comments:**
> **username_0**: 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.  
> **username_2**: 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](https://en.wikipedia.org/wiki/Barometric_formula).  
> **username_0**: 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  
> **username_2**: 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).  

---

### Answer by username_3 on 2017-07-23. Score: 0

Agreeing with username_2 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.

> **Comments:**
> **username_0**: I am not creator of the game. I have found great thread where the problem of thermal energy loss and heat transfer is discussed too. http://www.eng-tips.com/viewthread.cfm?qid=264134 Many formulas. To calculate solar radiation I am gonna use Bird and Hulstrom's Solar Irradiance Model: http://www.instesre.org/Solar/BirdModelNew.htm  

---

