True wind on a moving platform
Originally developed for ships, the required parameters include the vessels course over the ground, speed over the ground, heading, any anemometer offset and observed wind speed and direction relative to the vessel. Note that the vessels heading (indicated by compass) and course over the ground (as measured by GPS track) may well be different due to the effects of tide and leeway.
The technique can also be applied to moving land platforms but in this case the course over the ground and heading values will almost certainly be the same. All calculations are performed in the mathematical coordinate system which has an angle of zero degrees on the positive x-axis with angles increasing in a counterclockwise direction. Each vector direction, originally defined using the meteorological conventions is converted to mathematical coordinates prior to other calculations. Primes (') denote values in math coordinates.
The direction of the observed wind in math coordinates A is:
$$A_{\theta}^{'}=270^\circ-\left(h_{\theta}+R_{\theta}+P_{\theta}\right)$$
where h is the vessels heading, R the anemometer offset (if any) from zero and P the platform relative observed wind direction.
The course over the ground C of the vessel in math coordinates is:
$$C_{\theta}^{'}=90^\circ-C_{\theta}$$
The true wind is then calculated by summing the vector components of the observed wind and vessels motion:
$$T_{u}=T_{u}^{'}=\left|A\right|\cos\left(A_{\theta}^{'}\right)+\left|C\right|\cos\left(C_{\theta}^{'}\right)$$
$$T_{v}=T_{v}^{'}=\left|A\right|\sin\left(A_{\theta}^{'}\right)+\left|C\right|\sin\left(C_{\theta}^{'}\right)$$
where positive Tu and Tv are eastwards and northwards components of the true wind in the earth reference frame.
The true wind speed |T| and direction Tθ can then be calculated:
$$\left|T\right|=\sqrt{\left(T_{u}^{2}+T_{v}^{2}\right)}$$
$$T_{\theta}=270^\circ-\arctan\left(\frac{T_{v}}{T_{u}}\right)$$
NOTE: The 270° converts the value of the atan operation to a direction from which the wind is blowing (meteorological convention) in the Earth coordinate system. For the atan operation to return a correct angle, the atan function must have a range from -180° to 180° to determine the vector's trigonometric quadrant (e.g., Python/Excel atan2 function). Also, any program must have a check to avoid dividing by zero.