waves.utilities.met_data#

Provides a series of functions for processing meteorological data.

Functions

compute_shear(data, ws_heights[, ...])

Computes the shear coefficient between wind speed measurements using the power law.

extrapolate_windspeed(v1, z1, z2, shear)

Extrapolates wind speed vertically using the Power Law.

fit_weibull_distribution(wind_speed_data[, ...])

Fits a Weibull distribution to wind speed data and returns the shape parameter.

waves.utilities.met_data.fit_weibull_distribution(wind_speed_data, random_seed=1)[source]#

Fits a Weibull distribution to wind speed data and returns the shape parameter.

This function fits a Weibull distribution to the provided wind speed data, assuming that wind speeds are non-negative by fixing the location parameter of the Weibull distribution to 0. It returns the shape parameter of the fitted Weibull distribution. The function also allows for reproducibility by setting a random seed for the fitting process. If the required wind speed data is not available or the data is invalid, an error message is printed.

Parameters:
  • wind_speed_data (np.ndarray) -- The array of wind speed data to fit the Weibull distribution to.

  • random_seed (int, optional) -- A random seed for reproducibility. Defaults to 1. This seed initializes the random number generator used in the fitting procedure.

Returns:

float | str -- The shape parameter of the fitted Weibull distribution if the wind speed data is valid. If the data is missing or invalid, it returns an error message indicating the issue.

waves.utilities.met_data.compute_shear(data, ws_heights, return_reference_values=False)[source]#

Computes the shear coefficient between wind speed measurements using the power law.

The shear coefficient is calculated by evaluating the expression for an Ordinary Least Squares (OLS) regression coefficient. The power law is used to model the relationship between wind speed and sensor height. This function is based on the implementation provided by OpenOA (NREL/OpenOA)

Return type:

Series | tuple[Series, float, Series]

Parameters:
  • data (pandas.DataFrame) -- A DataFrame containing wind speed columns that correspond to the keys of ws_heights. Each column should represent wind speed measurements at a specific height.

  • ws_heights (dict[str, float]) -- A dictionary where the keys are the names of the wind speed columns in data, and the values are the respective sensor heights (in meters) for those columns.

  • return_reference_values (bool, optional) -- If True, the function will return a tuple containing the shear exponents, the reference height (m), and the reference wind speed (m/s). Defaults to False.

Returns:

pd.Series | tuple[pd.Series, float, pd.Series] -- If return_reference_values is False, the function returns the shear coefficient (unitless) as a pandas Series. If return_reference_values is True, the function returns a tuple:

  • The shear coefficient (unitless) as a pandas Series,

  • The reference height (float) in meters,

  • The reference wind speed (pandas Series) in meters per second.

waves.utilities.met_data.extrapolate_windspeed(v1, z1, z2, shear)[source]#

Extrapolates wind speed vertically using the Power Law. This function is based on the implementation provided by OpenOA (NREL/OpenOA).

Return type:

Series | ndarray | float

Parameters:
  • v1 -- A pandas Series of the wind speed measurements at the reference height, or the name of the column in data.

  • z1 (float) -- Height of reference wind speed measurements; units in meters.

  • z2 (float) -- Target extrapolation height; units in meters.

  • shear -- A pandas Series of the shear values, or a single shear value.

Returns:

obj: pandas.Series | np.ndarray | float -- Wind speed extrapolated to target height, :py:arg:`z2`.