R2PD package

Submodules

R2PD.Timeout module

exception R2PD.Timeout.TimeoutError[source]

Bases: Exception

Custom Error for Timeout

class R2PD.Timeout.Timeout(sec)[source]

Bases: object

Timeout wrapper for signal.alarm Currently only compatible with linux systems, need to update for windows

Initialize timeout

Parameters:sec ('float') – seconds before raising TimeoutError
raise_timeout(*args)[source]

Closes event_loop on exit from with

Parameters:*args ('signal.signal handler args') – signal number and frame

R2PD.cli module

R2PD Command Line Interface (CLI)

R2PD.cli.cli_parser()[source]
R2PD.cli.cli_main()[source]

R2PD.datastore module

This module provides classes for accessing site-level wind and solar data from internal and external data stores.

class R2PD.datastore.DataStore[source]

Bases: object

Abstract class to define interface for accessing stores of resource data.

META_ROOT = '/Users/mrossol/Documents/Python_Packages/R2PD/R2PD/library'
static load_meta(meta_path)[source]

Load meta data

Parameters:meta_path ('str') – Path to meta data .json
Returns:meta – DataFrame of resource meta data
Return type:‘pandas.DataFrame’
wind_meta

Return wind meta data

Returns:self._wind_meta – DataFrame of wind resource meta data
Return type:‘pandas.DataFrame’
solar_meta

Return solar meta data

Returns:self._wind_meta – DataFrame of solar resource meta data
Return type:‘pandas.DataFrame’
classmethod decode_config_entry(entry)[source]

Decode config entry converting missing or ‘None’ entires to None

Parameters:entry ('str') – entry from ConfigParser call
Returns:entry – if config entry is not ‘None’ or empty the entry is returned else None is returned
Return type:‘str’ or None
class R2PD.datastore.InternalDataStore(cache_root=None, size=None)[source]

Bases: R2PD.datastore.DataStore

This class manages an internal cache of already downloaded resource data, and other Resource Data Tool information that should persist.

The default location for the internal cache will be in the current working diretory, but the user can set a different location by passing in a configuration file.

A configuration file can also be used to set user library locations, for pointing to externally provided shapers and formatters.

Initialize InternalDataStore object

Parameters:
  • cache_root ('str') – Path to root directory in which local cache should be created Default is ./R2PD/R2PD_Cache
  • size ('float') – Maximum local cache size in GB
PKG_DIR = '/Users/mrossol/Documents/Python_Packages/R2PD'
classmethod connect(config=None)[source]

Reads the configuration. From configuration and defaults, determines initializes InternalDataStore object.

Parameters:config ('str') – Path to .ini configuration file. See library/config.ini for an example
Returns:Initialized InternalDataStore object
Return type:‘InternalDataStore’
static get_cache_size(cache_path)[source]

Searches all sub directories in path for .hdf5 files computes total size in GB

Parameters:cache_path ('str') – Path to cache directory
Returns:repo_size – Returns total size of .hdf5 files in cache in GB
Return type:‘float’
static get_cache_summary(cache_meta)[source]

Summarize the data available in the local cache

Parameters:path ('str') – Path to cache meta .csv
Returns:summary – Summary table of number of sites, and corresponding resource types in local cache
Return type:‘pandas.Series’
cache_size

Calculate size of local cache and dataset caches in GB

Returns:total, wind, and solar cache sizes in GB (floats)
Return type:‘tuple’
cache_summary

Summarize sites and resource types in cache

Returns:Summary of Wind and Solar caches
Return type:‘pandas.DataFrame’
wind_cache

Scan wind cache and update cache meta

Returns:cache_meta – DataFrame of files in wind cache
Return type:‘pandas.DataFrame’
static scan_cache(cache_path, cache_meta)[source]

Scan cache_path and update cache_meta

Parameters:
  • cache_path ('str') – Root directory to be scanned for .hdf5 files
  • cache_meta ('pandas.DataFrame') – DataFrame of resource files in cache
Returns:

cache_meta – Updated DataFrame of resource files in cache

Return type:

‘pandas.DataFrame’

update_cache_meta(dataset=None)[source]

