reVX.hybrid_stats.hybrid_stats.HybridCrossCorrelation

class HybridCrossCorrelation(solar_h5, wind_h5, res_cls=<class 'rex.resource.Resource'>, year=None)[source]

Bases: HybridStats

Compute the temporal cross correlations for co-located wind and solar generation

Parameters:
  • solar_h5 (str) – Path to solar h5 file(s)

  • wind_h5 (str) – Path to wind h5 file(s)

  • res_cls (Class, optional) – Resource class to use to access res_h5, by default Resource

  • year (str | int, optional) – Year to extract time-index for if running on a multi-year file, by default None

Methods

cf_profile(solar_h5, wind_h5[, lag_range, ...])

Compute cross correlations on cf_profile dataset

compute_stats(dataset[, lag_range, ...])

Compute correlations

cross_correlation(solar_data, wind_data, m)

Compute the cross-correlation between solar and wind time-series data with time-lag m

run(solar_h5, wind_h5, dataset[, lag_range, ...])

Compute cross correlations between solar and wind time-series

save_stats(out_stats, out_fpath)

Save correlations to disk

Attributes

STATS

lat_lon

Resource (lat, lon) coordinates

meta

Resource meta-data table

res_cls

Resource class to use to access res_h5

solar_h5

Path to solar h5 file(s)

statistics

Dictionary of statistic functions/kwargs to run

time_index

Resource Datetimes

wind_h5

Path to wind h5 file(s)

static cross_correlation(solar_data, wind_data, m)[source]

Compute the cross-correlation between solar and wind time-series data with time-lag m

Parameters:
  • solar_data (ndarray) – Time-series solar data

  • wind_data (ndarray) – Time-series wind data

  • m (int) – Integer shift between solar and wind time-series, is pass directly to np.roll, so it will be the number of time-steps that are shifted. The lag time will be m * dt where dt is the time-step size.

Returns:

corr (ndarray) – Cross-correlation coefficient for each solar, wind site pair

compute_stats(dataset, lag_range=(-50, 51, 1), max_workers=None, sites_per_worker=1000, lat_lon_only=True)[source]

Compute correlations

Parameters:
  • dataset (tuple | str) – Dataset to compare, if a string, extract the same dataset for both with and solar, other wise a tuple of the form: (solar_dataset, wind_dataset)

  • lag_range (tuple, optional) – The range of lag (m) values to compute the cross-correlation for (start, stop, step). Cross-correlation will be run for all lags in range(start, stop, step), each value in the range is the number of timesteps by which the time-series will be shifted to compute the cross-correlation. by default (-50, 51, 1)

  • max_workers (None | int, optional) – Number of workers to use, if 1 run in serial, if None use all available cores, by default None

  • sites_per_worker (int, optional) – Number of sites to extract on each worker, by default 1000

  • lat_lon_only (bool, optional) – Only append lat, lon coordinates to stats, by default True

Returns:

res_stats (pandas.DataFrame) – DataFrame of desired statistics at desired time intervals

classmethod run(solar_h5, wind_h5, dataset, lag_range=(-50, 51, 1), res_cls=<class 'rex.resource.Resource'>, year=None, max_workers=None, sites_per_worker=1000, lat_lon_only=True, out_path=None)[source]

Compute cross correlations between solar and wind time-series

Parameters:
  • solar_h5 (str) – Path to solar h5 file(s)

  • wind_h5 (str) – Path to wind h5 file(s)

  • dataset (tuple | str) – Dataset to compare, if a string, extract the same dataset for both with and solar, other wise a tuple of the form: (solar_dataset, wind_dataset)

  • year (str | int, optional) – Year to extract time-index for if running on a multi-year file, by default None

  • lag_range (tuple, optional) – The range of lag (m) values to compute the cross-correlation for (start, stop, step). Cross-correlation will be run for all lags in range(start, stop, step), each value in the range is the number of timesteps by which the time-series will be shifted to compute the cross-correlation. by default (-50, 51, 1)

  • res_cls (Class, optional) – Resource class to use to access res_h5, by default Resource

  • max_workers (None | int, optional) – Number of workers to use, if 1 run in serial, if None use all available cores, by default None

  • sites_per_worker (int, optional) – Number of sites to extract on each worker, by default 1000

  • lat_lon_only (bool, optional) – Only append lat, lon coordinates to stats, by default True

  • out_path (str, optional) – .csv, or .json path to save statistics too, by default None

Returns:

out_stats (pandas.DataFrame) – DataFrame of resource statistics

classmethod cf_profile(solar_h5, wind_h5, lag_range=(-50, 51, 1), res_cls=<class 'rex.resource.Resource'>, max_workers=None, sites_per_worker=1000, lat_lon_only=True, out_path=None)[source]

Compute cross correlations on cf_profile dataset

Parameters:
  • solar_h5 (str) – Path to solar h5 file(s)

  • wind_h5 (str) – Path to wind h5 file(s)

  • dataset (str) – Dataset to extract stats for

  • lag_range (tuple, optional) – The range of lag (m) values to compute the cross-correlation for (start, stop, step). Cross-correlation will be run for all lags in range(start, stop, step), each value in the range is the number of timesteps by which the time-series will be shifted to compute the cross-correlation. by default (-50, 51, 1)

  • res_cls (Class, optional) – Resource class to use to access res_h5, by default Resource

  • max_workers (None | int, optional) – Number of workers to use, if 1 run in serial, if None use all available cores, by default None

  • sites_per_worker (int, optional) – Number of sites to extract on each worker, by default 1000

  • lat_lon_only (bool, optional) – Only append lat, lon coordinates to stats, by default True

  • out_path (str, optional) – .csv, or .json path to save statistics too, by default None

Returns:

out_stats (pandas.DataFrame) – DataFrame of resource statistics

property lat_lon

Resource (lat, lon) coordinates

Returns:

pandas.DataFrame

property meta

Resource meta-data table

Returns:

pandas.DataFrame

property res_cls

Resource class to use to access res_h5

Returns:

Class

static save_stats(out_stats, out_fpath)

Save correlations to disk

Parameters:
  • out_stats (pandas.DataFrame) – Table of correlations to save

  • out_path (str) – .csv, or .json path to save statistics too

property solar_h5

Path to solar h5 file(s)

Returns:

str

property statistics

Dictionary of statistic functions/kwargs to run

Returns:

dict

property time_index

Resource Datetimes

Returns:

pandas.DatetimeIndex

property wind_h5

Path to wind h5 file(s)

Returns:

str