reVX.rpm.rpm_output.RPMOutput
- class RPMOutput(rpm_clusters, cf_fpath, excl_fpath, excl_dict, techmap_dset, excl_area=None, include_threshold=0.001, n_profiles=1, rerank=True, cluster_kwargs=None, max_workers=None, trg_bins=None, trg_dset='lcoe_fcr', pre_extract_inclusions=False, target_crs=None)[source]
Bases:
object
Framework to format and process RPM clustering results.
- Parameters:
rpm_clusters (pd.DataFrame | str) – Single DataFrame with (gid, gen_gid, cluster_id, rank), or str to file.
cf_fpath (str) – Path to reV .h5 file containing desired capacity factor profiles
excl_fpath (str | None) – Filepath to exclusions data (must match the techmap grid). None will not apply exclusions.
excl_dict (dict | None) – Dictionary of exclusion LayerMask arugments {layer: {kwarg: value}}
techmap_dset (str) – Dataset name in the exclusions file containing the exclusions-to-resource mapping data.
excl_area (float | None) – Area in km2 of one exclusion pixel. None will calculate the exclusion pixel area from the exclusion projection profile.
include_threshold (float) – Inclusion threshold. Resource pixels included more than this threshold will be considered in the representative profiles. Set to zero to find representative profile on all resource, not just included.
n_profiles (int) – Number of representative profiles to output.
rerank (bool) – Flag to rerank representative generation profiles after removing excluded generation pixels.
cluster_kwargs (dict) – RPMClusters kwargs
max_workers (int, optional) – Number of parallel workers. 1 will run serial, None will use all available., by default None
trg_bins (str | list | None) – TRG bins as an ordered list of bin edge values or string to a csv containing a single column with bin edge values. None will ignore trgs.
trg_dset (str) – Dataset associated with TRG bins that can be found in the cf_fpath file.
pre_extract_inclusions (bool) – Flag to pre-extract the inclusion mask using excl_fpath and excl_dict. This is advantageous if the excl_dict is highly complex and if you’re processing a lot of points. Default is False.
target_crs (str) – Target coordinate reference system, e.g. “EPSG:4326”. Note that everything is in EPSG:4326/WGS84 by default (raw lat/lon with lon=0 at Greenwich).
Methods
Calculate exclusions for clusters, adding data to self._clusters.
Apply TRG's if requested.
export_all
(out_dir[, job_tag])Run RPM output algorithms and write to CSV's.
extract_profiles
(rpm_clusters, cf_fpath, out_dir)Use pre-formatted RPM cluster outputs to generate profile outputs.
make_shape_file
(fpath_shp)Make shape file containing all clusters.
process_outputs
(rpm_clusters, cf_fpath, ...)Perform output processing on clusters and write results to disk.
run_rerank
([groupby, rank_col])Re-rank rep profiles for included resource in generic groups.
Attributes
Summary dataframe with cluster_id primary key.
Get the full 2D array of latitudes of the exclusion grid.
Get the full 2D array of longitudes of the exclusion grid.
- property excl_lat
Get the full 2D array of latitudes of the exclusion grid.
- Returns:
_excl_lat (np.ndarray) – 2D array representing the latitudes at each exclusion grid cell
- property excl_lon
Get the full 2D array of longitudes of the exclusion grid.
- Returns:
_excl_lon (np.ndarray) – 2D array representing the latitudes at each exclusion grid cell
- apply_exclusions()[source]
Calculate exclusions for clusters, adding data to self._clusters.
- Returns:
self._clusters (pd.DataFrame) – self._clusters with new columns for exclusions data.
- run_rerank(groupby='cluster_id', rank_col='rank_included')[source]
Re-rank rep profiles for included resource in generic groups.
- Parameters:
groupby (str | list) – One or more columns in self._clusters to groupby and rank profiles within each group.
rank_col (str) – Column to add to self._clusters with new rankings.
- property cluster_summary
Summary dataframe with cluster_id primary key.
- Returns:
s (pd.DataFrame) – Summary dataframe with a row for each cluster id.
- make_shape_file(fpath_shp)[source]
Make shape file containing all clusters.
- Parameters:
fpath_shp (str) – Filepath to write shape_file to.
- export_all(out_dir, job_tag=None)[source]
Run RPM output algorithms and write to CSV’s.
- Parameters:
out_dir (str) – Directory to dump output files.
job_tag (str | None) – Optional name tag to add to the csvs being saved. Format is “rpm_cluster_output_{tag}.csv”.
- classmethod extract_profiles(rpm_clusters, cf_fpath, out_dir, n_profiles=1, job_tag=None, max_workers=None, key=None, forecast_fpath=None)[source]
Use pre-formatted RPM cluster outputs to generate profile outputs.
- Parameters:
rpm_clusters (pd.DataFrame | str) – Single DataFrame with (gid, gen_gid, cluster_id, rank), or str to file.
cf_fpath (str) – reV generation output file.
out_dir (str) – Directory to dump output files.
n_profiles (int) – Number of representative profiles to output.
job_tag (str | None) – Optional name tag to add to the output files. Format is “rpm_cluster_output_{tag}.csv”.
max_workers (int, optional) – Number of parallel workers. 1 will run serial, None will use all available., by default None
key (str | None) – Column in clusters to sort ranks by. None will allow for default logic.
forecast_fpath (str) – reV generation output file for forecast data. If this is input, profiles will be taken from forecast fpath instead of fpath gen based on a NN mapping.
- classmethod process_outputs(rpm_clusters, cf_fpath, excl_fpath, excl_dict, techmap_dset, out_dir, job_tag=None, max_workers=None, cluster_kwargs=None, excl_area=None, include_threshold=0.001, n_profiles=1, rerank=True, trg_bins=None, trg_dset='lcoe_fcr', pre_extract_inclusions=False, target_crs=None)[source]
Perform output processing on clusters and write results to disk.
- Parameters:
rpm_clusters (pd.DataFrame | str) – Single DataFrame with (gid, gen_gid, cluster_id, rank), or str to file.
cf_fpath (str) – Path to reV .h5 file containing desired capacity factor profiles
excl_fpath (str | None) – Filepath to exclusions data (must match the techmap grid). None will not apply exclusions.
excl_dict (dict | None) – Dictionary of exclusion LayerMask arugments {layer: {kwarg: value}}
techmap_dset (str) – Dataset name in the techmap file containing the exclusions-to-resource mapping data.
out_dir (str) – Directory to dump output files.
job_tag (str | None) – Optional name tag to add to the output files. Format is “rpm_cluster_output_{tag}.csv”.
max_workers (int, optional) – Number of parallel workers. 1 will run serial, None will use all available., by default None
excl_area (float | None) – Area in km2 of one exclusion pixel. None will calculate the exclusion pixel area from the exclusion projection profile.
include_threshold (float) – Inclusion threshold. Resource pixels included more than this threshold will be considered in the representative profiles. Set to zero to find representative profile on all resource, not just included.
n_profiles (int) – Number of representative profiles to output.
rerank (bool) – Flag to rerank representative generation profiles after removing excluded generation pixels.
trg_bins (str | list | None) – TRG bins as an ordered list of bin edge values or string to a csv containing a single column with bin edge values. None will ignore trgs.
trg_dset (str) – Dataset associated with TRG bins that can be found in the cf_fpath file.
pre_extract_inclusions (bool) – Flag to pre-extract the inclusion mask using excl_fpath and excl_dict. This is advantageous if the excl_dict is highly complex and if you’re processing a lot of points. Default is False.
target_crs (str) – Target coordinate reference system, e.g. “EPSG:4326”. Note that everything is in EPSG:4326/WGS84 by default (raw lat/lon with lon=0 at Greenwich).