Refresh cache metadata by rescanning cache directory

Parameters:dataset ('str') – ‘wind’ or ‘solar’
check_cache(dataset, site_id, resource_type=None)[source]

Check cache for presence of resource. If resource_type is None check for any resource_type of site_id else check for specific resource_type for site_id

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • site_id ('int') – Site id number
  • resource_type ('str') – type of resource wind -> (‘power’, ‘fcst’, ‘met’) solar -> (‘power’, ‘fcst’, ‘met’, ‘irradiance’)
Returns:

Is site/resource present in cache

Return type:

‘bool’

test_cache_size(download_size)[source]

Test to see if download will fit in cache

Parameters:download_size ('float') – Size of requested download in GB
class R2PD.datastore.ExternalDataStore(local_cache=None, threads=None)[source]

Bases: R2PD.datastore.DataStore

Abstract class to define interface for accessing external stores of resource data.

Initialize ExternalDataStore object

Parameters:
  • local_cache ('InternalDataStore') – InternalDataStore object represening internal data cache
  • threads ('int') – Number of threads to use during downloads
WIND_FILE_SIZES = {'fcst': 1, 'met': 14, 'power': 4.1}
SOLAR_FILE_SIZES = {'fcst': 0, 'met': 31, 'power': 8.4}
classmethod connect(config)[source]

Reads the configuration. From configuration and defaults, determines initializes ExternalDataStore object.

Parameters:config ('str') – Path to .ini configuration file. See library/config.ini for an example
Returns:Initialized ExternalDataStore object
Return type:‘ExternalDataStore’
get_meta(dataset)[source]

Get meta associated with given dataset

Parameters:dataset ('str') – ‘wind’ or ‘solar’
Returns:meta – DataFrame of resource meta
Return type:‘pandas.DataFrame’
get_download_size(dataset, numb_sites, resource_type, forecasts=False)[source]

Estimate download size

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • num_sites ('int') – Number of sites to be downloaded
  • resource_type ('str') – type of resource wind -> (‘power’, ‘fcst’, ‘met’) solar -> (‘power’, ‘fcst’, ‘met’, ‘irradiance’)
  • forecasts ('bool') – Boolean flag as to whether forecasts will be included in the download or not
Returns:

download_size – Estimated download size in GB

Return type:

‘float’

download(src, dst)[source]

Abstract method to download src to dst

Parameters:
  • src ('str') – Path or URL to src file
  • dst ('str') – Path to which file should be downloaded
nearest_neighbors(node_collection)[source]

Find the nearest neighbor resource sites for all nodes in Node_collection

Parameters:node_collection ('NodeCollection') – Collection of nodes for which resource sites are to be identified
Returns:nearest_nodes – Dataframe with the nearest neighbor resource sites for each node
Return type:‘pandas.DataFrame’
download_resource(dataset, site_id, resource_type)[source]

Download the resource site file from repository

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • site_ids ('list') – List of site ids to be downloaded
  • resource_type ('str') – power or met or fcst
download_resource_data(dataset, site_ids, resource_type)[source]

Download resource files from repository

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • site_ids ('list') – List of site ids to be downloaded
  • resource_type ('str') – power or met
  • threads ('int') – Number of threads to use for downloading
get_node_resource(dataset, site_id, frac=None)[source]

Initialize and return Resource class object for specified resource site

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • site_id (int) – Resource site_id
  • frac ('float') – Fraction of resource to use from resource site
Returns:

Wind or Solar Resource class instance

Return type:

‘Resource’

get_resource(node_collection, forecasts=False)[source]

Finds nearest nodes, caches files to local datastore and assigns resource to node_collection

Parameters:
  • node_collection ('NodeCollection') – Collection of either weather of generator nodes
  • forecasts ('bool') – Whether to download forecasts along with power data
Returns:

  • node_collection (‘NodeCollection’) – Node collection with resources assigned to nodes
  • nearest_nodes (‘pandas.DataFrame’) – DataFrame of the nearest neighbor matching between nodes and resources

class R2PD.datastore.DRPower(local_cache=None, threads=None)[source]

Bases: R2PD.datastore.ExternalDataStore

Class object for External DataStore at DR Power (egrid.org)

