reVX.plexos.simple_plant_builder.SimplePlantBuilder
- class SimplePlantBuilder(plant_meta, rev_sc, cf_fpath, forecast_fpath=None, plant_name_col=None, tech_tag=None, timezone='UTC', share_resource=True, max_workers=None)[source]
Bases:
BaseProfileAggregation
Class to build generation profiles for “plants” by aggregating resource from nearest neighbor supply curve points.
Run plexos aggregation.
- Parameters:
plant_meta (str | pd.DataFrame) – Str filepath or extracted dataframe for plant meta data with every row representing a plant with columns for latitude, longitude, and capacity (in MW). Plants will compete for available capacity in the reV supply curve input and will be prioritized based on the row order of this input.
rev_sc (str | pd.DataFrame) – reV supply curve or sc-aggregation output table including sc_gid, latitude, longitude, res_gids, gid_counts, mean_cf.
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 generation profiles are sourced from this file.
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.
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
share_resource (bool) – Flag to share available capacity within a single resource GID between multiple plants.
max_workers (int | None) – Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
Methods
March through the plant meta data and make subsets of the supply curve table that will be built out for each plant.
check_valid_buildouts
(plant_sc_builds)Check that plant buildouts are mapped to valid resource data that can be found in the cf_fpath input.
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_profiles
(plant_sc_builds)Make a 2D array of aggregated plant gen profiles.
run
(plant_meta, rev_sc, cf_fpath[, ...])Build profiles and meta data.
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).
Nearest neighbor output mapping rev supply curve points to plants or plexos nodes.
Get plant meta data for the requested plant buildout with buildout information
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 plant_meta
Get plant meta data for the requested plant buildout with buildout information
- Returns:
pd.DataFrame
- assign_plant_buildouts()[source]
March through the plant meta data and make subsets of the supply curve table that will be built out for each plant. The supply curve table attribute of this SimplePlantBuilder instance will be manipulated such that total sc point capacity and resource gid capacity is reduced whenever a plant is built. In this fashion, resource in SC points will not be double counted, but resource within an SC point can be divided up between multiple plants. Resource within an SC point is prioritized by available capacity.
- Returns:
plant_sc_builds (dict) – Dictionary mapping the plant row indices (keys) to subsets of the SC table showing what should be built for each plant. The subset SC tables in this dict will no longer match the sc table attribute of the SimplePlantBuilder instance, because the tables in this dict show what should be built, and the sc table attribute will show what is remaining.
- check_valid_buildouts(plant_sc_builds)[source]
Check that plant buildouts are mapped to valid resource data that can be found in the cf_fpath input.
- make_profiles(plant_sc_builds)[source]
Make a 2D array of aggregated plant gen profiles.
- Returns:
profiles (np.ndarray) – (t, n) array of plant eneration profiles where t is the timeseries length and n is the number of plants.
- classmethod run(plant_meta, rev_sc, cf_fpath, forecast_fpath=None, plant_name_col=None, tech_tag=None, timezone='UTC', share_resource=True, max_workers=None, out_fpath=None)[source]
Build profiles and meta data.
- Parameters:
plant_meta (str | pd.DataFrame) – Str filepath or extracted dataframe for plant meta data with every row representing a plant with columns for latitude, longitude, and capacity (in MW). Plants will compete for available capacity in the reV supply curve input and will be prioritized based on the row order of this input.
rev_sc (str | pd.DataFrame) – reV supply curve or sc-aggregation output table including sc_gid, latitude, longitude, res_gids, gid_counts, mean_cf.
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 generation profiles are sourced from this file.
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.
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
share_resource (bool) – Flag to share available capacity within a single resource GID between multiple plants.
max_workers (int | None) – Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
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.
- Returns:
plant_meta (pd.DataFrame) – Plant 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.
- 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.
- 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