Commonly the air density can be calculated with an equation of state or with an interpolated bestfit curve. In both cases, we have to deal with an equation of the form \(\rho=f(T,p,RH, others)\). Let's make things a bit simpler and start with a simple relationship between density and temperature:
$$\rho=f(T,Constant)$$
Temperature in the SI is measured in degrees Kelvin, but many equations of state may also be given with temperature expressed in \(Celsius=Kelvin – 273.15\). Quoted from BIMP: "The kelvin, unit of thermodynamic temperature, is the fraction 1/273.16 of the thermodynamic temperature of the triple point of water.". The thermodynamic temperature is correlated to the state of a thermodynamic system and according to the third law of thermodynamics it defines an absolute temperature scale. For dry air, the ideal gas equation of state is
$$\rho=\frac{p}{R_{specific}T}$$where
\(\rho\) is the air density in \(kg/m^3\),
\(p\) is the absolute pressure in \(Pa\),
\(T\) is the absolute temperature in \(K\) and
\(R_{specific}=287.058\frac{J}{kgK}\) is the specific gas constant for air.
The main advantage of the equation of state is that it provides a closed form solution, which in turn can be incorporated in other computations. This is a very convenient property for analysis purposes. Let's proceed with a density calculation. Refer to figure 1; our idealized test setup is a room with two thermometers and a fan. The first thermometer measures the temperature of the air in the room at a point far away from the fan effects, while the second one is subject to the direct airflow from the fan.
Figure 1: Example layout
Prior to any calculation let's introduce the stagnation temperature, which indicates the temperature at a stagnation point within a flow field. At the stagnation point the local flow velocity is zero. We find a stagnation point on a Pitot tube tip or in a total air temperature probe.
In our example, the air from the fan which hits the thermometer is brought to rest on the surface of the sensing element. Consider an infinitesimal volume of the overall air stream traveling at a certain speed. This small volume has a corresponding kinetic and gravitational potential energy. If we assume that this volume does not exchange any form of energy with the surroundings then this energy must be converted when one of its forms is eliminated. In the process where the air slows down, kinetic energy is converted into heat, which causes a temperature rise. Assuming an adiabatic process we can describe the enthalpy at stagnation
$$h_s=h+\frac{V^2}{2}$$where the enthalpy term \(h\) is that of the nearest point along the streamline and
\(V\) is the speed of the air flow.
For an ideal gas it holds that
$$h=u+pv$$
where \(v\) is the specific volume and
\(u\) is the internal energy of the gas.
By manipulating the enthalpy expression and taking into account the constant pressure heat capacity definition \(Cp\) for an ideal gas \(h=C_pT\), we arrive at
$$T_s=T+\frac{V^2}{2C_p}$$
This equation defines how much the temperature rises because of the fact that is adiabatically brought to rest.
Returning to our example let's calculate the different values of stagnation temperature in correspondence of different airspeed values. You can find precalculated values in the table below.
T [K] Static  V [m/s]  V [km/h]  M  T0 [K] Stagnation  Deviation [K]  Deviation [%]  Parameters  

288.15

0

0

0

288.15

0

0

Cp

1005

J/Kg/K

288.15

2

7.2

0.01

288.15

0

0

c

340.3

m/s

288.15

3

10.8

0.01

288.15

0

0
 
288.15

4

14.4

0.01

288.16

0.01

0
 
288.15

5

18

0.01

288.16

0.01

0
 
288.15

6

21.6

0.02

288.17

0.02

0.01
 
288.15

7

25.2

0.02

288.17

0.02

0.01
 
288.15

8

28.8

0.02

288.18

0.03

0.01
 
288.15

9

32.4

0.03

288.19

0.04

0.01
 
288.15

10

36

0.03

288.2

0.05

0.02
 
288.15

11

39.6

0.03

288.21

0.06

0.02
 
288.15

12

43.2

0.04

288.22

0.07

0.02
 
288.15

13

46.8

0.04

288.23

0.08

0.03
 
288.15

14

50.4

0.04

288.25

0.1

0.03
 
288.15

15

54

0.04

288.26

0.11

0.04
 
288.15

16

57.6

0.05

288.28

0.13

0.04
 
288.15

17

61.2

0.05

288.29

0.14

0.05
 
288.15

18

64.8

0.05

288.31

0.16

0.06
 
288.15

19

68.4

0.06

288.33

0.18

0.06
 
288.15

20

72

0.06

288.35