Initialize ExternalDataStore object

Parameters:
  • local_cache ('InternalDataStore') – InternalDataStore object represening internal data cache
  • threads ('int') – Number of threads to use during downloads
DATA_ROOT = 'https://dtn2.pnl.gov/drpower'
download(src, dst)[source]

Download resource data from src URL to dst file path

Parameters:
  • src ('str') – URL of resource data to be downloaded
  • dst ('str') – Destination path of resource data (including file name)
download_resource(dataset, site_id, resource_type)[source]

Download the resource site file from repo and add site to cache meta

Parameters:
  • dataset ('str') – ‘wind’ or ‘solar’
  • site_ids ('list') – List of site ids to be downloaded
  • resource_type ('str') – power or met or fcst

R2PD.nearestnodes module

This module provides classes for facilitating the transfer of data between the external and internal store as well as processing the data using a queue.

R2PD.nearestnodes.nearest_power_nodes(node_collection, resource_meta)[source]

Fill requested power nodes in node_collection with resource sites in resource_meta

Parameters:
  • node_collection ('pandas.DataFrame'|'GeneratorNodeCollection') –
    DataFrame of requested nodes:
    [node_id(index), latitude, longitude, capacity]

    or NodeCollection instance

  • resource_meta ('pandas.DataFrame') –
    DataFrame with resource node meta-data:
    [site_id(index), latitude, longitude, capacity]
Returns:

nodes – Requested nodes with site_ids and fractions of resource for each node

Return type:

‘pandas.DataFrame’

R2PD.nearestnodes.nearest_met_nodes(node_collection, resource_meta)[source]

Fill requested weather nodes in node_collection with resource sites in resource_meta

Parameters:
  • node_collection ('pandas.DataFrame'|'WeatherNodeCollection') –
    DataFrame of requested nodes:
    [node_id(index), latitude, longitude]

    or NodeCollection instance

  • resource_meta ('pandas.DataFrame') –
    DataFrame with resource node meta-data:
    [site_id(index), latitude, longitude]
Returns:

nodes – Requested nodes with site_id of resource for each node

Return type:

‘pandas.DataFrame’

R2PD.powerdata module

This module transforms wind and solar PV resource data into forms usable by power system modelers. Functionalities needed include:

  • Select raw resource data (wind speeds, irradiance) or power outputs
  • Scale power timeseries to the desired capacity
  • Provide data for the temporal extents and resolutions desired, expressed in units of a user-chosen standard-time timezone
  • Blend multiple resource data timeseries into composite curves for distributed PV based on a default or user-supplied distribution of orientations
  • Reshape forecast data into forms usable by operation simulators
  • Sum multiple timeseries to represent the combined output over larger areas all tied into the same node
class R2PD.powerdata.Node(node_id, latitude, longitude)[source]

Bases: object

Abstract class for a single Node

Initialize generic Node object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
assign_resource(resource)[source]

Assign resource to Node

Parameters:resource ('Resource'|'ResourceList') – Resource or ResourceList instance with resource site(s) for node
class R2PD.powerdata.GeneratorNode(node_id, latitude, longitude, capacity)[source]

Bases: R2PD.powerdata.Node

Abstract class for GeneratorNode

Initialize generic GeneratorNode object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
  • capacity ('float') – Capacity of generator in MW
assign_resource(resource, forecasts=False)[source]

Assign resource to Node

Parameters:
  • resource ('Resource'|'ResourceList') – Resource or ResourceList instance with resource site(s) for node
  • forecasts ('bool') – Are forecasts included in generator resource
get_power(temporal_params, shaper=None)[source]

Extracts and processes power data for Node

Parameters:
  • temporal_params ('TemporalParameters') – Requiements for timeseries output
  • shaper ('TimeseriesShaper'|'function') – Method to convert Resource data into required output
get_forecasts(forecast_params, shaper=None)[source]

Extracts and processes forecast data for Node

Parameters:
  • forecast_params ('ForecastParameters') – Requiements for forecast output
  • shaper ('ForecastShaper'|'function') – Method to convert forecast data into required output
save_power(file_path, formatter=None)[source]

