reV.config.project_points.ProjectPoints
- class ProjectPoints(points, sam_configs, tech=None, res_file=None, curtailment=None)[source]
Bases:
object
Class to manage site and SAM input configuration requests.
Examples
>>> import os >>> from reV import TESTDATADIR >>> from reV.config.project_points import ProjectPoints >>> >>> points = slice(0, 100) >>> sam_file = os.path.join(TESTDATADIR, 'SAM/naris_pv_1axis_inv13.json') >>> pp = ProjectPoints(points, sam_file) >>> >>> config_id_site0, SAM_config_dict_site0 = pp[0] >>> site_list_or_slice = pp.sites >>> site_list_or_slice = pp.get_sites_from_config(config_id) >>> ProjectPoints_sub = pp.split(0, 10, project_points) >>> h_list = pp.h
- Parameters:
points (int | slice | list | tuple | str | pd.DataFrame | dict) – Slice specifying project points, string pointing to a project points csv, or a dataframe containing the effective csv contents. Can also be a single integer site value.
sam_configs (dict | str | SAMConfig) – SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s) which map to the config column in the project points CSV. Values are either a JSON SAM config file or dictionary of SAM config inputs. Can also be a single config file path or a pre loaded SAMConfig object.
tech (str, optional) – SAM technology to analyze (pvwattsv7, windpower, tcsmoltensalt, solarwaterheat, troughphysicalheat, lineardirectsteam) The string should be lower-cased with spaces and _ removed, by default None
res_file (str | NoneType) – Optional resource file to find maximum length of project points if points slice stop is None.
curtailment (NoneType | dict | str | config.curtailment.Curtailment) – Inputs for curtailment parameters. If not None, curtailment inputs are expected. Can be:
Explicit namespace of curtailment variables (dict)
Pointer to curtailment config json file with path (str)
Instance of curtailment config object (config.curtailment.Curtailment)
Methods
get_sites_from_config
(config)Get a site list that corresponds to a config key.
index
(gid)Get the index location (iloc not loc) for a resource gid found in the project points.
join_df
(df2[, key])Join new df2 to the _df attribute using the _df's gid as pkey.
lat_lon_coords
(lat_lons, res_file, sam_configs)Generate ProjectPoints for gids nearest to given latitude longitudes
regions
(regions, res_file, sam_configs[, ...])Generate ProjectPoints for gids nearest to given latitude longitudes
split
(i0, i1, project_points)Return split instance of a ProjectPoints instance w/ site subset.
Attributes
Get a list of unique input keys from all SAM technology configs.
Get the curtailment config object.
Get the depths (m) corresponding to the site list.
Get the project points dataframe property.
Get the list of gids (resource file index values) belonging to this instance of ProjectPoints.
Get the hub heights corresponding to the site list.
Get the SAM configs dictionary property.
Get the SAM config object.
Get the SAM configuration inputs dictionary property.
Get the list of sites (resource file gids) belonging to this instance of ProjectPoints.
Get the sites in slice format.
Get the tech property from the config.
- property df
Get the project points dataframe property.
- Returns:
_df (pd.DataFrame) – Table of sites and corresponding SAM configuration IDs. Has columns “gid” and ‘config’.
- property sam_config_ids
Get the SAM configs dictionary property.
- Returns:
dict – Multi-level dictionary containing multiple SAM input config files. The top level key is the SAM config ID, top level value is the SAM config file path
- property sam_config_obj
Get the SAM config object.
- Returns:
_sam_config_obj (reV.config.sam_config.SAMConfig) – SAM configuration object.
- property sam_inputs
Get the SAM configuration inputs dictionary property.
- Returns:
dict – Multi-level dictionary containing multiple SAM input configurations. The top level key is the SAM config ID, top level value is the SAM config. Each SAM config is a dictionary with keys equal to input names, values equal to the actual inputs.
- property all_sam_input_keys
Get a list of unique input keys from all SAM technology configs.
- Returns:
all_sam_input_keys (list) – List of unique strings where each string is a input key for the SAM technology configs. For example, “gcr” or “losses” for PVWatts or “wind_turbine_hub_ht” for windpower.
- property gids
Get the list of gids (resource file index values) belonging to this instance of ProjectPoints. This is an alias of self.sites.
- Returns:
gids (list) – List of integer gids (resource file index values) belonging to this instance of ProjectPoints. This is an alias of self.sites.
- property sites
Get the list of sites (resource file gids) belonging to this instance of ProjectPoints.
- Returns:
sites (list) – List of integer sites (resource file gids) belonging to this instance of ProjectPoints.
- property sites_as_slice
Get the sites in slice format.
- Returns:
sites_as_slice (list | slice) – Sites slice belonging to this instance of ProjectPoints. The type is slice if possible. Will be a list only if sites are non-sequential.
- property tech
Get the tech property from the config.
- Returns:
_tech (str) – SAM technology to analyze (pvwattsv7, windpower, tcsmoltensalt, solarwaterheat, troughphysicalheat, lineardirectsteam) The string should be lower-cased with spaces and _ removed.
- property h
Get the hub heights corresponding to the site list.
- Returns:
_h (list | NoneType) – Hub heights corresponding to each site, taken from the sam config for each site. This is None if the technology is not wind.
- property d
Get the depths (m) corresponding to the site list.
- Returns:
_d (list | NoneType) – Resource depths (m) corresponding to each site, taken from the sam config for each site. This is None if the technology is not geothermal.
- property curtailment
Get the curtailment config object.
- Returns:
_curtailment (NoneType | reV.config.curtailment.Curtailment) – None if no curtailment, reV curtailment config object if curtailment is being assessed.
- index(gid)[source]
Get the index location (iloc not loc) for a resource gid found in the project points.
- Parameters:
gid (int) – Resource GID found in the project points gid column.
- Returns:
ind (int) – Row index of gid in the project points dataframe.
- join_df(df2, key=SiteDataField.GID)[source]
Join new df2 to the _df attribute using the _df’s gid as pkey.
This can be used to add site-specific data to the project_points, taking advantage of the points_control iterator/split functions such that only the relevant site data is passed to the analysis functions.
- Parameters:
df2 (pd.DataFrame) – Dataframe to be joined to the self._df attribute (this instance of project points dataframe). This likely contains site-specific inputs that are to be passed to parallel workers.
key (str) – Primary key of df2 to be joined to the _df attribute (this instance of the project points dataframe). Primary key of the self._df attribute is fixed as the gid column.
- get_sites_from_config(config)[source]
Get a site list that corresponds to a config key.
- Parameters:
config (str) – SAM configuration ID associated with sites.
- Returns:
sites (list) – List of sites associated with the requested configuration ID. If the configuration ID is not recognized, an empty list is returned.
- classmethod split(i0, i1, project_points)[source]
Return split instance of a ProjectPoints instance w/ site subset.
- Parameters:
i0 (int) – Starting INDEX (not resource gid) (inclusive) of the site property attribute to include in the split instance. This is not necessarily the same as the starting site number, for instance if ProjectPoints is sites 20:100, i0=0 i1=10 will result in sites 20:30.
i1 (int) – Ending INDEX (not resource gid) (exclusive) of the site property attribute to include in the split instance. This is not necessarily the same as the final site number, for instance if ProjectPoints is sites 20:100, i0=0 i1=10 will result in sites 20:30.
project_points (ProjectPoints) – Instance of project points to split.
- Returns:
sub (ProjectPoints) – New instance of ProjectPoints with a subset of the following attributes: sites, project points df, and the self dictionary data struct.
- classmethod lat_lon_coords(lat_lons, res_file, sam_configs, tech=None, curtailment=None)[source]
Generate ProjectPoints for gids nearest to given latitude longitudes
- Parameters:
lat_lons (str | tuple | list | ndarray) – Pair or pairs of latitude longitude coordinates
res_file (str) – Resource file, needed to fine nearest neighbors
sam_configs (dict | str | SAMConfig) – SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s) which map to the config column in the project points CSV. Values are either a JSON SAM config file or dictionary of SAM config inputs. Can also be a single config file path or a pre loaded SAMConfig object.
tech (str, optional) – SAM technology to analyze (pvwattsv7, windpower, tcsmoltensalt, solarwaterheat, troughphysicalheat, lineardirectsteam) The string should be lower-cased with spaces and _ removed, by default None
curtailment (NoneType | dict | str | config.curtailment.Curtailment) – Inputs for curtailment parameters. If not None, curtailment inputs are expected. Can be:
Explicit namespace of curtailment variables (dict)
Pointer to curtailment config json file with path (str)
Instance of curtailment config object (config.curtailment.Curtailment)
- Returns:
pp (ProjectPoints) – Initialized ProjectPoints object for points nearest to given lat_lons
- classmethod regions(regions, res_file, sam_configs, tech=None, curtailment=None)[source]
Generate ProjectPoints for gids nearest to given latitude longitudes
- Parameters:
regions (dict) – Dictionary of regions to extract points for in the form: {‘region’: ‘region_column’}
res_file (str) – Resource file, needed to fine nearest neighbors
sam_configs (dict | str | SAMConfig) – SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s) which map to the config column in the project points CSV. Values are either a JSON SAM config file or dictionary of SAM config inputs. Can also be a single config file path or a pre loaded SAMConfig object.
tech (str, optional) – SAM technology to analyze (pvwattsv7, windpower, tcsmoltensalt, solarwaterheat, troughphysicalheat, lineardirectsteam) The string should be lower-cased with spaces and _ removed, by default None
curtailment (NoneType | dict | str | config.curtailment.Curtailment) – Inputs for curtailment parameters. If not None, curtailment inputs are expected. Can be:
Explicit namespace of curtailment variables (dict)
Pointer to curtailment config json file with path (str)
Instance of curtailment config object (config.curtailment.Curtailment)
- Returns:
pp (ProjectPoints) – Initialized ProjectPoints object for points nearest to given lat_lons