0.2

0.07
 
288.15

21

75.6

0.06

288.37

0.22

0.08
 
288.15

22

79.2

0.06

288.39

0.24

0.08
 
288.15

23

82.8

0.07

288.41

0.26

0.09
 
288.15

24

86.4

0.07

288.44

0.29

0.1
 
288.15

25

90

0.07

288.46

0.31

0.11
 
288.15

26

93.6

0.08

288.49

0.34

0.12
 
288.15

27

97.2

0.08

288.51

0.36

0.13
 
288.15

28

100.8

0.08

288.54

0.39

0.14
 
288.15

29

104.4

0.09

288.57

0.42

0.15
 
288.15

30

108

0.09

288.6

0.45

0.16
 
288.15

31

111.6

0.09

288.63

0.48

0.17
 
288.15

32

115.2

0.09

288.66

0.51

0.18
 
288.15

33

118.8

0.1

288.69

0.54

0.19
 
288.15

34

122.4

0.1

288.73

0.58

0.2
 
288.15

35

126

0.1

288.76

0.61

0.21
 
288.15

36

129.6

0.11

288.79

0.64

0.22
 
288.15

37

133.2

0.11

288.83

0.68

0.24
 
288.15

38

136.8

0.11

288.87

0.72

0.25
 
288.15

39

140.4

0.11

288.91

0.76

0.26
 
288.15

40

144

0.12

288.95

0.8

0.28
 
288.15

41

147.6

0.12

288.99

0.84

0.29
 
288.15

42

151.2

0.12

289.03

0.88

0.3
 
288.15

43

154.8

0.13

289.07

0.92

0.32
 
288.15

44

158.4

0.13

289.11

0.96

0.33
 
288.15

45

162

0.13

289.16

1.01

0.35
 
288.15

46

165.6

0.14

289.2

1.05

0.37
 
288.15

47

169.2

0.14

289.25

1.1

0.38
 
288.15

48

172.8

0.14

289.3

1.15

0.4
 
288.15

49

176.4

0.14

289.34

1.19

0.41
 
288.15

50

180

0.15

289.39

1.24

0.43
 
288.15

51

183.6

0.15

289.44

1.29

0.45
 
288.15

52

187.2

0.15

289.5

1.35

0.47
 
288.15

53

190.8

0.16

289.55

1.4

0.48
 
288.15

54

194.4

0.16

289.6

1.45

0.5
 
288.15

55

198

0.16

289.65

1.5

0.52

Table 1. Stagnation temperature vs static temperature at different V values. Download spreadsheet.
By inspection of the table, the deviation between the two temperature measurements increases with the air speed.
The air density in the room should be calculated using the static temperature, in our case, for e.g. \(p=101325 Pa\) the corresponding density is \(\rho=1.225\ kg/m^3\). The same calculation using the total temperature with a fan pushing the air at 55 m/s gives \(\rho=1.218\ kg/m^3\), which is about a 0.5% of error on density.
Inspect the relationship between static and total temperature for a total air temperature probe; the first formula in this link.
$$T_{total}/T_s=1+\frac{\gamma1}{2}M^2$$
where the “total” subscript indicates the adiabatic temperature and “s” subscript is for the static temperature. This formula is in accordance with our example formula. To reach this formula from our derived temperature equation, substitute in this formula the definition of the specific heat ratio \(\gamma=C_p/C_v\), the Mayer's relation \(C_p – C_v = R\) and the Mach number expression \(M=V/\sqrt{\gamma R_{specific}T}\).
The total air temperature computed up to now here is somewhat ideal. All the kinetic energy is converted and contributes to a temperature rise but it should be accounted with an appropriate recovery factor (Commercial example here, equation 3). The relationship of the recovery factor with airspeed and other environmental factors is not trivial and for best accuracy it should be experimentally found. Nonetheless, the tight relationship between airspeed and temperature can be exploited to have a true air speed indication as per equation 9 in the previous link. Consequently, a total air temperature probe working together with a Pitotstatic tube offers a useful redundant airspeed indication.
Even at low airspeeds, to achieve top performance, the temperature measurement rise due to airspeed is existent. However, the impact of this effect on temperature measurements can be neglected in many applications with moderate to no loss of accuracy. Unfortunately, this is not the only source of uncertainty in a total air temperature probe. There are other aspects that hinder much more the performance of the total air temperature probes. Thermal aspects will be considered in a following article.
Further reading
General description
Full developed calculation example