Save power data to disc

Parameters:
  • file_path ('str') – Output file path
  • formatter – Method to save powerdata to desired format
save_forecasts(file_path, formatter=None)[source]

Save forecast data to disc

Parameters:
  • file_path ('str') – Output file path
  • formatter – Method to save powerdata to desired format
class R2PD.powerdata.WindGeneratorNode(node_id, latitude, longitude, capacity)[source]

Bases: R2PD.powerdata.GeneratorNode

Class for Wind Generator Nodes

Initialize generic GeneratorNode object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
  • capacity ('float') – Capacity of generator in MW
class R2PD.powerdata.SolarGeneratorNode(node_id, latitude, longitude, capacity)[source]

Bases: R2PD.powerdata.GeneratorNode

Class for Solar Generator Nodes

Initialize generic GeneratorNode object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
  • capacity ('float') – Capacity of generator in MW
class R2PD.powerdata.WeatherNode(node_id, latitude, longitude)[source]

Bases: R2PD.powerdata.Node

Abstract Class for Weather Nodes

Initialize generic Node object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
get_weather(temporal_params, shaper=None)[source]

Extracts and processes weather data for Node

Parameters:
  • temporal_params ('TemporalParameters') – Requiements for timeseries output
  • shaper ('TimeseriesShaper'|'function') – Method to convert Resource data into required output
save_weather(file_path, formatter=None)[source]

Save weather data to disc

Parameters:
  • file_path ('str') – Output file path
  • formatter – Method to save powerdata to desired format
class R2PD.powerdata.WindMetNode(node_id, latitude, longitude)[source]

Bases: R2PD.powerdata.WeatherNode

Class for Wind Weather Nodes

Initialize generic Node object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
class R2PD.powerdata.SolarMetNode(node_id, latitude, longitude)[source]

Bases: R2PD.powerdata.WeatherNode

Class for Solar Weather Nodes

Initialize generic Node object

Parameters:
  • node_id ('str'|'int') – Node id, must be an integer
  • latitude ('float') – Latitude of node
  • longitude ('float') – Longitude of node
get_irradiance(temporal_params, shaper=None)[source]

Extracts and processes irradiance data for Node

Parameters:
  • temporal_params ('TemporalParameters') – Requiements for timeseries output
  • shaper ('TimeseriesShaper'|'function') – Method to convert Resource data into required output
save_irradiance(filename, formatter=None)[source]

Save weather data to disc

Parameters:
  • file_path ('str') – Output file path
  • formatter – Method to save powerdata to desired format
class R2PD.powerdata.NodeCollection(nodes)[source]

Bases: object

Abstract Class of list of nodes of the same type. This class is provided to interface w/ Pandas for processing timeseries data in bulk. (TODO)

Initialize generic NodeCollection object

Parameters:nodes ('list') – List of Node objects
assign_resource(resources, node_ids=None)[source]

Assign resource to nodes in NodeCollection

Parameters:
  • resources ('list') – List of Resource or ResourceList objects
  • node_ids ('list') – node ids that correspond to Resource in resources list
classmethod factory(nodes)[source]

Constructs the right type of NodeCollection based on the type of nodes.

Parameters:nodes ('list') – List of Node objects
Returns:Proper type of node collection based on type of Nodes
Return type:‘NodeCollection’
locations

DataFrame of (latitude, longitude) coordinates for nodes in NodeCollection

Returns:Latitude and longitude for each node in NodeCollection
Return type:‘pandas.DataFrame’
class R2PD.powerdata.GeneratorNodeCollection(nodes)[source]

Bases: R2PD.powerdata.NodeCollection

Collection of GeneratorNodes

Initialize GeneratorNodeCollection object Determines if the nodes are wind or solar nodes

Parameters:nodes ('list') – List of Node objects
assign_resource(resources, node_ids=None, forecasts=False)[source]

Assign resource to nodes in GeneratorNodeCollection

Parameters:
  • resources ('list') – List of Resource or ResourceList objects
  • node_ids ('list') – node ids that correspond to Resource in resources list
  • forecasts ('bool') – If forecasts are included in resources or not
node_data

Array of node data [id, latitude, longitude, capacity (MW)]

