To properly resample - or average over a longer period - wind direction and wind speed, you need to first break it down into its horizontal and vertical components. If you simply take the arithmetic mean over a longer period, you will end up with the 'scalar' average which can be meaningful for wind speed, but not for wind direction. For more on why this is, please see the "References" section below.
Below, we will document the math and provide an example of how to calculate these variables using Python. Whether you need the vector average or scalar average for wind speed depends on your use case.
How can you do it properly?
Let's assume you have just downloaded a data file from the QuantAQ Cloud that contains columns for the vector wind direction (wd
) and vector wind speed (ws
). The first step is to compute the horizontal and vertical components of the wind speed vector, u
and v
.
u = sin(wd)*ws
v = cos(wd)*ws
It is important to note that wind direction should be in units of radians. If working in Python with the pandas
library, you can compute this as follows:
Once you've computed the u
and v
components, you can resample the data by following these steps:
Decide what time interval you would like to average the values over and group by that (e.g., for hourly-averaged data separate your data by hour)
For the averaging period from Step 1, calculate the average
u
andv
componentsCalculate the vector wind direction using the following equation:
wd = arctan(u, v)
Calculate the vector wind speed using the following equation:
ws = sqrt(u^2 + v^2)
Complete Python Implementation
If you are working in Python (using pandas
), you can use the following resampling function and example to implement the above:
To use the function, you can then implement as follows:
You can edit the freq
variable to resample at different periods.
References
For more information, please visit the EPA's Meteorological Monitoring Guidance for Regulatory Modeling Applications.