plower package#
Submodules#
plower.common module#
This file contains general functions used by other functions
- plower.common.add_logpath(logger, log_file_prefix, log_dir='logs', **kwargs)[source]#
Update Logger with log file path.
Here the log file has date and time as suffix.
- plower.common.count(iterable)[source]#
Count the number of items that iterable yields. Equivalent to the expression len(iterable)
Author: Wouter Bolsterlee
- Parameters
iterable (iterable) –
- Returns
count
- Return type
- plower.common.get_heading(logger, title, level=0, total_len=79)[source]#
Converts ‘string’ to a heading (‘== string ==’)
- Parameters
- Returns
Outputs logger.info(string)
- Return type
logger.info
- plower.common.xrmax(dataset, full_dataset=None)[source]#
Return maxima of the dataset with all coordinates
- Parameters
dataset (scalar, array, Variable, DataArray or Dataset) – dataset
full_dataset (scalar, array, Variable, DataArray or Dataset, optional) – superset of the dataset, by default dataset
- Returns
dataset_maxima – maxima of the dataset
- Return type
plower.imports module#
Imports the NDBC data and converts to pandas.DataFrame and perform statistics.
- plower.imports.get_ndbc_buoy_details(station_id)[source]#
Returns buoy details from the NDBC website.
The details are taken from the https://www.ndbc.noaa.gov/metadata/stationmetadata.xml
- Parameters
station_id (str or iterable) – Buoy station ID (5 lettered ID may contains numbers or alphabet).
- Returns
station_dbs – Details of the NDBC buoy.
- Return type
List of dict
- plower.imports.get_ndbc_db_url(station_id, year)[source]#
Return URL to the NDBC database of the buoy.
- plower.imports.get_ndbc_df(path, tp_range=(0, 24), hs_range=(0, 10), additional_data_names=[])[source]#
Return the NDBC buoy data for a range of peak period (tp) and significant height (hs). The description of data is available at https://www.ndbc.noaa.gov/measdes.shtml.
- Parameters
path (str) – URL of an year NDBC buoy database
tp_range (tuple, optional) – Minimum and Maximum of peak periods, by default (0,21)
hs_range (tuple, optional) – Minimum and Maximum of significant heights, by default (0,10)
additional_data_names (iterable) – Names of the data to include in output apart from (“DPD”, “WVHT”, “MWD”). The data names details are available at https://www.ndbc.noaa.gov/measdes.shtml.
- Returns
buoy_db – Dataframe of an year NDBC buoy database. By default returns (“DPD”, “WVHT”, “MWD”).
- Return type
Notes
The default tp and hs ranges are choosen according to SAM software https://sam.nrel.gov/marine-energy.html
- plower.imports.get_probability_of_occurrence(station_id, year_range=range(2011, 2021), tp2te=0.892, hs_edges=array([0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 8.5, 9., 9.5, 10.]), dir_edges=array([- 180, - 160, - 140, - 120, - 100, - 80, - 60, - 40, - 20, 0, 20, 40, 60, 80, 100, 120, 140, 160, 180]), te_edges=array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21.]), norm_factor=1.0)[source]#
Return probability of occurrence for a ocean wave data at a buoy location.
- Parameters
station_id (str) – Buoy station ID (5 lettered ID may contains numbers or alphabet).
tp2te (float, optional) – Conversion factor from peak peroid to energy period. The default is 0.892.
year_range (iterable, optional) – Range of year for the database selection. The default is range(2011,2021).
hs_edges (np.ndarray, optional) – Array of significant heights. The default is np.arange(0,10.5,0.5).
dir_edges (np.ndarray, optional) – Array of mean directions. The default is np.arange(-180,200,20).
te_edges (np.ndarray, optional) – Array of energy periods. The default is np.arange(0.0,22.0,1.0).
sam_wave_res_path (str or pathlib.Path, optional) – Path of the SAM wave resource datafile. The default is None.
norm_factor (float, optional) – Histogram is normalized such that the sum of the histograms is norm_factor. The default is 1.0.
- Returns
te_hs_dir_hist – Histogram of energy period, significant height and mean direction. Note: te_hs_dir_hist is normalized to the
- Return type
np.ndarray
- plower.imports.get_sam_dataset()[source]#
Returns a sample significant height, energy period and mean direction ranges based on the SAM model wave resource ranges. https://sam.nrel.gov/marine-energy.html
plower.wave_spectrum module#
This file contains functions to compute wave spectrums
- plower.wave_spectrum.get_2n_cosine_spread(rel_dir, n)[source]#
Cosine 2l-power type directional spreading function.
- Parameters
rel_dir (scalar, array, Variable, DataArray or Dataset) – Relative direction with the mean direction.
n (scalar, array, Variable, DataArray or Dataset) – Cosine power.
- Returns
spread – Directional spreading.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_2n_half_cosine_spread(rel_dir, n=1)[source]#
Half cosine 2l-power type directional spreading function.
- Parameters
rel_dir (scalar, array, Variable, DataArray or Dataset) – Relative direction with the mean direction.
n (scalar, array, Variable, DataArray or Dataset) – Spreading Parameter.
- Returns
spread – Directional spreading.
- Return type
scalar, array, Variable, DataArray or Dataset
References
Yoshimi Goda (1999) A Comparative Review on the Functional Forms of Directional Wave Spectrum, Coastal Engineering Journal, 41:1, 1-20, DOI: https://doi.org/10.1142/S0578563499000024
- plower.wave_spectrum.get_avail_power_simple(hs, tp, density=1000, g=9.80665, kh=inf, tp2te=0.8)[source]#
Compute the Available Power in the ocean waves with respect to significant height and wave period
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – ignificant Height.
tp (scalar, array, Variable, DataArray or Dataset) – Peak Peroid.
density (scalar, optional) – Water Density (kg/m^3). The default is 1000.
g (scalar, optional) – Gravity. The default is 9.80665.
kh (scalar, optional) – wave number to depth ratio. The default is np.inf (deep water).
- Returns
avail_power – Available Power in the ocean wave spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
References
Pecher, A., & Kofoed, J. P. (2017). Handbook of ocean wave energy. Springer Nature. pg. 59
- plower.wave_spectrum.get_jonswap_coef(hs, tp, gamma, coef_type='abs')[source]#
Compute the Coefficient of JONSWAP Spectrum.
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – Significant Height.
tp (scalar, array, Variable, DataArray or Dataset) – Peak Period.
gamma (scalar, array, Variable, DataArray or Dataset) – Peak Enchancement Factor.
- Returns
jonswap_coef – Coefficient of JONSWAP Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_jonswap_spectrum(hs, tp, omega, gamma, coef_type='goda')[source]#
Compute the JONSWAP Spectrum.
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – Significant Height.
tp (scalar, array, Variable, DataArray or Dataset) – Peak Period.
omega (scalar, array, Variable, DataArray or Dataset) – Frequency (rad/s).
gamma (scalar, array, Variable, DataArray or Dataset) – Peak Enchancement Factor.
- Returns
jonswap_spectrum – JONSWAP Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
References
Jensen, J. J. (2001). Load and global response of ships. Elsevier.
- plower.wave_spectrum.get_jonswap_unit_spectrum(norm_omega, gamma)[source]#
Compute the proportional term of JONSWAP Spectrum.
- Parameters
norm_omega (scalar, array, Variable, DataArray or Dataset) – Frequency normalized with spectrum peak frequency.
gamma (scalar, array, Variable, DataArray or Dataset) – Peak Enchancement Factor.
- Returns
jonswap_unit_spectrum – Proportional term of JONSWAP Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_mitsuyasu_spread(rel_dir, wave_dir_name, smax=12.5, spectrum_type='PM', gamma=1.0)[source]#
Compute the Mitsuyasu directional unnormalized spreading function.
- Parameters
rel_dir (scalar, array, Variable, DataArray or Dataset) – Relative direction with the mean direction.
smax (float, optional) – Maximum spread parameter. The default is 10.
spectrum ({"PM", "JONSWAP"}, optional) – spectrum type. The default is “PM”.
- Returns
unit_spread – unnormalized spread function.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_pm_coef(hs, tp)[source]#
Compute the Coefficient of Pierson-Moskowitz Spectrum.
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – Significant Height.
tp (scalar, array, Variable, DataArray or Dataset) – Peak Period.
- Returns
pm_coef – Coefficient of Pierson-Moskowitz Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_pm_spectrum(hs, tp, omega)[source]#
Compute the Pierson-Moskowitz Spectrum.
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – Significant Height.
tp (scalar, array, Variable, DataArray or Dataset) – Peak Period.
omega (scalar, array, Variable, DataArray or Dataset) – Frequency (rad/s).
- Returns
pm_spectrum – Pierson-Moskowitz Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
References
Jensen, J. J. (2001). Load and global response of ships. Elsevier.
- plower.wave_spectrum.get_pm_spectrum_te(hs, te, omega)[source]#
Compute the Pierson-Moskowitz Spectrum.
- Parameters
hs (scalar, array, Variable, DataArray or Dataset) – Significant Height.
tpe (scalar, array, Variable, DataArray or Dataset) – Energy Period.
omega (scalar, array, Variable, DataArray or Dataset) – Frequency (rad/s).
- Returns
pm_spectrum – Pierson-Moskowitz Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
References
Jensen, J. J. (2001). Load and global response of ships. Elsevier.
- plower.wave_spectrum.get_pm_unit_spectrum(norm_omega)[source]#
Compute the proportional term of Pierson-Moskowitz Spectrum.
- Parameters
norm_omega (scalar, array, Variable, DataArray or Dataset) – Frequency normalized with spectrum peak frequency.
- Returns
pm_unit_spectrum – Proportional term of Pierson-Moskowitz Spectrum.
- Return type
scalar, array, Variable, DataArray or Dataset
- plower.wave_spectrum.get_rel_dir(mean_dir, wave_dir)[source]#
Relative direction with the mean direction.
- Parameters
mean_dir (scalar, Variable, DataArray or Dataset) – Mean wave direction.
wave_dir (scalar, Variable, DataArray or Dataset) – Wave direction.
- Returns
rel_dir_sym – Relative direction with the mean direction ranging from 0 to pi.
- Return type
scalar, array, Variable, DataArray or Dataset
Note
Input mean_dir and wave_dir as xarray variables for boardcasting mean_dir array and wave_dir array to a 2D rel_dir.
- plower.wave_spectrum.get_spread_parameter(norm_omega, smax)[source]#
Compute the spread parameter.
- Parameters
norm_omega (scalar, array, Variable, DataArray or Dataset) – Frequency normalized with spectrum peak frequency.
smax (scalar, array, Variable, DataArray or Dataset) – Maximum spread parameter.
- Returns
spread_parameter – Spread parameter.
- Return type
scalar, array, Variable, DataArray or Dataset
Note
Input norm_omega and smax as xarray variables for boardcasting.
References
Mitsuyasu, Hisashi, et al. “Observations of the directional spectrum of ocean WavesUsing a cloverleaf buoy.” Journal of Physical Oceanography 5.4 (1975): 750-760.
- plower.wave_spectrum.get_wraped_normal_spread(rel_dir, std=10)[source]#
Wrapped-normal directional spreading function.
- Parameters
rel_dir (scalar, array, Variable, DataArray or Dataset) – Relative direction with the mean direction.
std (scalar, array, Variable, DataArray or Dataset) – Cosine power.
- Returns
spread – Directional spreading.
- Return type
scalar, array, Variable, DataArray or Dataset