Returns:Meta data for all nodes in GeneratorNodeCollection [id, latitude, longitude, capacity (MW)]
Return type:‘nd.array’
get_power(temporal_params, shaper=None)[source]

Extracts and processes power data for all Nodes in GeneratorNodeCollection

Parameters:
  • temporal_params ('TemporalParameters') – Requiements for timeseries output
  • shaper ('TimeseriesShaper'|'function') – Method to convert Resource data into required output
get_forecasts(forecast_params, shaper=None)[source]

Extracts and processes forecast data for all nodes in GeneratorNodeCollection

Parameters:
  • forecast_params ('ForecastParameters') – Requiements for forecast output
  • shaper ('ForecastShaper'|'function') – Method to convert forecast data into required output
save_power(out_dir, file_prefix=None, formatter=None)[source]

Save power data to disc

Parameters:
  • out_dir ('str') – Path to root directory to save power data
  • file_prefix ('str') – Prefix for files to be save after appending node id and extension
  • formatter – Method to save powerdata to desired format
save_forecasts(out_dir, file_prefix=None, formatter=None)[source]

Save forecast data to disc

Parameters:
  • out_dir ('str') – Path to root directory to save power data
  • file_prefix ('str') – Prefix for files to be save after appending node id and extension
  • formatter – Method to save powerdata to desired format
class R2PD.powerdata.WeatherNodeCollection(nodes)[source]

Bases: R2PD.powerdata.NodeCollection

Collection of WeatherNodes

Initialize WeatherNodeCollection object Determines if the nodes are wind or solar nodes

Parameters:nodes ('list') – List of Node objects
node_data

Array of node data [id, latitude, longitude]

Returns:Meta data for all nodes in WeatherNodeCollection [id, latitude, longitude]
Return type:‘nd.array’
get_weather(temporal_params, shaper=None)[source]

Extracts and processes weather data for all nodes in WeatherNodeCollection

Parameters:
  • temporal_params ('TemporalParameters') – Requiements for timeseries output
  • shaper ('TimeseriesShaper'|'function') – Method to convert Resource data into required output
save_weather(out_dir, file_prefix=None, formatter=None)[source]

Save weather data to disc

Parameters:
  • out_dir ('str') – Path to root directory to save power data
  • file_prefix ('str') – Prefix for files to be save after appending node id and extension
  • formatter – Method to save powerdata to desired format

R2PD.resourcedata module

This module provides an API to the raw resource data and meta-data.

class R2PD.resourcedata.Resource(loc_meta, root_path, frac=None)[source]

Bases: object

Abstract Resource class containing resource site information

Initialize Resource instance

Parameters:
  • loc_meta ('pandas.Series') – meta data for resource location
  • root_path ('str') – path to internal repository
  • frac ('float') – fraction of site’s capacity to be used Is None for weather nodes
DATASET = None
site_id

resource site id

Returns:resource site id
Return type:‘int’
latitude

resource site latitude

Returns:resource site latitude
Return type:‘float’
longitude

resource site longitude

Returns:resource site longitude
Return type:‘float’
capacity

resource site capacity in MW

Returns:resource site capacity in MW
Return type:‘float’
extract_data(data_type)[source]

Abstract method to extract time series data from resource .hdf5 file

Parameters:data_type ('str') – type of data (‘met’, ‘power’, ‘fcst’)
Returns:data – Time series DataFrame of resource data
Return type:‘pandas.DataFrame’
power_data

Extract power data

Returns:power_data – Time series dataframe of power data
Return type:‘pandas.DataFrame’
meteorological_data

Extract weather (met) data

Returns:met_data – Time series DataFrame of weather (met)
Return type:‘pandas.DataFrame’
forecast_data

Extract forecast data

Returns:fcst_data – Time series DataFrame of forecast data
Return type:‘pandas.DataFrame’
forecast_probabilities

Extract forecast probabilities data

Returns:fcst_prob – Time series DataFrame of forecast probabilities
Return type:‘pandas.DataFrame’
class R2PD.resourcedata.WindResource(loc_meta, root_path, frac=None)[source]

Bases: R2PD.resourcedata.Resource

