One possible way to retrieve winds using wind lidar is using the Doppler beam swing (DBS) scanning strategy. The DBS consists of four slanted observations of the wind. Each one of the observations is from a different azimuth, equally separated by 90 degrees (0, 90, 180, 270). While executing the DBS, the lidar first observes the wind at azimuths of 0 and 180 degrees and then at 90 and 270 degrees. From those observations, the north-south and east-west wind components can be calculated directly.
This example focuses on using lidarwind to retrieve wind speed and direction profiles from the observations collected by the WindCube using the DBS scan strategy.
import matplotlib.pyplot as plt
import lidarwind
from lidarwind.utilities import sample_data
Caching the short DBS sample data
# 6-beam sample data
file_list = sample_data("wc_short_dbs")
Here we are going to read all the DBS files. Be careful to provide a list of files that are compatible with each other. Here we also indicate the variables required for processing the DBS files. Finally, the merged dataset is created.
var_list = ['azimuth', 'elevation', 'radial_wind_speed',
'radial_wind_speed_status', 'measurement_height', 'cnr']
merged_ds = lidarwind.DbsOperations(file_list, var_list).merged_ds
Below, you can see the merged dataset and the variables used during the wind retrieval. You can also see one additional variable, the scan_mean_time. This variable is used to identify observations belonging to the same DBS sequence and is used if the parameter method from GetWindProperties5Beam is set to single_dbs.
merged_ds
<xarray.Dataset> Dimensions: (time: 349, gate_index: 159) Coordinates: * time (time) datetime64[ns] 2021-07-01T13:03:28.08800... * gate_index (gate_index) int32 0 1 2 3 4 ... 155 156 157 158 Data variables: azimuth (time) float64 0.0 0.0 180.0 ... 180.0 180.0 270.0 elevation (time) float64 75.0 90.0 75.0 ... 90.0 75.0 75.0 radial_wind_speed (time, gate_index) float64 0.2 -0.07 ... -19.05 radial_wind_speed_status (time, gate_index) float32 1.0 1.0 1.0 ... 0.0 0.0 measurement_height (time, gate_index) float64 200.0 250.0 ... 8.1e+03 cnr (time, gate_index) float64 -10.05 -9.8 ... -34.31 scan_mean_time (time) datetime64[ns] 2021-07-01T13:03:35.09280...
Once the merged dataset is created, you can use the dedicated class to retrieve the wind profiles.
wind_obj = lidarwind.GetWindProperties5Beam(merged_ds)
As indicated below, you can read the wind profiles directly from the wind_obj (wind object). Since they have different timestamps, it is helpful to resample the data into a regular time grid.
hor_wind_speed = lidarwind.GetResampledData(wind_obj.hor_wind_speed, time_freq='20s', tolerance=10)
ver_wind_speed = lidarwind.GetResampledData(wind_obj.ver_wind_speed, time_freq='20s', tolerance=10)
hor_wind_dir = lidarwind.GetResampledData(wind_obj.hor_wind_dir, time_freq='20s', tolerance=10)
After resampling, you can use the xarray methods to plot the data.
t1 = merged_ds.time.values[0]
t2 = merged_ds.time.values[-1]
hor_wind_speed.resampled.sortby('time_ref').sel(time_ref=slice(t1,t2)).plot(y='range', cmap='turbo')
plt.show()
ver_wind_speed.resampled.sortby('time_ref').sel(time_ref=slice(t1,t2)).plot(y='range', cmap='turbo')
plt.show()
hor_wind_dir.resampled.sortby('time_ref').sel(time_ref=slice(t1,t2)).plot(y='range', cmap='hsv')
plt.show()