reV.rep_profiles.rep_profiles.RepProfiles

class RepProfiles(gen_fpath, rev_summary, reg_cols, cf_dset='cf_profile', rep_method='meanoid', err_method='rmse', weight='gid_counts', n_profiles=1, aggregate_profiles=False)[source]

Bases: RepProfilesBase

reV rep profiles class.

reV rep profiles compute representative generation profiles for each supply curve point output by reV supply curve aggregation. Representative profiles can either be a spatial aggregation of generation profiles or actual generation profiles that most closely resemble an aggregated profile (selected based on an error metric).

Parameters:
  • gen_fpath (str) – Filepath to reV generation output HDF5 file to extract cf_dset dataset from.

    Note

    If executing reV from the command line, this path can contain brackets {} that will be filled in by the analysis_years input. Alternatively, this input can be set to "PIPELINE", which will parse this input from one of these preceding pipeline steps: multi-year, collect, generation, or supply-curve-aggregation. However, note that duplicate executions of any of these commands within the pipeline may invalidate this parsing, meaning the gen_fpath input will have to be specified manually.

  • rev_summary (str | pd.DataFrame) – Aggregated reV supply curve summary file. Must include the following columns:

    • res_gids : string representation of python list containing the resource GID values corresponding to each supply curve point.

    • gen_gids : string representation of python list containing the reV generation GID values corresponding to each supply curve point.

    • weight column (name based on weight input) : string representation of python list containing the resource GID weights for each supply curve point.

    Note

    If executing reV from the command line, this input can be set to "PIPELINE", which will parse this input from one of these preceding pipeline steps: supply-curve-aggregation or supply-curve. However, note that duplicate executions of any of these commands within the pipeline may invalidate this parsing, meaning the rev_summary input will have to be specified manually.

  • reg_cols (str | list) – Label(s) for a categorical region column(s) to extract profiles for. For example, "state" will extract a rep profile for each unique entry in the "state" column in rev_summary. To get a profile for each supply curve point, try setting reg_cols to a primary key such as "sc_gid".

  • cf_dset (str, optional) – Dataset name to pull generation profiles from. This dataset must be present in the gen_fpath HDF5 file. By default, "cf_profile"

    Note

    If executing reV from the command line, this name can contain brackets {} that will be filled in by the analysis_years input (e.g. "cf_profile-{}").

  • rep_method ({‘mean’, ‘meanoid’, ‘median’, ‘medianoid’}, optional) – Method identifier for calculation of the representative profile. By default, 'meanoid'

  • err_method ({‘mbe’, ‘mae’, ‘rmse’}, optional) – Method identifier for calculation of error from the representative profile. If this input is None, the representative meanoid / medianoid profile will be returned directly. By default, 'rmse'.

  • weight (str, optional) – Column in rev_summary used to apply weights when computing mean profiles. The supply curve table data in the weight column should have weight values corresponding to the res_gids in the same row (i.e. string representation of python list containing weight values).

    Important

    You’ll often want to set this value to something other than None (typically "gid_counts" if running on standard reV outputs). Otherwise, the unique generation profiles within each supply curve point are weighted equally. For example, if you have a 64x64 supply curve point, and one generation profile takes up 4095 (99.98%) 90m cells while a second generation profile takes up only one 90m cell (0.02%), they will contribute equally to the meanoid profile unless these weights are specified.

    By default, 'gid_counts'.

  • n_profiles (int, optional) – Number of representative profiles to save to the output file. By default, 1.

  • aggregate_profiles (bool, optional) – Flag to calculate the aggregate (weighted meanoid) profile for each supply curve point. This behavior is in lieu of finding the single profile per region closest to the meanoid. If you set this flag to True, the rep_method, err_method, and n_profiles inputs will be forcibly set to the default values. By default, False.

Methods

run([fout, save_rev_summary, ...])

Run representative profiles in serial or parallel and save to disc

save_profiles(fout[, save_rev_summary, ...])

Initialize fout and save profiles.

Attributes

meta

Meta data for the representative profiles.

profiles

Get the arrays of representative CF profiles corresponding to meta.

time_index

Get the time index for the rep profiles.

run(fout=None, save_rev_summary=True, scaled_precision=False, max_workers=None)[source]

Run representative profiles in serial or parallel and save to disc

Parameters:
  • fout (str, optional) – Filepath to output HDF5 file. If None, output data are not written to a file. By default, None.

  • save_rev_summary (bool, optional) – Flag to save full reV supply curve table to rep profile output. By default, True.

  • scaled_precision (bool, optional) – Flag to scale cf_profiles by 1000 and save as uint16. By default, False.

  • max_workers (int, optional) – Number of parallel rep profile workers. 1 will run serial, while None will use all available. By default, None.

property meta

Meta data for the representative profiles.

Returns:

meta (pd.DataFrame) – Meta data for the representative profiles. At the very least, this has columns for the region and res class.

property profiles

Get the arrays of representative CF profiles corresponding to meta.

Returns:

profiles (dict) – dict of n_profile-keyed arrays with shape (time, n) for the representative profiles for each region.

save_profiles(fout, save_rev_summary=True, scaled_precision=False)

Initialize fout and save profiles.

Parameters:
  • fout (str) – None or filepath to output h5 file.

  • save_rev_summary (bool) – Flag to save full reV SC table to rep profile output.

  • scaled_precision (bool) – Flag to scale cf_profiles by 1000 and save as uint16.

property time_index

Get the time index for the rep profiles.

Returns:

time_index (pd.datetimeindex) – Time index sourced from the reV gen file.