Class for wind Resource data

Initialize Resource instance

Parameters:
  • loc_meta ('pandas.Series') – meta data for resource location
  • root_path ('str') – path to internal repository
  • frac ('float') – fraction of site’s capacity to be used Is None for weather nodes
DATASET = 'wind'
class R2PD.resourcedata.SolarResource(loc_meta, root_path, frac=None)[source]

Bases: R2PD.resourcedata.Resource

Class for solar Resource data

Initialize Resource instance

Parameters:
  • loc_meta ('pandas.Series') – meta data for resource location
  • root_path ('str') – path to internal repository
  • frac ('float') – fraction of site’s capacity to be used Is None for weather nodes
DATASET = 'solar'
forecast_data

Extract forecast data

Returns:fcst_data – Time series DataFrame of forecast data
Return type:‘pandas.DataFrame’
forecast_probabilities

Extract forecast probabilities data

Returns:fcst_prob – Time series DataFrame of forecast probabilities
Return type:‘pandas.DataFrame’
class R2PD.resourcedata.ResourceList(resources)[source]

Bases: object

Handles the aggregation of power and forecast data

Initialize ResourceList instance :param resources: List of Resource objects :type resources: ‘list’

locations

DataFrame of (latitude, longitude) coordinates for nodes in NodeCollection

Returns:Latitude and longitude for each node in NodeCollection
Return type:‘pandas.DataFrame’
power_data

Extract and aggragate power data for all sites in ResourceList

Returns:power_data – Time series DataFrame of aggragated power data
Return type:‘pandas.DataFrame’
forecast_data

Extract and aggragate forecast data for all sites in ResourceList

Returns:fcst_data – Time series DataFrame of aggragated forecast data
Return type:‘pandas.DataFrame’
forecast_probabilities

Extract and aggragate forecast probabilities for all sites in ResourceList

Returns:fcst_prob – Time series DataFrame of aggragated forecast probabilities
Return type:‘pandas.DataFrame’

R2PD.tshelpers module

This module defines time conventions for basic timeseries and for forecasts, as well as abstract function calls for converting between them.

class R2PD.tshelpers.TemporalParameters(extent, point_interp='instantaneous', timezone='UTC', resolution=None)[source]

Bases: object

Class to specify temporal parameters

Initialize TemporalParameters

Parameters:
  • extent ('list'|'tuple') – Start and end datetime
  • point_interp ('POINT_INTERPRETATIONS') – element of POINT_INTERPRETATIONS representing data
  • timezone ('str') – timezone for timeseries
  • resolution ('str') – resolution for timeseries, if None use data’s native resolution
class POINT_INTERPRETATIONS

Bases: enum.Enum

An enumeration.

average_midpt = 4
average_next = 2
average_prev = 3
instantaneous = 1
integrated_midpt = 7
integrated_next = 5
integrated_prev = 6
classmethod infer_params(ts, timezone=None, **kwargs)[source]

Infer time-series temporal parameters

Parameters:
  • ts ('pandas.DataFrame') – Timeseries DataFrame
  • timezone ('str') – Timezone of time-series, if None, infer
  • **kwargs – kwargs for TemporalParameters
Returns:

ts_params

Return type:

‘TemporalParameters’

infer_resolution(ts)[source]

Infer time-series temporal resolution

Parameters:ts ('pandas.DataFrame') – Timeseries DataFrame
infer_timezone(ts)[source]

Infer time-series timezone

Parameters:ts ('pandas.DataFrame') – Timeseries DataFrame
class R2PD.tshelpers.TimeseriesShaper[source]

Bases: object

Abstract class defining the call signature for reshaping timeseries to conform to the desired temporal parameters.

class R2PD.tshelpers.ForecastParameters(forecast_type, temporal_params, **kwargs)[source]

Bases: object

Describes different shapes of forecast data.

Discrete leadtimes datasets are repeated timeseries where the different values given for the same timestamp are the value predicted for that time various amounts of time in advance. For example, the WindToolkit forecast data, for every hour lists the amount of output power predicted for that hour 1-hour ahead, 4-hours ahead, 6-hours ahead, and 24-hours ahead.

