lidarwind package
Submodules
lidarwind.data_attributes module
Module for wrinting the data attributes
- class lidarwind.data_attributes.LoadAttributes(data)[source]
Bases:
objectLevel 1 Attribute generator
It defines and writes the attributes from the Level 1
- Parameters:
data (
xarray.Dataset) – A xarray dataset containing the Level 1 data generated by the lidarwind- Returns:
data – A dataset with corrected attributes
- Return type:
xarray.Dataset
- variables_attrs()[source]
Variable attributes definitions
All variables and coordinates attributes are defined here.
- write_coords_attrs()[source]
Coordinate attribute writer
It loops over the dataset coordinate and writes their attributes
lidarwind.data_operator module
Module to manage and prepare the data for other modules
- class lidarwind.data_operator.DataOperations(data_paths, verbose=False)[source]
Bases:
objectBasic data manager
It performs some basic operations. For example: rounds the values from the azimuth coordinate and separates the vertical observations from the slanted observations.
It is helpful first use this class to process all data and then save the data as NetCDF files to speed up the derivation of wind properties later.
Examples
>>> merged_ds = lidarwind.DataOperations(file_list).merged_data >>> merged_ds.to_netcdf(output_file_path)
- Parameters:
data_paths (
list) – List of paths of the original WindCube’s output.- Returns:
object – it returns an object containing an instance of the original files merged (.merged_data)
- Return type:
object
- class lidarwind.data_operator.DbsOperations(file_list, var_list)[source]
Bases:
objectDBS file manager
This class extracts the variables required to retrieve the wind information from the DBS files.
- Parameters:
file_list (
list) – list of DBS filesvar_list (
list) – list of variables to be extracted from the DBS files
- Returns:
object – it returns an object containing an instance of the merged files (.merged_ds)
- Return type:
object
- add_mean_time(lidar_ds)[source]
This method adds the mean time to each file from the DBS scan strategy.
- Parameters:
lidar_ds (
xarray.DataSet) – a dataset from a sequence of scans
- class lidarwind.data_operator.GetResampledData(xr_data_array, vert_coord='range', time_freq='15s', tolerance=10, time_coord='time')[source]
Bases:
objectAlternative basic data resample
This class is used to resample the data into a given temporal grid.
It mainly used internal processings of the package.
- Parameters:
xr_data_array (
xr.DataArray) – varaiable that will be resampledvert_coord (
str) – name of the vertical coordinatetime_freq (
str) – size of the window e.g.: ’15s’tolerance (
int) – maximum separation from the referencetime_coord (
str) – name of the time coordinate
- Returns:
data – time resampled variable
- Return type:
xr.DataArray
- calc_delt_grid(ref_grid, orig_grid)[source]
Calculates the distance between the reference grid and the radar grid (time or range)
- Parameters:
ref_grid (
numpy.array) – reference grid (array[n])radarGrid (
numpy.array) – radar grid (array[m])
- Returns:
delta_grid – distance between each element from the reference grid to each element from the radar grid
- Return type:
numpy.array
- get_nearest_index_method_2(delta_grid, tolerance)[source]
Identify the index of the delta_grid that fulfil the resampling tolerance
- Parameters:
delta_grid (
numpy.array) – output from calcRadarDeltaGridtolerance (
int) – tolerance distance for detecting the closest neighbour (time or range)
- Returns:
grid_index – array of indexes that fulfil the resampling tolerance
- Return type:
np.array
- get_time_ref(date, time_freq='1s')[source]
Genetates the time reference grid used for resampling the data
- Parameters:
date (
Timestamp) – date for resampling (pandas Timestamp)dateFreq (
str) – resolution of the reference grid (str, default=1s)
- Returns:
time_ref – time reference grid (DatetimeIndex)
- Return type:
DatetimeIndex
- time_resample(data, time_index_array, vert_coord)[source]
It resamples a given radar variable using the time and range index calculated by get_nearest_index_method_2
- Parameters:
var (
str) – radar variable name to be resampledxrDataset (
xarray.dataset) – xarray dataset containing the variables to be resampledtimeIdexArray (
np.array) – time resampling index (output from get_nearest_index_method_2)rangeIndexArray (
np.array) – range resampling index (output from get_nearest_index_method_2)
- Returns:
resampledArr – time/range resampled numpy array
- Return type:
xarray.dataArray
- class lidarwind.data_operator.GetRestructuredData(data, snr=False, status=True, n_prof=500, center=True, min_periods=30, n_std=2, check90=True)[source]
Bases:
objectData re-structurer
It prepares the data structure for using the wind retrieval modules.
Examples
>>> wind_prop = lidarwind.GetRestructuredData(merged_data)
- Parameters:
data (
xr.Dataset) – a xr.Dataset of pre-processed datasnr (
bool,int, optional) – if an interger is given it is used to as threshold to filter the data based on the signal to noise ratiostatus (
bool, optional) – if true it filters the data using the status variable generated by the WindCube’s softwaresProf (
int, optional) – number of profiles used to calculate the anomaly for partially filter the second trip echoes (IT GOES TO FILTER MODULE)center (
bool, optional) – (IT GOES TO FILTER MODULE)min_periods (
int, optional) – (IT GOES TO FILTER MODULE)n_std (
int, optional) – size of the standard deviation window used to partially remove the second trip echoes (IT GOES TO FILTER MODULE)check90 (
bool, optional) – If True, it checks if the vertical observations are available. If False, the verification is ignored.
- Returns:
object – an instance of the prepared for the retrieval
- Return type:
object
- class lidarwind.data_operator.ReadProcessedData(file_list)[source]
Bases:
objectPre-processed data reader
It reads all data pre-processed by data_operator.DbsOperations and merges them.
Examples
>>> merged_data = lidarwind.ReadProcessedData(file_list).merge_data()
- Parameters:
file_list (
list) – list of pre-processed NetCDF files- Returns:
object – an instance of all pre-processed data
- Return type:
object
lidarwind.filters module
Module for keep all filtering functionalities
- class lidarwind.filters.Filtering(data)[source]
Bases:
objectSNR and Status filter
It uses the carrier to noise ratio (SNR) and status variables available in the WindCube’s data. It is similar to the filter described in the manual
- Parameters:
data (
xrarray.Dataset) – Dataset containing the original WindCube’s data
- get_radial_obs_comp(variable, azm, snr=False, status=True)[source]
Slanted data filter
It uses the SNR and status variables to filter out the data from slanted observations
- Parameters:
variable (
str) – name of the variable that will be filteredsnr (
bool,int, optional) – if an interger is given it is used to as threshold to filter the data based on the signal to noise ratiostatus (
bool, optional) – if true it filters the data using the status variable generated by the WindCube’s software
- Returns:
tmpaData – an instance of the variable filtered using SNR or status variable
- Return type:
xarray.DataSet
- get_vertical_obs_comp(variable, snr=False, status=True)[source]
Vertical data filter
It uses the SNR and status variables to filter out the data from vertical observations
- Parameters:
variable (
str) – name of the variable that will be filteredsnr (
bool,int, optional) – if an interger is given it is used to as threshold to filter the data based on the signal to noise ratiostatus (
bool, optional) – if true it filters the data using the status variable generated by the WindCube’s software
- Returns:
tmp_data – an instance of the variable filtered using SNR or status variable
- Return type:
xarray.DataSet
- class lidarwind.filters.SecondTripEchoFilter(data, n_prof=500, center=True, min_periods=30, n_std=2, str_h='09', end_h='16')[source]
Bases:
objectBoundary layer second trip echoes filter
This filter minimises the presence of second trip echoes (STE). This filter is based on the standard deviation of the anomaly of the observaions. It is applicable in regions where there is a contrast between the real data and the STE.
- Parameters:
data (
object) – the object returned from the GetRestructuredDatatimeCloudMaks (
xarray.DataArray) – it is a time series for indicating the presence of clouds above the maximum WinCube range. 1 indicates cloud and 0 indicates no cloud. (THIS MAKS IS NOT NEEDED NOW)n_prof (
int) – number of profiles used to calculating the anomalycenter (
bool, optional) – it defines how the mean value for the anomaly will be calculatedmin_periods (
int) – minimum number of profiles used for calculating the mean valuen_std (
int) – Multiplication factor for defining the size of the window to keep the data. The filter removes any anomaly larger than n_std * stdstr_h (
str) – starting hour for calculating the anomalyend_h (
str) – end hour for calculating the anomaly
- Returns:
object – an object containing data filtered for STE
- Return type:
object
- cleaning()[source]
It removes the data that is larger than the n_std * anomaly from the slanted observations
- class lidarwind.filters.WindCubeCloudRemoval(ceilo, lidar=None)[source]
Bases:
objectAbove boundary layer second trip echoes filter
This filter reduces the second trip echoes contamination and clouds from regions above the boundary layer. It requires information from the ceilometer. IT IS STILL EXPERIMENTAL
- Parameters:
ceilo (
xarray.Dataset) – A dataset of the CHM15k Nimbus ceilometer observations.lidar (
xarray.Dataset) – An instance of the re-structured WindCube dataset
- Returns:
object – an object containing an instance of the noise height interface and the re-structured dataset filtered for STE and clouds.
- Return type:
object
- get_height_interface()[source]
It identifies the height of the separation between the noise and the non-noise data from the ceilometer backscattered signal
lidarwind.io module
lidarwind.lidar_code module
Module to open the lidar original output
- class lidarwind.lidar_code.GetLidarData(file_name)[source]
Bases:
objectWindcube’s data reader
ATENTION, please move to io.open_sweep(). This GetLidarData will be eventually removed.
It opens and reads the original NetCDF output from the Windcube lidar
- Parameters:
file_name (
str) – name of the file that will be open
lidarwind.lidarwind_config module
Module for configuring the data global attribute
- class lidarwind.lidarwind_config.Configurations(lidarwind=None)[source]
Bases:
objectGlobal attributes definition
This class defines all global attributes that will be writen on the dataset
- Parameters:
lidarwind (
object) – an instance of the lidarwind package
- load_comments(comments='General comments')[source]
It defines additional comments
- Parameters:
comments (
str) – additional comments
- load_conf_file(file_path='config.json')[source]
It loads the pre-defined global attributes from the config.json, if it exists.
- Parameters:
file_path (
str) – the path to the configuration file (config.json)
- load_contact(contact='contact person')[source]
It defines the author’s name
- Parameters:
contact (
str) – name of the contact person
- load_email(email='contact email')[source]
It defines the contacting email
- Parameters:
email (
str) – contact email
- load_institution(institution='institution name')[source]
It defines the institution affiliation name
- Parameters:
institution (
str) – institution name
- load_instrument(instrument='instrument name')[source]
It defines the instrument name
- Parameters:
instrument (
str) – name of the instrument used during the experiment
- load_reference(reference='Generated by lidarwind version: {0}')[source]
It loads the lidarwind’s version used for processing the data
- Parameters:
reference (
str) – lidarwind version used to process the data
lidarwind.utilities module
Utilities module
- class lidarwind.utilities.CloudMask(wc_data=None, ceilo_data=None, radar_data=None)[source]
Bases:
objectThis class generates the time-height cloud mask and the temporal cloud mask using observations from lidar and ceilometer.
- class lidarwind.utilities.Util[source]
Bases:
objectThis class contains useful tools
- data_filenames()[source]
Sample file list
It searches for the sample files. If the files do not exist, it downloads them.
lidarwind.version module
lidarwind.visualization module
- class lidarwind.visualization.Visualizer(data)[source]
Bases:
object- plot_data(tmp_data, cmap='Spectral', vmin=-1, vmax=1, elv='90', azm='-', save=False, plot_id=None, fig_path=None, string_name=None, show=False, min_time=None, max_time=None)[source]
- plot_data_azm(data_non_90, cmap='Spectral', vmin=-1, vmax=1, fig_path=None, save=False, plot_id=None, show=False, min_time=None, max_time=None)[source]
lidarwind.wind_prop_retrieval module
- class lidarwind.wind_prop_retrieval.FourierTransfWindMethod(doppler_obs)[source]
Bases:
objectFFT wind retrieval method
It is a fft wind retrieval method. It was proposed by Ishwardat (2017). For more details see http://resolver.tudelft.nl/uuid:a659654b-e76a-4513-a656-ecad761bdbc8
- Parameters:
doppler_obs (
xarray.DataArray) – It should be a DataArray of slanted Doppler velocity observations as function of the azimuthal angle. It must have a coordinate called azm.- Returns:
wind_prop – A Dataset containing the horizontal wind speed and direction. It also includes the zonal and meridional wind components
- Return type:
xarray.Dataset
- get_azm_wind(azm)[source]
Wind speed for a given azimuth
It retrieves the wind speed for a given azimuthal angle. It cam be used to calculate the meridional and zonal wind components
- Parameters:
azm (
float) – an azimuth for retrieving the wind
- get_comp_amp()[source]
First harmonic amplitude
It calculates the complex amplitudes from the first harmonic from the observations along the azm coordinate
- get_hor_wind_speed()[source]
Wind speed elevation correction
It corrects the magnitude of the wind speed using the elevation angle
- get_phase()[source]
First harmonic phase
It calculates the phase of the first harmonic from the complex amplitude used for retrieving wind direction, i.e. comp_amp.
- get_rad_wind_speed()[source]
Wind speed calculation
It calculates the wind speed using the first harmonic
- get_wind_comp_u()[source]
Zonal wind calculation
It retrives the zonal wind component the -1 multiplication is for comply with the conventions used in meteorology
- get_wind_comp_v()[source]
Meridional wind calculation
It retrieves the meridional wind component the -1 multiplication is for comply with the conventions used in meteorology
- class lidarwind.wind_prop_retrieval.GetWindProperties5Beam(data, status_filter=True, cnr=None, method='single_dbs', tolerance='8s')[source]
Bases:
objectDBS wind retrieval
This class caculates the wind speeed and direction using the 5bean dataset (DBS files) as input.
- Parameters:
data (
xarray.Dataset) – merged xarray dataset (merged_ds) output from lidarwind.DbsOperations()status_filter (
bolean) – Data filtering based on the wind lidar wind status variable. If True, all data with status not equal to 1 are removed. If False, no filtering is applied.cnr (
int, optional) – Filter based on the carrier to noise ratio. If None, no filtering is applied. If a cnr value is given, all data smaller than the cnr is removed.method (
str) – It can be ‘single_dbs’ (default) or ‘continuous’. If single_dbs: the wind information is retrieved from comple sets of DBS profiles. If continuos: it uses the nearest 4 observations to retrieve the wind information, a tolerance wind has to be specified.tolerance (
str) – It defines the tolerance window that the method will use for identify the nearest profile. Example: ‘8s’ for 8 seconds.
- Returns:
object – This class returns an object containing the derived wind speed (.hor_wind_speed) and direction (.hor_wind_dir).
- Return type:
object
- calc_hor_wind_comp_continuous()[source]
Function to derive wind v and u components. It folows the same approach used by the lidar software.
- calc_hor_wind_comp_single_dbs()[source]
This method derives v and u components from the WindCube DBS files. The components are caculated from each individual DBS file. The mean time from each scan complete scan is used as identification tag.
- calc_hor_wind_dir()[source]
Function to derive wind direction. If folows the same approach used by the lidar sftware.
- class lidarwind.wind_prop_retrieval.RetriveWindFFT(transfd_data)[source]
Bases:
object6 beam wind retrieval
Wind retrieval based on the FFT method for the 6 beam observations.
- Parameters:
transfd_data (
object) – An instance of the re-structured data, it should be preferentially filtered for artefacts.- Returns:
object – An object containing an dataset of the retrieved wind speed, direction, wind components (meridional, zonal and vertical) and the relative beta
- Return type:
object
lidarwind.wind_prop_retrieval_6_beam module
Module for estimating turbulence
- class lidarwind.wind_prop_retrieval_6_beam.SixBeamMethod(data, freq=10, freq90=10)[source]
Bases:
object6 beam method
Implementation of the 6 beam method to retrieve the Reynolds stress tensor components based on the 6 Beam method developed by Sathe at all 2015. See: https://doi.org/10.5194/amt-8-729-2015
- Parameters:
data (
object) – an instance of the object generated by the lidarwind.GetRestructuredData()freq (
int) – number of profiles used to calculate the variancefreq90 (
int) – number of profiles used to calculate the variance
- Returns:
var_comp_ds – a dataset of the eynolds stress tensor matrix elementes
- Return type:
xarray.DataSet
- get_m_matrix()[source]
This method populates the coefficient matrix (M). Each element of M is one of the coefficients from equation 3 from Newman et. all 2016. The lines 0 to 4 in M are the radial velocities coefficients from the non 90 deg elevation and different azimuths. Line 6 in M has the coefficients from the radial velocity at 90 deg elevation. See: https://doi.org/10.5194/amt-9-1993-2016
M x SIGMA = S
- get_sigma()[source]
This method calculates the components of the Reynolds stress tensor (SIGMA).
SIGMA = M^-1 x S
- get_variance(data, freq=10, name='rVariance')[source]
This method calculates the variance from the observed radial velocities within a time window. The default size of this window is 10 minutes.
- Parameters:
data (
xarray.DataArray) – a dataarray of the slanted azimuthal observationsfreq (
int) – number of profiles used to calculate the variance
Module contents
Top-level package for lidarwind package