hydesign.weather.weather
Classes
Atmospheric boundary layer WS interpolation and gradient |
Functions
|
Auxiliar functions for WS, shear and WS gradient interpolation. |
|
Extracting weather data using the era5 datasets, by specifying the location coordinates. |
|
Method to perform a 1D isoprobabilistic trasnformation in order to |
|
Method to select a number of weeks per season per year from a time series df |
|
Function that creates the 3D interpolation weights using finite |
|
Function that applies interpolation to a wrf simulation. |
|
Function that interpolates as dataset using inverse distance weighting (IDW). |
|
Function that uses the wrf projection properties for |
Module Contents
- class hydesign.weather.weather.ABL(weather_fn, N_time)[source]
Bases:
openmdao.api.ExplicitComponent
Atmospheric boundary layer WS interpolation and gradient
- Parameters:
hh (Turbine's hub height)
- Returns:
wst
- Return type:
wind speed time series at the hub height
- setup_partials()[source]
Declare partials.
This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.
- compute(inputs, outputs)[source]
Compute outputs given inputs. The model is assumed to be in an unscaled state.
An inherited component may choose to either override this function or to define a compute_primal function.
- Parameters:
inputs (Vector) – Unscaled, dimensional input variables read via inputs[key].
outputs (Vector) – Unscaled, dimensional output variables read via outputs[key].
discrete_inputs (dict-like or None) – If not None, dict-like object containing discrete input values.
discrete_outputs (dict-like or None) – If not None, dict-like object containing discrete output values.
- compute_partials(inputs, partials)[source]
Compute sub-jacobian parts. The model is assumed to be in an unscaled state.
- Parameters:
inputs (Vector) – Unscaled, dimensional input variables read via inputs[key].
partials (Jacobian) – Sub-jac components written to partials[output_name, input_name]..
discrete_inputs (dict or None) – If not None, dict containing discrete input values.
- hydesign.weather.weather.interpolate_WS_loglog(weather, hh)[source]
Auxiliar functions for WS, shear and WS gradient interpolation.
- Parameters:
weather (pd.DataFrame) – WS time-series table for a location at multiple heights. The columns must be named WS_hh (for example WS_1, WS_10, WS_50).
hh (float) – Elevation (of a wind turbine) to interpolate WS, shear and dWS_dz
- Returns:
ds_interpolated – Dataset that contains the interpolated time-series: WS, shear and dWS_dz
- Return type:
xr.Dataset
- hydesign.weather.weather.extract_weather_for_HPP(longitude, latitude, altitude, era5_zarr='/groups/reanalyses/era5/app/era5.zarr', ratio_gwa_era5='/groups/INP/era5/ratio_gwa2_era5.nc', era5_ghi_zarr='/groups/INP/era5/ghi.zarr', year_start='1990', year_end='1990')[source]
Extracting weather data using the era5 datasets, by specifying the location coordinates.
- Parameters:
longitude (location longitude)
latitude (location latitude)
altitude (location altitude)
year_start (first year of the lifetime)
year_end (last year of the last time)
- Returns:
weather
- Return type:
weather time series including wind speed, wind direction, temperature, ghi, dni, dhi
- hydesign.weather.weather.isoprob_transfrom(y_input, y_desired)[source]
Method to perform a 1D isoprobabilistic trasnformation in order to force the input sample to be have the desired distribution. Correlations are kept in rank-sense.
- hydesign.weather.weather.select_years(df, seed=0, weeks_per_season_per_year=1)[source]
Method to select a number of weeks per season per year from a time series df To each variable a isoprobabilistic trasnformation is applied in order to force the sample distribution to be the same as the long term distribution. Correlations are kept in rank-sense.
- hydesign.weather.weather.get_interpolation_weights(px, py, pz, all_x, all_y, all_z, n_stencil=4, locs_ID=[])[source]
Function that creates the 3D interpolation weights using finite differences for multiple interpolations points (px,py,pz), given a grid of observed points [all_x, all_y, all_z].
This function computes the weights for interpolation for different order in the horizontal dimensions (x,y), while it computes the weights for both linear interpolation and for piecewise logarithmic profile in z.
- Parameters:
px (numpy.array) – Interpolation (prediction) points in x
py (numpy.array) – Interpolation (prediction) points in y
pz (numpy.array) – Interpolation (prediction) points in z
all_x (numpy.array) – Observed points in x
all_y (numpy.array) – Observed points in y
all_z (numpy.array) – Observed points in z
n_stencil (int, optional, default=4) – Number of points used in the horizontal interpolation
locs_ID (list) – Names or ID to identify the locations
- hydesign.weather.weather.apply_interpolation_f(wrf_ds, weights_ds, vars_xy_logz=['WSPD'], vars_xyz=['WDIR', 'RHO'], vars_xy=['UST', 'RMOL', 'TAIR', 'DIF_AVG', 'DNI_AVG'], vars_nearest_xy=[], vars_nearest_xyz=[], var_x_grid='west_east', var_y_grid='south_north', var_z_grid='height', varWD='WDIR')[source]
Function that applies interpolation to a wrf simulation.
- Parameters:
wrf_ds (xarray.Dataset) – Weather timeseries
weights_ds (xarray.Dataset) –
Weights for locs interpolation for several methods:
<xarray.Dataset> Dimensions: (ix: 4, iy: 4, iz: 5, loc: 14962) Coordinates: * loc (loc) int64 Dimensions without coordinates: ix, iy, iz Data variables: weights_x (loc, ix) float64 ind_x (loc, ix) int64 weights_y (loc, iy) float64 ind_y (loc, iy) int64 weights_z (loc, iz) float64 weights_log_z (loc, iz) float64 ind_z (loc, iz) int64 ind_x_1 (loc) int64 ind_y_1 (loc) int64 ind_z_1 (loc) int64
vars_xy_logz (list) – List of variables to be interpolated in horizontal (x,y) using finite differences and power law piecewise interpolation in z.
vars_xyz (list) – List of variables to be interpolated in horizontal (x,y) using finite differences and linear piecewise interpolation in z.
vars_xy (list) – List of variables to be interpolated in horizontal (x,y) using finite differences
vars_nearest_xy (list) – List of variables to be approximated to the nearest horizontal point (x,y)
vars_nearest_xyz (list) – List of variables to be approximated to the nearest point (x,y,z)
var_x_grid (string, default:'west_east') – Name of the variable in the weather data used as x in the interpolation
var_y_grid (string, default: 'south_north') – Name of the variable in the weather data used as y in the interpolation
var_z_grid (string, default:'height') – Name of the variable in the weather data used as z in the interpolation
varWD (string, default:'wd') – Name of the wind direction variable for ensuring it is in [0,360]
- Returns:
interp – Dataset including meso-variables timeseries, interpolated at each locs. The arrays have two dimensions: (‘Time’, ‘locs’).
- Return type:
xarray.Dataset
- hydesign.weather.weather.apply_interpolation_IDW(ds_dssr, px, var='ghi', n_neighbors=4, IDW_p=2)[source]
Function that interpolates as dataset using inverse distance weighting (IDW). Usefull for unstructured datasets or with nan’s on several locations.
- Parameters:
ds_dssr (Dataset) – Dataset with latitude and longitude as coordinates
px (array) – points to interpolate in [lon,lat]
var (str) – Variable to interpolate available in ds_dssr
n_neighbors (int) – Number of neares neighbor points to use in the interpolation
IDW_p (float) – IDW exponent coefficient to compute the weitghs = 1/d**IDW_p
- hydesign.weather.weather.project_locations(locs, region_domain_fn, ds, domain, var_lon='longitude', var_lat='latitude')[source]
Function that uses the wrf projection properties for converting the locations (lat,lon) to regular grid coordinates used in wrf.
- Parameters:
locs (Dataframe) – Table with locations including Latitude and Longitude
region_domain_fn (str) – Filename of region_domain_fn excel file. To describe wich domain to use per region (or country).
ds (Dataset) – Meso-scale xarray dataset including Lat, Lon and wrf projection
domains (str) – Domain name