Dispatch lookahead datasets mimic actual power system operations. For example, every day a day-ahead unit commitment model is run using forecasts for the next 1 to 2 days, with the simulation typically kicked-off 6 to 12 hours ahead of the modeled time. These forecasts happen at a certain frequency, cover a certain amount of lookahead time, and are computed a certain amount of time ahead of the modeled time.

Initialize ForecastParameters

Parameters:
  • forecast_type ('FORECAST_TYPES') – Element of FORECAST_TYPES representing type of forecast
  • temporal_params ('TemporalParameters') – TemporalParameters instance describing timeseries parameters
  • **kwargs – kwargs specific to forecast type
class FORECAST_TYPES

Bases: enum.Enum

An enumeration.

discrete_leadtimes = 1
dispatch_lookahead = 2
classmethod infer_params(ts, **kwargs)[source]

Infer time-series temporal parameters and discrete lead time parameters

Parameters:
  • ts ('pandas.DataFrame') – Timeseries DataFrame
  • timezone ('str') – Timezone of time-series, if None, infer
  • **kwargs – kwargs for TemporalParameters
Returns:

ts_params

Return type:

‘TemporalParameters’

forecast_type

Type of forecast

Returns:element of FORECAST_TYPES
Return type:‘FORECAST_TYPES’
temporal_params

Temporal Parameters for forecast timeseries

Returns:Timeseries temporal parameters
Return type:‘TemporalParameters’
leadtimes

A list of the amounts of time ahead at which forecasts are available, e.g. [datetime.timedelta(hours=1), datetime.timedelta(hours=4), datetime.timedelta(hours=6), datetime.timedelta(hours=24)].

Returns:List of forecast leadtimes
Return type:‘list’
frequency

For ‘dispatch_lookahead’ data, the frequency at which forecasts are needed.

Returns:Frequency of lookahead forecasts
Return type:‘datetime.timedelta’
lookahead

For ‘dispatch_lookahead’ data, the amount of time covered by each forecast.

Returns:Amount of time covered by each forecast
Return type:‘datetime.timedelta’
leadtime

For ‘dispatch_lookahead’ data, the amount of time ahead of the start of the modeled time that the forecast data would need to be provided.

Returns:Amount of leadtime for lookahead forecast
Return type:‘datetime.timedelta’
dispatch_time

For ‘dispatch_lookahead’ data, the time of day that the forecast model is run.

Returns:Time of day forecast is run
Return type:‘datetime.time’
dispatch_leadtimes

Get all leadtimes needed to create dispatch_lookahead forecast

Returns:List of forecast leadtimes
Return type:‘list’
classmethod discrete_leadtime(temporal_params, leadtimes)[source]

Constructs ForecastParameters for leadtime forecasts

Parameters:
  • temporal_params ('TemporalParameters') – Timeseries temporal parameters for leadtime forecasts
  • leadtimes ('list') – List of forecast leadtimes
Returns:

Forecast parameters for leadtime forecasts

Return type:

‘ForecastParameters’

classmethod dispatch_lookahead(temporal_params, dispatch_time, frequency, lookahead, leadtime)[source]

Constructs ForecastParameters for lookahead forecasts

Parameters:
  • temporal_params ('TemporalParameters') – Timeseries temporal parameters for lookahead forecast
  • dispatch_time ('str') – Time of day forecast is dispatched
  • frequency ('datetime.timedelta') – frequency of lookahead forecasts
  • lookahead ('datetime.timedelta') – amount of lookahead for forecast
  • leadtime ('datetime.timedelta') – leadtime for lookahead forcast
Returns:

Forecast parameters for lookahead forecast

Return type:

‘ForecastParameters’

class R2PD.tshelpers.ForecastShaper[source]

Bases: object

Abstract class defining the call signature for reshaping timeseries to conform to the desired temporal parameters.

R2PD.tshelpers.get_enum_instance(value, enum_class)[source]

Extracts value from enum_class if needed

Parameters:
  • value ('str'|'enum_class') – Either enum_class value or string for value
  • enum_class ('Enum') – enum class object for which value belongs
Returns:

enum_class value

Return type:

‘enum_class’

Module contents