rex.joint_pd.joint_pd.JointPD

class JointPD(res_h5, res_cls=<class 'rex.resource.Resource'>, hsds=False)[source]

Bases: object

Compute the joint probability distribution between the desired variables

Parameters
  • res_h5 (str) – Path to resource h5 file(s)

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

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS, by default False

Methods

compute(dset1, dset2, bins1, bins2[, sites, ...])

Compute joint probability distribution between given datasets using given bins for all sites.

compute_joint_pd(res_h5, dset1, dset2, ...)

Compute the joint probability distribution between the two given datasets using the given bins for given sites

plot_joint_pd(jpd[, site])

Plot the mean joint probability distribution accross all sites (site=None), or the distribution for the single given site

run(res_h5, dset1, dset2, bins1, bins2[, ...])

Compute joint probability distribution between given datasets using given bins

save(jpd, out_fpath)

Save joint probability distribution to disk

wind_rose(wind_h5, hub_height[, wspd_bins, ...])

Compute wind rose at given hub height

Attributes

res_cls

Resource class to use to access wind_h5

res_h5

Path to resource h5 file(s)

property res_h5

Path to resource h5 file(s)

Returns

str

property res_cls

Resource class to use to access wind_h5

Returns

Class

classmethod compute_joint_pd(res_h5, dset1, dset2, bins1, bins2, res_cls=<class 'rex.resource.Resource'>, hsds=False, sites_slice=None)[source]

Compute the joint probability distribution between the two given datasets using the given bins for given sites

Parameters
  • res_h5 (str) – Path to resource h5 file(s)

  • dset1 (str) – Dataset 1 to generate joint probability distribution for

  • dset2 (str) – Dataset 2 to generate joint probabilty distribution for

  • bins1 (tuple) – (start, stop, step) for dataset 1 bins

  • bins2 (tuple) – (start, stop, step) for dataset 2 bins

  • sites (list | slice, optional)

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

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS, by default False

  • sites_slice (slice | None, optional) – Sites to extract, if None all, by default None

Returns

jpd (dict) – Dictionary of joint probabilty distribution densities for given sites

compute(dset1, dset2, bins1, bins2, sites=None, max_workers=None, chunks_per_worker=5)[source]

Compute joint probability distribution between given datasets using given bins for all sites.

Parameters
  • dset1 (str) – Dataset 1 to generate joint probability distribution for

  • dset2 (str) – Dataset 2 to generate joint probabilty distribution for

  • bins1 (tuple) – (start, stop, step) for dataset 1 bins

  • bins2 (tuple) – (start, stop, step) for dataset 2 bins

  • sites (list | slice, optional) – Subset of sites to extract, by default None or all sites

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

  • chunks_per_worker (int, optional) – Number of chunks to extract on each worker, by default 5

Returns

jpd (pandas.DataFrame) – DataFrame of joint probability distribution between given datasets with given bins

save(jpd, out_fpath)[source]

Save joint probability distribution to disk

Parameters
  • jpd (pandas.DataFrame) – Table of joint probability distribution densities to save

  • out_fpath (str) – .csv, or .h5 file path to save joint probability distribution to

static plot_joint_pd(jpd, site=None, **kwargs)[source]

Plot the mean joint probability distribution accross all sites (site=None), or the distribution for the single given site

Parameters
  • jpd (pandas.DataFrame) – DataFrame of joint probability distribution between given datasets with given bins

  • site (int, optional) – Site to plot distribution for, if None plot mean distribution across all sites, by default None

classmethod run(res_h5, dset1, dset2, bins1, bins2, sites=None, res_cls=<class 'rex.resource.Resource'>, hsds=False, max_workers=None, chunks_per_worker=5, out_fpath=None)[source]

Compute joint probability distribution between given datasets using given bins

Parameters
  • res_h5 (str) – Path to resource h5 file(s)

  • dset1 (str) – Dataset 1 to generate joint probability distribution for

  • dset2 (str) – Dataset 2 to generate joint probabilty distribution for

  • bins1 (tuple) – (start, stop, step) for dataset 1 bins

  • bins2 (tuple) – (start, stop, step) for dataset 2 bins

  • sites (list | slice, optional) – Subset of sites to extract, by default None or all sites

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

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS, by default False

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

  • chunks_per_worker (int, optional) – Number of chunks to extract on each worker, by default 5

  • out_fpath (str, optional) – .csv, or .h5 file path to save joint probability distribution to

Returns

out (pandas.DataFrame) – DataFrame of joint probability distribution between given datasets with given bins

classmethod wind_rose(wind_h5, hub_height, wspd_bins=(0, 30, 1), wdir_bins=(0, 360, 5), sites=None, res_cls=<class 'rex.renewable_resource.WindResource'>, hsds=False, max_workers=None, chunks_per_worker=5, out_fpath=None)[source]

Compute wind rose at given hub height

Parameters
  • wind_h5 (str) – Path to resource h5 file(s)

  • hub_height (str | int) – Hub-height to compute wind rose at

  • wspd_bins (tuple) – (start, stop, step) for wind speed bins

  • wdir_bins (tuple) – (start, stop, step) for wind direction bins

  • sites (list | slice, optional) – Subset of sites to extract, by default None or all sites

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

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS, by default False

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

  • chunks_per_worker (int, optional) – Number of chunks to extract on each worker, by default 5

  • out_fpath (str, optional) – .csv, or .h5 file path to save wind rose to

Returns

wind_rose (pandas.DataFrame) – DataFrame of wind rose frequencies at desired hub-height