reVX.pras.rev_reeds_pras.PrasAggregation
- class PrasAggregation(rev_sc, reeds_build, cf_fpath, pras_file, forecast_fpath=None, build_year=2050, res_class=None, tech_type=None, timezone='US/Central', dset_tag=None, max_workers=None)[source]
Bases:
PlexosAggregation
Framework to aggregate reV gen profiles to PRAS zone power profiles and overwrite exisiting pras file with new generation profiles. This class takes as input 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 pras zone. The corresponding zone power profiles in the pras output file will be overwritten with these new aggregated generation profiles.
Examples
>>> from reVX.pras.rev_reeds_pras import PrasAggregation >>> >>> rev_supply_curve_file = ... >>> reeds_build_file = ... >>> capacity_factor_file = ... >>> pras_file = ... >>> >>> PrasAggregation.run(rev_supply_curve_file, reeds_build_file, capacity_factor_file, pras_file, build_year=2047, tech_type='upv')
This will replace all the pras generation profiles with upv tech in the file pras_file.pras.h5 with aggregated generation profiles from cf_path.h5
>>> reeds_build_files = [...] >>> capacity_factor_files = [...] >>> tech_types = ['upv', 'dupv', 'wind-ons', 'wind-ofs'] >>> >>> PrasAggregation.run(rev_supply_curve_file, reeds_build_files, capacity_factor_files, pras_file, build_year=2047, tech_type=tech_types)
This will run the same routine but for each tech type in tech_types. The files in reeds_build_files and capacity_factor_files have to correspond to the tech type in the tech_types list.
- Parameters:
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: year, region, class, 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.
cf_fpath (str) – File path to .h5 capacity factor file (reV gen output) to get profiles from.
pras_file (str) – File path to existing hdf5 PRAS file (.pras or .h5 extension) which will be amended to include generation data from given resource data. This file must have a ‘generators’ group with ‘_core’ and ‘capacity’ datasets in this group.
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
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. The corresponds to the ‘class’ column in the reeds_build file.
tech_type (str | None) – Pras files will have the tech type in the [‘generation/_core’][‘name’] entry, which is used to select the correct output index
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)
max_workers (int | None) – Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
Methods
enforce_tech_constraint
(meta)Filter the pras generator meta for the requested technology type and class
export
(time_index, profiles)Export generation profiles to h5 and plexos-formatted csv
Check for zones present in the pras output file which cannot be found in the supply curve zone list
get_pras_classes
(pras_file, tech_type)Get list of tech classes present in the pras file for the requested technology type
get_pras_meta
(pras_file)Get pras 'meta' which describes the tech type and class at each zone For upv and dupv regions are labeled p1, p2, etc.
get_unique_plant_names
(table, name_col[, ...])Get a list of ordered unique plant names
Make a 2D array of aggregated plexos gen profiles.
qa
(profiles)Simple QA to check original mean/min/max capacity and the mean/min/max capacity for the updated generation profiles
run
(rev_sc, reeds_build, cf_fpath, pras_file)Run pras aggregation and output for the requested tech types.
tz_convert_profiles
(profiles, timezone)Convert profiles to local time and forward/back fill missing data.
Attributes
Resource gids available in the cf file.
Get the built capacity for all zones found in the pras output file and the reeds build file.
Get pras 'meta' without filtering for tech_type and class
An array mapping the reV "actuals" generation data to forecast data of a different resolution (if input).
List of sc build zones found in the pras output file for the requested tech and class
List of pras zones found in the reeds build out for the requested tech and class
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 list of pras file indices for the pras zones available in the supply curve zone list.
Get pras 'meta' which describes the tech type and class at each zone
Get the list of pras entry names for the pras zones available in the supply curve zone list.
Get list of all available zones in pras output file for the requested tech and class.
Get the reV supply curve table reduced to just those points built by reeds including a built_capacity column in MW.
Get the list of profile indices corresponding to the sc_build_zones - used to write the new profiles to the pras output.
Get the labels for the zones in the zone_map.
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)
Get the map between zone index and zone label.
- classmethod get_pras_meta(pras_file)[source]
Get pras ‘meta’ which describes the tech type and class at each zone For upv and dupv regions are labeled p1, p2, etc. For wind and csp regions are labeled s1, s2, etc.
- Parameters:
pras_file (str) – Path to the pras file being overwritten with new generation profiles
- Returns:
pd.DataFrame
- classmethod get_pras_classes(pras_file, tech_type)[source]
Get list of tech classes present in the pras file for the requested technology type
- Parameters:
pras_file (str) – Path to the pras file being overwritten with new generation profiles
tech_type (str) – Technology type for which profiles are being overwritten
- Returns:
List
- property zone_index_map
Get the map between zone index and zone label. i.e. zone_index=1, zone_label=p10
- property sc_build_zones
Get the labels for the zones in the zone_map. For example, the zone_map might have an index of 1 for the region but this corresponds to the label of p10.
- property complete_pras_meta
Get pras ‘meta’ without filtering for tech_type and class
- Returns:
pd.DataFrame
- property pras_meta
Get pras ‘meta’ which describes the tech type and class at each zone
- Returns:
pd.DataFrame
- property pras_zones
Get list of all available zones in pras output file for the requested tech and class. For upv and dupv regions are labeled p1, p2, etc. For wind and csp regions are labeled s1, s2, etc.
- Returns:
List
- property pras_indices
Get the list of pras file indices for the pras zones available in the supply curve zone list.
- Returns:
np.ndarray
- property pras_names
Get the list of pras entry names for the pras zones available in the supply curve zone list.
- Returns:
np.ndarray
- property found_pras_zones
List of pras zones found in the reeds build out for the requested tech and class
- Returns:
np.ndarray
- property found_build_zones
List of sc build zones found in the pras output file for the requested tech and class
- Returns:
np.ndarray
- property sc_build_indices
Get the list of profile indices corresponding to the sc_build_zones - used to write the new profiles to the pras output.
- Returns:
List
- property built_capacity
Get the built capacity for all zones found in the pras output file and the reeds build file.
- Returns:
np.ndarray
- enforce_tech_constraint(meta)[source]
Filter the pras generator meta for the requested technology type and class
- Parameters:
meta (pd.DataFrame) – Full pras ‘meta’ without tech_type or class filtering
- Returns:
pd.DataFrame – pras meta DataFrame filtered by tech_type and class
- get_missing_zones()[source]
Check for zones present in the pras output file which cannot be found in the supply curve zone list
- qa(profiles)[source]
Simple QA to check original mean/min/max capacity and the mean/min/max capacity for the updated generation profiles
- Parameters:
profiles (np.ndarray) – Generation profile timeseries in MW at each plant / pras zone.
- Returns:
new_cap (np.ndarray) – Array containing the updated generation profiles
- export(time_index, profiles)[source]
Export generation profiles to h5 and plexos-formatted csv
- Parameters:
time_index (pd.datetimeindex) – Time index for the profiles.
profiles (np.ndarray) – Generation profile timeseries in MW at each plant / pras zone.
- classmethod run(rev_sc, reeds_build, cf_fpath, pras_file, forecast_fpath=None, build_year=2050, res_class=None, tech_type=None, timezone='US/Central', dset_tag=None, max_workers=None)[source]
Run pras aggregation and output for the requested tech types. This will aggregate the generation profiles over region specific supply curve points found in rev_sc, after filtering rev_sc for the requested tech type, and resource class. These aggregated generation profiles will then be written to the pras output file in the location corresponding to the region, tech type, and class.
- rev_scstr | pd.DataFrame
reV supply curve results table including SC gid, latitude, longitude, res_gids, gid_counts. Or file path to reV supply curve table. If providing a list of tech types this also needs to be a list of the corresponding supply curve files.
- reeds_buildstr | pd.DataFrame | list
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 pras zone. If included, all points must be assigned to pras zones. If providing a list of tech types this also needs to be a list of the corresponding reeds builout files for each tech type.
- cf_fpathstr | list
File path to capacity factor file (reV gen output) to get profiles from. If providing a list of tech types this also needs to be a list of the corresponding capacity factor files.
- pras_filestr
File path to existing PRAS file which will be amended to include generation data from given resource data.
- forecast_fpathstr | 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_yearint, optional
REEDS year of interest, by default 2050
- res_classint | 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. If None then the aggregation will be run for each class found in the pras output file
- tech_typestr | list
Tech type for which to overwrite the generation profiles in the pras output file. Pras files will have the tech type in the [‘generation/_core’][‘name’] entry, which is used to select the correct output index
- timezonestr
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_tagstr
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)
- max_workersint | None
Max workers for parallel profile aggregation. None uses all available workers. 1 will run in serial.
- 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.
- 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
- make_profiles()
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.
- 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 node_map
Nearest neighbor output mapping rev supply curve points to plants or plexos nodes.
- Returns:
np.ndarray
- 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 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
- 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 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