reVX.wind_dirs.mean_wind_dirs_point.MeanWindDirectionsPoint
- class MeanWindDirectionsPoint(gid, excl, agg_h5, tm_dset, excl_dict=None, inclusion_mask=None, resolution=64, excl_area=None, exclusion_shape=None, close=True, gen_index=None, apply_exclusions=True)[source]
Bases:
AggregationSupplyCurvePoint
SC point class to compute mean wind directions
- Parameters:
gid (int) – gid for supply curve point to analyze.
excl (str | ExclusionMask) – Filepath to exclusions h5 or ExclusionMask file handler.
agg_h5 (str | Resource) – Filepath to .h5 file to aggregate or Resource handler
tm_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
excl_dict (dict | None) – Dictionary of exclusion keyword arugments of the format {layer_dset_name: {kwarg: value}} where layer_dset_name is a dataset in the exclusion h5 file and kwarg is a keyword argument to the reV.supply_curve.exclusions.LayerMask class. None if excl input is pre-initialized.
inclusion_mask (np.ndarray) – 2D array pre-extracted inclusion mask where 1 is included and 0 is excluded. The shape of this will be checked against the input resolution.
resolution (int) – Number of exclusion points per SC point along an axis. This number**2 is the total number of exclusion points per SC point.
excl_area (float | None, optional) – Area of an exclusion pixel in km2. None will try to infer the area from the profile transform attribute in excl_fpath, by default None
exclusion_shape (tuple) – Shape of the full exclusions extent (rows, cols). Inputing this will speed things up considerably.
close (bool) – Flag to close object file handlers on exit.
gen_index (np.ndarray) – Array of generation gids with array index equal to resource gid. Array value is -1 if the resource index was not used in the generation run.
apply_exclusions (bool) – Flag to apply exclusions to the resource / generation gid’s on initialization.
Methods
agg_data_layers
(summary, data_layers)Perform additional data layer aggregation.
aggregate
(arr)Calc sum (aggregation) of the resource data.
close
()Close all file handlers.
exclusion_weighted_mean
(arr[, drop_nan])Calc the exclusions-weighted mean value of an array of resource data.
get_agg_slices
(gid, shape, resolution)Get the row, col slices of an aggregation gid.
mean_wind_dirs
(dset)Calc the mean wind directions at every time-step
run
(gid, excl, agg_h5, tm_dset, *wind_dir_dsets)Compute exclusions weight mean for the sc point from data
sc_mean
(gid, excl, tm_dset, data[, ...])Compute exclusions weight mean for the sc point from data
sc_sum
(gid, excl, tm_dset, data[, ...])Compute the aggregate (sum) of data for the sc point
Attributes
Get the non-excluded resource area of the supply curve point in the current resource class.
Get a boolean inclusion mask (True if excl point is not excluded).
Get the supply curve point centroid coordinate.
Get the cols of the exclusions layer associated with this SC point.
Get the SC point country based on the resource meta data.
Get the SC point county based on the resource meta data.
Get the SC point elevation based on the resource meta data.
Get the exclusions object.
Supply curve point gid
Get the sum of the inclusion values in each resource/generation gid corresponding to this sc point.
h5 Resource handler object
Get list of unique h5 gids corresponding to this sc point.
[0, 1] where 1 is included and 0 is excluded).
Get the flattened inclusion mask (normalized with expected range: [0, 1] where 1 is included and 0 is excluded).
Get the SC point latitude
Get the SC point longitude
Get the total number of not fully excluded pixels associated with the available resource/generation gids at the given sc gid.
Get the SC point offshore flag based on the resource meta data (if offshore column is present).
The area in km2 of a single exclusion pixel.
Get the supply curve grid aggregation resolution
Get the rows of the exclusions layer associated with this SC point.
Supply curve column index
Supply curve point gid
Supply curve row index
Get the SC point state based on the resource meta data.
Supply curve point's meta data summary
Get the SC point timezone based on the resource meta data.
- property h5
h5 Resource handler object
- Returns:
_h5 (Resource) – Resource h5 handler object.
- mean_wind_dirs(dset)[source]
Calc the mean wind directions at every time-step
- Parameters:
dset (str) – Wind direction dataset to aggregate
- Returns:
mean_wind_dirs (np.ndarray | float) – Mean wind direction masked by the binary exclusions
- classmethod run(gid, excl, agg_h5, tm_dset, *wind_dir_dsets, excl_dict=None, inclusion_mask=None, resolution=64, excl_area=0.0081, exclusion_shape=None, close=True, gen_index=None)[source]
Compute exclusions weight mean for the sc point from data
- Parameters:
gid (int) – gid for supply curve point to analyze.
excl (str | ExclusionMask) – Filepath to exclusions h5 or ExclusionMask file handler.
agg_h5 (str | Resource) – Filepath to .h5 file to aggregate or Resource handler
tm_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
wind_dir_dsets (str) – Wind direction dataset(s) to aggregate, can supply multiple datasets
excl_dict (dict | None) – Dictionary of exclusion LayerMask arugments {layer: {kwarg: value}} None if excl input is pre-initialized.
inclusion_mask (np.ndarray) – 2D array pre-extracted inclusion mask where 1 is included and 0 is excluded. The shape of this will be checked against the input resolution.
resolution (int) – Number of exclusion points per SC point along an axis. This number**2 is the total number of exclusion points per SC point.
excl_area (float) – Area of an exclusion cell (square km).
exclusion_shape (tuple) – Shape of the full exclusions extent (rows, cols). Inputing this will speed things up considerably.
close (bool) – Flag to close object file handlers on exit.
gen_index (np.ndarray) – Array of generation gids with array index equal to resource gid. Array value is -1 if the resource index was not used in the generation run.
- Returns:
out (dict) – Wind direction(s) and meta data aggregated to given supply curve point gid
- agg_data_layers(summary, data_layers)
Perform additional data layer aggregation. If there is no valid data in the included area, the data layer will be taken from the full SC point extent (ignoring exclusions). If there is still no valid data, a warning will be raised and the data layer will have a NaN/None value.
- Parameters:
summary (dict) – Dictionary of summary outputs for this sc point.
data_layers (None | dict) – Aggregation data layers. Must be a dictionary keyed by data label name. Each value must be another dictionary with “dset”, “method”, and “fpath”.
- Returns:
summary (dict) – Dictionary of summary outputs for this sc point. A new entry for each data layer is added.
- aggregate(arr)
Calc sum (aggregation) of the resource data.
- Parameters:
arr (np.ndarray) – Array of resource data.
- Returns:
agg (float) – Sum of arr masked by the binary exclusions
- property area
Get the non-excluded resource area of the supply curve point in the current resource class.
- Returns:
area (float) – Non-excluded resource/generation area in square km.
- property bool_mask
Get a boolean inclusion mask (True if excl point is not excluded).
- Returns:
mask (np.ndarray) – Mask with length equal to the flattened exclusion shape
- property centroid
Get the supply curve point centroid coordinate.
- Returns:
centroid (tuple) – SC point centroid (lat, lon).
- close()
Close all file handlers.
- property cols
Get the cols of the exclusions layer associated with this SC point.
- Returns:
cols (slice) – Column slice to index the high-res layer (exclusions layer) for the gid in the agg layer (supply curve layer).
- property country
Get the SC point country based on the resource meta data.
- property county
Get the SC point county based on the resource meta data.
- property elevation
Get the SC point elevation based on the resource meta data.
- exclusion_weighted_mean(arr, drop_nan=True)
Calc the exclusions-weighted mean value of an array of resource data.
- Parameters:
arr (np.ndarray) – Array of resource data.
drop_nan (bool) – Flag to drop nan values from the mean calculation (only works for 1D arr input, profiles should not have NaN’s)
- Returns:
mean (float | np.ndarray) – Mean of arr masked by the binary exclusions then weighted by the non-zero exclusions. This will be a 1D numpy array if the input data is a 2D numpy array (averaged along axis=1)
- property exclusions
Get the exclusions object.
- Returns:
_excls (ExclusionMask) – ExclusionMask h5 handler object.
- static get_agg_slices(gid, shape, resolution)
Get the row, col slices of an aggregation gid.
- Parameters:
gid (int) – Gid of interest in the aggregated layer.
shape (tuple) – (row, col) shape tuple of the underlying high-res layer.
resolution (int) – Resolution of the aggregation: number of pixels in 1D being aggregated.
- Returns:
row_slice (slice) – Row slice to index the high-res layer for the gid in the agg layer.
col_slice (slice) – Col slice to index the high-res layer for the gid in the agg layer.
- property gid
Supply curve point gid
- property gid_counts
Get the sum of the inclusion values in each resource/generation gid corresponding to this sc point. The sum of the gid counts can be less than the value provided by n_gids if fractional exclusion/inclusions are provided.
- Returns:
gid_counts (list)
- property h5_gid_set
Get list of unique h5 gids corresponding to this sc point.
- Returns:
h5_gids (list) – List of h5 gids.
- property include_mask
[0, 1] where 1 is included and 0 is excluded).
- Returns:
np.ndarray
- Type:
Get the 2D inclusion mask (normalized with expected range
- property include_mask_flat
Get the flattened inclusion mask (normalized with expected range: [0, 1] where 1 is included and 0 is excluded).
- Returns:
np.ndarray
- property latitude
Get the SC point latitude
- property longitude
Get the SC point longitude
- property n_gids
Get the total number of not fully excluded pixels associated with the available resource/generation gids at the given sc gid.
- Returns:
n_gids (list)
- property offshore
Get the SC point offshore flag based on the resource meta data (if offshore column is present).
- property pixel_area
The area in km2 of a single exclusion pixel. If this value was not provided on initialization, it is determined from the profile of the exclusion file.
- Returns:
float
- property resolution
Get the supply curve grid aggregation resolution
- property rows
Get the rows of the exclusions layer associated with this SC point.
- Returns:
rows (slice) – Row slice to index the high-res layer (exclusions layer) for the gid in the agg layer (supply curve layer).
- classmethod sc_mean(gid, excl, tm_dset, data, excl_dict=None, resolution=64, exclusion_shape=None, close=True)
Compute exclusions weight mean for the sc point from data
- Parameters:
gid (int) – gid for supply curve point to analyze.
excl (str | ExclusionMask) – Filepath to exclusions h5 or ExclusionMask file handler.
tm_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
data (ndarray | ResourceDataset) – Array of data or open dataset handler to apply exclusions too
excl_dict (dict | None) – Dictionary of exclusion keyword arugments of the format {layer_dset_name: {kwarg: value}} where layer_dset_name is a dataset in the exclusion h5 file and kwarg is a keyword argument to the reV.supply_curve.exclusions.LayerMask class. None if excl input is pre-initialized.
resolution (int) – Number of exclusion points per SC point along an axis. This number**2 is the total number of exclusion points per SC point.
exclusion_shape (tuple) – Shape of the full exclusions extent (rows, cols). Inputing this will speed things up considerably.
close (bool) – Flag to close object file handlers on exit
- Returns:
ndarray – Exclusions weighted means of data for supply curve point
- property sc_point_gid
Supply curve point gid
- Returns:
int
- classmethod sc_sum(gid, excl, tm_dset, data, excl_dict=None, resolution=64, exclusion_shape=None, close=True)
Compute the aggregate (sum) of data for the sc point
- Parameters:
gid (int) – gid for supply curve point to analyze.
excl (str | ExclusionMask) – Filepath to exclusions h5 or ExclusionMask file handler.
tm_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
data (ndarray | ResourceDataset) – Array of data or open dataset handler to apply exclusions too
excl_dict (dict | None) – Dictionary of exclusion keyword arugments of the format {layer_dset_name: {kwarg: value}} where layer_dset_name is a dataset in the exclusion h5 file and kwarg is a keyword argument to the reV.supply_curve.exclusions.LayerMask class. None if excl input is pre-initialized.
resolution (int) – Number of exclusion points per SC point along an axis. This number**2 is the total number of exclusion points per SC point.
exclusion_shape (tuple) – Shape of the full exclusions extent (rows, cols). Inputing this will speed things up considerably.
close (bool) – Flag to close object file handlers on exit.
- Returns:
ndarray – Sum / aggregation of data for supply curve point
- property state
Get the SC point state based on the resource meta data.
- property summary
Supply curve point’s meta data summary
- Returns:
pandas.Series – List of supply curve point’s meta data
- property timezone
Get the SC point timezone based on the resource meta data.