reVX.plexos.rev_reeds_plexos.PlexosAggregation
- class PlexosAggregation(plexos_nodes, rev_sc, reeds_build, cf_fpath, forecast_fpath=None, build_year=2050, plexos_columns=None, force_full_build=False, force_shape_map=False, plant_name_col=None, tech_tag=None, res_class=None, timezone='UTC', dset_tag=None, bespoke=False, gid_column='sc_gid', max_workers=None)[source]
Bases:
BaseProfileAggregation
Framework to aggregate reV gen profiles to PLEXOS node power profiles. This class takes as input the plexos nodes meta data (lat/lon or shape files), rev supply curve table, and reeds buildout table (specifying which rev sc points were built and at what capacity). The class will build power profiles for each supply curve point and then aggregate the sc point profiles to the nearest neighbor plexos node (if plexos nodes are defined by lat/lon) or the shape intersect plexos node (if plexos nodes are defined by shape file).
- Parameters:
plexos_nodes (str | pd.DataFrame) – Plexos node meta data including gid, latitude, longitude, voltage (optional). Or file path to .csv containing plexos node meta data, or a file path to a .shp file that contains plexos nodes defined as shapes.
rev_sc (str | pd.DataFrame) – reV supply curve results table including SC gid, latitude, longitude, res_gids, gid_counts. Or file path to reV supply curve table.
reeds_build (str | pd.DataFrame) – ReEDS buildout with rows for built capacity (MW) at each reV SC point. This should have columns: reeds_year, built_capacity, and sc_gid (corresponding to the reV supply curve point gid). Some cleaning of the column names will be performed for legacy tables but these are the column headers that are desired. This input can also include “plexos_node_gid” which will explicitly assign a supply curve point buildout to a single plexos node. If included, all points must be assigned to plexos nodes.
cf_fpath (str) – File path to capacity factor file (reV gen output) to get profiles from.
forecast_fpath (str | None) – Forecasted capacity factor .h5 file path (reV results). If not None, the supply curve res_gids are mapped to sites in the cf_fpath, then the coordinates from cf_fpath are mapped to the nearest neighbor sites in the forecast_fpath, where the final generation profiles are retrieved from.
build_year (int, optional) – REEDS year of interest, by default 2050
plexos_columns (list | None) – Additional columns from the plexos_nodes input to pass through to the output meta data.
force_full_build (bool) – Flag to ensure the full requested buildout is built at each SC point. If True, the remainder of the requested build will always be built at the last resource gid in the sc point.
force_shape_map (bool) – Flag to force the mapping of supply curve points to the plexos node shape file input (if a shape file is input) via nearest neighbor to shape centroid.
plant_name_col (str | None) – Column in plexos_table that has the plant name that should be used in the plexos output csv column headers.
tech_tag (str | None) – Optional technology tag to include as a suffix in the plexos output csv column headers.
res_class (int | None) – Optional resource class to use to filter supply curve points. For example, if res_class = 3 then only supply curve points with class 3 will be kept in the sc_build table. This filters the on the ‘class’ column in the reeds_build table.
timezone (str) – Timezone for output generation profiles. This is a string that will be passed to pytz.timezone() e.g. US/Pacific, US/Mountain, US/Central, US/Eastern, or UTC. For a list of all available timezones, see pytz.all_timezones
dset_tag (str) – Dataset tag to append to dataset names in cf profile file. e.g. If the cf profile file is a multi year file using dset_tag=”-2008” will enable us to select the corresponding datasets (cf_mean-2008, cf_profile-2008, etc)
bespoke (bool) – Flag to signify if the cf_fpath file was generated using the reV bespoke wind module. The bespoke output files have generation profiles at the supply curve grid resolution which is different than traditional reV generation outputs that are on the resource grid resolution.
gid_column (str, optional) – Reference column to use for supply curve gid. Valid options are sc_gid and sc_point_gid.
max_workers (int | None) – Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
Methods
convert_bespoke_sc
(df, gid_column)Convert a bespoke supply curve table to reference resource gids (res_gids) based on the bespoke generation outputs that are on the supply curve grid not the resource grid
export
(meta, time_index, profiles, out_fpath)Export generation profiles to h5 and plexos-formatted csv
get_unique_plant_names
(table, name_col[, ...])Get a list of ordered unique plant names
Make a 2D array of aggregated plexos gen profiles.
run
(plexos_nodes, rev_sc, reeds_build, cf_fpath)Run plexos aggregation.
tz_convert_profiles
(profiles, timezone)Convert profiles to local time and forward/back fill missing data.
Attributes
Resource gids available in the cf file.
An array mapping the reV "actuals" generation data to forecast data of a different resolution (if input).
Get the number of unique plexos nodes in this buildout.
Nearest neighbor output mapping rev supply curve points to plants or plexos nodes.
Get plexos node meta data for the nodes included in this problem.
Get the reV supply curve table reduced to just those points built by reeds including a built_capacity column in MW.
List of unique resource GIDS in the REEDS build out.
Get the generation profile time index.
Get a short 3-char tz alias if the timezone is common in the US (pst, mst, cst, est)
- property plexos_meta
Get plexos node meta data for the nodes included in this problem.
- Returns:
plexos_meta (pd.DataFrame) – Plexos meta dataframe reduced to the nodes in this problem.
- property n_plexos_nodes
Get the number of unique plexos nodes in this buildout.
- Returns:
n (int) – Number of unique plexos nodes in this buildout
- property sc_res_gids
List of unique resource GIDS in the REEDS build out.
- Returns:
sc_res_gids (np.ndarray) – Array of resource GIDs associated with this REEDS buildout.
- property sc_build
Get the reV supply curve table reduced to just those points built by reeds including a built_capacity column in MW.
- Returns:
pd.DataFrame
- make_profiles()[source]
Make a 2D array of aggregated plexos gen profiles.
- Returns:
profiles (np.ndarray) – (t, n) array of Plexos node generation profiles where t is the timeseries length and n is the number of plexos nodes.
- classmethod run(plexos_nodes, rev_sc, reeds_build, cf_fpath, forecast_fpath=None, build_year=2050, plexos_columns=None, force_full_build=False, force_shape_map=False, plant_name_col=None, tech_tag=None, res_class=None, timezone='UTC', dset_tag=None, bespoke=False, gid_column='sc_gid', out_fpath=None, max_workers=None)[source]
Run plexos aggregation.
- Parameters:
plexos_nodes (str | pd.DataFrame) – Plexos node meta data including gid, latitude, longitude, voltage (optional). Or file path to .csv containing plexos node meta data, or a file path to a .shp file that contains plexos nodes defined as shapes.
rev_sc (str | pd.DataFrame) – reV supply curve results table including SC gid, latitude, longitude, res_gids, gid_counts. Or file path to reV supply curve table. Note that the gen_gids column in the rev_sc is ignored and only the res_gids from rev_sc are mapped to the corresponding “gid” column in the cf_fpath meta data.
reeds_build (pd.DataFrame) – ReEDS buildout with rows for built capacity (MW) at each reV SC point. This should have columns: reeds_year, built_capacity, and sc_gid (corresponding to the reV supply curve point gid). Some cleaning of the column names will be performed for legacy tables but these are the column headers that are desired. This input can also include “plexos_node_gid” which will explicitly assign a supply curve point buildout to a single plexos node. If included, all points must be assigned to plexos nodes.
cf_fpath (str) – File path to capacity factor file (reV gen output) to get profiles from.
forecast_fpath (str | None) – Forecasted capacity factor .h5 file path (reV results). If not None, the supply curve res_gids are mapped to sites in the cf_fpath, then the coordinates from cf_fpath are mapped to the nearest neighbor sites in the forecast_fpath, where the final generation profiles are retrieved from.
build_year (int) – REEDS year of interest.
plexos_columns (list | None) – Additional columns from the plexos_nodes input to pass through to the output meta data.
force_full_build (bool) – Flag to ensure the full requested buildout is built at each SC point. If True, the remainder of the requested build will always be built at the last resource gid in the sc point.
force_shape_map (bool) – Flag to force the mapping of supply curve points to the plexos node shape file input (if a shape file is input) via nearest neighbor to shape centroid.
plant_name_col (str | None) – Column in plexos_table that has the plant name that should be used in the plexos output csv column headers.
tech_tag (str | None) – Optional technology tag to include as a suffix in the plexos output csv column headers.
res_class (int | None) – Optional resource class to use to filter supply curve points. For example, if res_class = 3 then only supply curve points with class 3 will be kept in the sc_build table.
timezone (str) – Timezone for output generation profiles. This is a string that will be passed to pytz.timezone() e.g. US/Pacific, US/Mountain, US/Central, US/Eastern, or UTC. For a list of all available timezones, see pytz.all_timezones
dset_tag (str) – Dataset tag to append to dataset names in cf profile file. e.g. If the cf profile file is a multi year file using dset_tag=”-2008” will enable us to select the corresponding datasets (cf_mean-2008, cf_profile-2008, etc)
bespoke (bool) – Flag to signify if the cf_fpath file was generated using the reV bespoke wind module. The bespoke output files have generation profiles at the supply curve grid resolution which is different than traditional reV generation outputs that are on the resource grid resolution.
gid_column (str, optional) – Reference column to use for supply curve gid. Valid options are sc_gid and sc_point_gid.
out_fpath (str, optional) – Path to .h5 file into which plant buildout should be saved. A plexos-formatted csv will also be written in the same directory. By default None.
max_workers (int | None) – Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
- Returns:
plexos_meta (pd.DataFrame) – Plexos node meta data with built capacities.
time_index (pd.datetimeindex) – Time index for the profiles.
profiles (np.ndarray) – Generation profile timeseries at each plexos node.
- property available_res_gids
Resource gids available in the cf file.
- Returns:
res_gids (np.ndarray) – Array of resource GIDs available in the cf file.
- static convert_bespoke_sc(df, gid_column)
Convert a bespoke supply curve table to reference resource gids (res_gids) based on the bespoke generation outputs that are on the supply curve grid not the resource grid
- Parameters:
table (pd.DataFrame) – rev_sc and reeds_build inner joined on supply curve gid.
gid_column (str) – String to use for sc_gid.
- Returns:
table (pd.DataFrame) – Modified so that the “res_gids” points to the supply curve gids in the bespoke file so that the resource generation profiles will be taken based on the bespoke indexing.
- export(meta, time_index, profiles, out_fpath)
Export generation profiles to h5 and plexos-formatted csv
- Parameters:
plant_meta (pd.DataFrame) – Plant / plexos node meta data with built capacities and mappings to the resource used.
time_index (pd.datetimeindex) – Time index for the profiles.
profiles (np.ndarray) – Generation profile timeseries in MW at each plant / plexos node.
out_fpath (str, optional) – Path to .h5 file into which plant buildout should be saved. A plexos-formatted csv will also be written in the same directory. By default None.
- property forecast_map
An array mapping the reV “actuals” generation data to forecast data of a different resolution (if input). This is an (n, 1) array where n is the number of “actuals” generation data points. So self.forecast_map[9] yields the forecast index that corresponds to index 9 in the cf_fpath reV generation output.
- Returns:
np.ndarray | None
- static get_unique_plant_names(table, name_col, tech_tag=None)
Get a list of ordered unique plant names
- Parameters:
table (pd.DataFrame) – Plexos / plant meta data table where every row is a plant
name_col (str) – Column label in table. Exception will be raised if not found.
tech_tag (str) – Technology tag to append to plant names like “pv” or “wind”
- Returns:
names (list | None) – List of unique plant names
- property node_map
Nearest neighbor output mapping rev supply curve points to plants or plexos nodes.
- Returns:
np.ndarray
- property time_index
Get the generation profile time index.
- Returns:
time_index (pd.Datetimeindex) – Pandas datetime index sourced from the capacity factor data.
- property tz_alias
Get a short 3-char tz alias if the timezone is common in the US (pst, mst, cst, est)
- Returns:
str
- static tz_convert_profiles(profiles, timezone)
Convert profiles to local time and forward/back fill missing data.
- Parameters:
profiles (np.ndarray) – Profiles of shape (time, n_plants) in UTC
timezone (str) – Timezone for output generation profiles. This is a string that will be passed to pytz.timezone() e.g. US/Pacific, US/Mountain, US/Central, US/Eastern, or UTC. For a list of all available timezones, see pytz.all_timezones
- Returns:
profiles (np.ndarray) – Profiles of shape (time, n_plants) in timezone