reV.supply_curve.points.AggregationSupplyCurvePoint

class AggregationSupplyCurvePoint(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: SupplyCurvePoint

Generic single SC point to aggregate data from an h5 file.

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(arr)

Calc the mean wind directions at every time-step

run(gid, excl, agg_h5, tm_dset, *agg_dset[, ...])

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

area

Get the non-excluded resource area of the supply curve point in the current resource class.

bool_mask

Get a boolean inclusion mask (True if excl point is not excluded).

centroid

Get the supply curve point centroid coordinate.

cols

Get the cols of the exclusions layer associated with this SC point.

country

Get the SC point country based on the resource meta data.

county

Get the SC point county based on the resource meta data.

elevation

Get the SC point elevation based on the resource meta data.

exclusions

Get the exclusions object.

gid

Supply curve point gid

gid_counts

Get the sum of the inclusion values in each resource/generation gid corresponding to this sc point.

h5

h5 Resource handler object

h5_gid_set

Get list of unique h5 gids corresponding to this sc point.

include_mask

[0, 1] where 1 is included and 0 is excluded).

include_mask_flat

Get the flattened inclusion mask (normalized with expected range: [0, 1] where 1 is included and 0 is excluded).

latitude

Get the SC point latitude

longitude

Get the SC point longitude

n_gids

Get the total number of not fully excluded pixels associated with the available resource/generation gids at the given sc gid.

offshore

Get the SC point offshore flag based on the resource meta data (if offshore column is present).

pixel_area

The area in km2 of a single exclusion pixel.

resolution

Get the supply curve grid aggregation resolution

rows

Get the rows of the exclusions layer associated with this SC point.

sc_col_ind

Supply curve column index

sc_point_gid

Supply curve point gid

sc_row_ind

Supply curve row index

state

Get the SC point state based on the resource meta data.

summary

Supply curve point's meta data summary

timezone

Get the SC point timezone based on the resource meta data.

close()[source]

Close all file handlers.

property h5

h5 Resource handler object

Returns:

_h5 (Resource) – Resource h5 handler object.

property country

Get the SC point country based on the resource meta data.

property state

Get the SC point state 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.

property timezone

Get the SC point timezone based on the resource meta data.

property offshore

Get the SC point offshore flag based on the resource meta data (if offshore column is present).

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 summary

Supply curve point’s meta data summary

Returns:

pandas.Series – List of supply curve point’s meta data

classmethod run(gid, excl, agg_h5, tm_dset, *agg_dset, agg_method='mean', excl_dict=None, inclusion_mask=None, resolution=64, excl_area=None, 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.

  • agg_dset (str) – Dataset to aggreate, can supply multiple datasets or no datasets. The datasets should be scalar values for each site. This method cannot aggregate timeseries data.

  • agg_method (str) – Aggregation method, either mean or sum/aggregate

  • 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.

Returns:

out (dict) – Given datasets and meta data aggregated to supply curve points

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).

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).

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 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

mean_wind_dirs(arr)

Calc the mean wind directions at every time-step

Parameters:

arr (np.ndarray) – Array of wind direction data.

Returns:

mean_wind_dirs (np.ndarray | float) – Mean wind direction of arr masked by the binary exclusions

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 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).

property sc_col_ind

Supply curve column index

Type:

int

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

property sc_row_ind

Supply curve row index

Type:

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