reV.econ.econ.Econ

class Econ(project_points, sam_files, cf_file, site_data=None, output_request=('lcoe_fcr',), sites_per_worker=100, memory_utilization_limit=0.4, append=False)[source]

Bases: BaseGen

ReV econ analysis class.

reV econ analysis runs SAM econ calculations, typically to compute LCOE (using PySAM.Lcoefcr.Lcoefcr), though PySAM.Singleowner.Singleowner or PySAM.Windbos.Windbos calculations can also be performed simply by requesting outputs from those computation modules. See the keys of Econ.OPTIONS for all available econ outputs. Econ computations rely on an input a generation (i.e. capacity factor) profile. You can request reV to run the analysis for one or more “sites”, which correspond to the meta indices in the generation data.

Parameters:
  • project_points (int | list | tuple | str | dict | pd.DataFrame | slice) – Input specifying which sites to process. A single integer representing the GID of a site may be specified to evaluate reV at a single location. A list or tuple of integers (or slice) representing the GIDs of multiple sites can be specified to evaluate reV at multiple specific locations. A string pointing to a project points CSV file may also be specified. Typically, the CSV contains the following columns:

    • gid: Integer specifying the generation GID of each site.

    • config: Key in the sam_files input dictionary (see below) corresponding to the SAM configuration to use for each particular site. This value can also be None (or left out completely) if you specify only a single SAM configuration file as the sam_files input.

    • capital_cost_multiplier: This is an optional multiplier input that, if included, will be used to regionally scale the capital_cost input in the SAM config. If you include this column in your CSV, you do not need to specify capital_cost, unless you would like that value to vary regionally and independently of the multiplier (i.e. the multiplier will still be applied on top of the capital_cost input).

    The CSV file may also contain other site-specific inputs by including a column named after a config keyword (e.g. a column called wind_turbine_rotor_diameter may be included to specify a site-specific turbine diameter for each location). Columns that do not correspond to a config key may also be included, but they will be ignored. A DataFrame following the same guidelines as the CSV input (or a dictionary that can be used to initialize such a DataFrame) may be used for this input as well.

  • sam_files (dict | str) – A dictionary mapping SAM input configuration ID(s) to SAM configuration(s). Keys are the SAM config ID(s) which correspond to the config column in the project points CSV. Values for each key are either a path to a corresponding SAM config file or a full dictionary of SAM config inputs. For example:

    sam_files = {
        "default": "/path/to/default/sam.json",
        "onshore": "/path/to/onshore/sam_config.yaml",
        "offshore": {
            "sam_key_1": "sam_value_1",
            "sam_key_2": "sam_value_2",
            ...
        },
        ...
    }
    

    This input can also be a string pointing to a single SAM config file. In this case, the config column of the CSV points input should be set to None or left out completely. See the documentation for the reV SAM class (e.g. reV.SAM.generation.WindPower, reV.SAM.generation.PvWattsv8, reV.SAM.generation.Geothermal, etc.) for documentation on the allowed and/or required SAM config file inputs.

  • cf_file (str) – Path to reV output generation file containing a capacity factor output.

    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" to parse the output of the previous step (reV generation) and use it as input to this call. However, note that duplicate executions of reV generation within the pipeline may invalidate this parsing, meaning the cf_file input will have to be specified manually.

  • site_data (str | pd.DataFrame, optional) – Site-specific input data for SAM calculation. If this input is a string, it should be a path that points to a CSV file. Otherwise, this input should be a DataFrame with pre-extracted site data. Rows in this table should match the input sites via a gid column. The rest of the columns should match configuration input keys that will take site-specific values. Note that some or all site-specific inputs can be specified via the project_points input table instead. If None, no site-specific data is considered. By default, None.

  • output_request (list | tuple, optional) – List of output variables requested from SAM. Can be any of the parameters in the “Outputs” group of the PySAM module (e.g. PySAM.Windpower.Windpower.Outputs, PySAM.Pvwattsv8.Pvwattsv8.Outputs, PySAM.Geothermal.Geothermal.Outputs, etc.) being executed. This list can also include a select number of SAM config/resource parameters to include in the output: any key in any of the output attribute JSON files may be requested. Time-series profiles requested via this input are output in UTC. By default, ('lcoe_fcr',).

  • sites_per_worker (int, optional) – Number of sites to run in series on a worker. None defaults to the resource file chunk size. By default, None.

  • memory_utilization_limit (float, optional) – Memory utilization limit (fractional). Must be a value between 0 and 1. This input sets how many site results will be stored in-memory at any given time before flushing to disk. By default, 0.4.

  • append (bool) – Option to append econ datasets to source cf_file. By default, False.

Methods

add_site_data_to_pp(site_data)

Add the site df (site-specific inputs) to project points dataframe.

flush()

Flush the output data in self.out attribute to disk in .h5 format.

get_pc(points, points_range, sam_configs, ...)

Get a PointsControl instance.

get_sites_per_worker(res_file[, default])

Get the nominal sites per worker (x-chunk size) for a given file.

handle_leap_ti(ti[, drop_leap])

Handle a time index for a leap year by dropping a day.

run([out_fpath, max_workers, timeout, pool_size])

Execute a parallel reV econ run with smart data flushing.

site_index(site_gid[, out_index])

Get the index corresponding to the site gid.

unpack_futures(futures)

Combine list of futures results into their native dict format/type.

unpack_output(site_gid, site_output)

Unpack a SAM SiteOutput object to the output attribute.

Attributes

ECON_ATTRS

LCOE_ARGS

OPTIONS

Available reV econ output_request options

OUT_ATTRS

cf_file

Get the capacity factor output filename and path.

meta

Get meta data from the source capacity factors file.

out

Get the reV gen or econ output results.

out_chunk

Get the current output chunk index range (INCLUSIVE).

output_request

Get the output variables requested from the user.

points_control

Get project points controller.

project_points

Get project points

run_attrs

Run time attributes (__init__ args and kwargs)

sam_configs

Get the sam config dictionary.

sam_metas

SAM configurations including runtime module

sam_module

Get the SAM module class to be used for SAM simulations.

site_data

Get the site-specific inputs in dataframe format.

site_limit

Get the number of sites results that can be stored in memory at once

site_mem

Get the memory (MB) required to store all results for a single site.

tech

Get the reV technology string.

time_index

Get the generation resource time index data.

year

Get the resource year.

OPTIONS = {'bos_cost': <class 'reV.SAM.windbos.WindBos'>, 'capital_cost': <class 'reV.SAM.econ.LCOE'>, 'fixed_charge_rate': <class 'reV.SAM.econ.LCOE'>, 'fixed_operating_cost': <class 'reV.SAM.econ.LCOE'>, 'flip_actual_irr': <class 'reV.SAM.econ.SingleOwner'>, 'gross_revenue': <class 'reV.SAM.econ.SingleOwner'>, 'lcoe_fcr': <class 'reV.SAM.econ.LCOE'>, 'lcoe_nom': <class 'reV.SAM.econ.SingleOwner'>, 'lcoe_real': <class 'reV.SAM.econ.SingleOwner'>, 'ppa_price': <class 'reV.SAM.econ.SingleOwner'>, 'project_return_aftertax_npv': <class 'reV.SAM.econ.SingleOwner'>, 'sales_tax_cost': <class 'reV.SAM.windbos.WindBos'>, 'total_installed_cost': <class 'reV.SAM.windbos.WindBos'>, 'turbine_cost': <class 'reV.SAM.windbos.WindBos'>, 'variable_operating_cost': <class 'reV.SAM.econ.LCOE'>}

Available reV econ output_request options

property cf_file

Get the capacity factor output filename and path.

Returns:

cf_file (str) – reV generation capacity factor output file with path.

property meta

Get meta data from the source capacity factors file.

Returns:

_meta (pd.DataFrame) – Meta data from capacity factor outputs file.

property time_index

Get the generation resource time index data.

classmethod get_pc(points, points_range, sam_configs, cf_file, sites_per_worker=None, append=False)[source]

Get a PointsControl instance.

Parameters:
  • points (slice | list | str | reV.config.project_points.PointsControl) – Slice specifying project points, or string pointing to a project points csv, or a fully instantiated PointsControl object.

  • points_range (list | None) – Optional two-entry list specifying the index range of the sites to analyze. To be taken from the reV.config.PointsControl.split_range property.

  • 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.

  • cf_file (str) – reV generation capacity factor output file with path.

  • sites_per_worker (int) – Number of sites to run in series on a worker. None defaults to the resource file chunk size.

  • append (bool) – Flag to append econ datasets to source cf_file. This has priority over the out_fpath input.

Returns:

pc (reV.config.project_points.PointsControl) – PointsControl object instance.

add_site_data_to_pp(site_data)

Add the site df (site-specific inputs) to project points dataframe.

This ensures that only the relevant site’s data will be passed through to parallel workers when points_control is iterated and split.

Parameters:

site_data (pd.DataFrame) – Site-specific data for econ calculation. Rows correspond to sites, columns are variables.

flush()

Flush the output data in self.out attribute to disk in .h5 format.

The data to be flushed is accessed from the instance attribute “self.out”. The disk target is based on the instance attributes “self._out_fpath”. Data is not flushed if _fpath is None or if .out is empty.

static get_sites_per_worker(res_file, default=100)

Get the nominal sites per worker (x-chunk size) for a given file.

This is based on the concept that it is most efficient for one core to perform one read on one chunk of resource data, such that chunks will not have to be read into memory twice and no sites will be read redundantly.

Parameters:
  • res_file (str) – Filepath to single resource file, multi-h5 directory, or /h5_dir/prefix*suffix

  • default (int) – Sites to be analyzed on a single core if the chunk size cannot be determined from res_file.

Returns:

sites_per_worker (int) – Nominal sites to be analyzed per worker. This is set to the x-axis chunk size for windspeed and dni datasets for the WTK and NSRDB data, respectively.

static handle_leap_ti(ti, drop_leap=False)

Handle a time index for a leap year by dropping a day.

Parameters:
  • ti (pandas.DatetimeIndex) – Time-series datetime index with or without leap days.

  • drop_leap (bool) – Option to drop leap days (if True) or drop the last day of each leap year (if False).

Returns:

ti (pandas.DatetimeIndex) – Time-series datetime index with length a multiple of 365.

property out

Get the reV gen or econ output results.

Returns:

out (dict) – Dictionary of gen or econ results from SAM.

property out_chunk

Get the current output chunk index range (INCLUSIVE).

Returns:

_out_chunk (tuple) – Two entry tuple (start, end) indicies (inclusive) for where the current data in-memory belongs in the final output.

property output_request

Get the output variables requested from the user.

Returns:

output_request (list) – Output variables requested from SAM.

property points_control

Get project points controller.

Returns:

points_control (reV.config.project_points.PointsControl) – Project points control instance for site and SAM config spec.

property project_points

Get project points

Returns:

project_points (reV.config.project_points.ProjectPoints) – Project points from the points control instance.

run(out_fpath=None, max_workers=1, timeout=1800, pool_size=None)[source]

Execute a parallel reV econ run with smart data flushing.

Parameters:
  • out_fpath (str, optional) – Path to output file. If this class was initialized with append=True, this input has no effect. If None, no output file will be written. If the filepath is specified but the module name (econ) and/or resource data year is not included, the module name and/or resource data year will get added to the output file name. By default, None.

  • max_workers (int, optional) – Number of local workers to run on. By default, 1.

  • timeout (int, optional) – Number of seconds to wait for parallel run iteration to complete before returning zeros. By default, 1800 seconds.

  • pool_size (int, optional) – Number of futures to submit to a single process pool for parallel futures. If None, the pool size is set to os.cpu_count() * 2. By default, None.

Returns:

str | None – Path to output HDF5 file, or None if results were not written to disk.

property run_attrs

Run time attributes (__init__ args and kwargs)

Returns:

run_attrs (dict) – Dictionary of runtime args and kwargs

property sam_configs

Get the sam config dictionary.

Returns:

sam_configs (dict) – SAM config from the project points instance.

property sam_metas

SAM configurations including runtime module

Returns:

sam_metas (dict) – Nested dictionary of SAM configuration files with module used at runtime

property sam_module

Get the SAM module class to be used for SAM simulations.

Returns:

sam_module (object) – SAM object like PySAM.Pvwattsv7 or PySAM.Lcoefcr

property site_data

Get the site-specific inputs in dataframe format.

Returns:

_site_data (pd.DataFrame) – Site-specific input data for gen or econ calculation. Rows match sites, columns are variables.

site_index(site_gid, out_index=False)

Get the index corresponding to the site gid.

Parameters:
  • site_gid (int) – Resource-native site index (gid).

  • out_index (bool) – Option to get output index (if true) which is the column index in the current in-memory output array, or (if false) the global site index from the project points site list.

Returns:

index (int) – Global site index if out_index=False, otherwise column index in the current in-memory output array.

property site_limit

Get the number of sites results that can be stored in memory at once

Returns:

_site_limit (int) – Number of site result sets that can be stored in memory at once without violating memory limits.

property site_mem

Get the memory (MB) required to store all results for a single site.

Returns:

_site_mem (float) – Memory (MB) required to store all results in requested in output_request for a single site.

property tech

Get the reV technology string.

Returns:

tech (str) – SAM technology to analyze (pvwattsv7, windpower, tcsmoltensalt, solarwaterheat, troughphysicalheat, lineardirectsteam, econ) The string should be lower-cased with spaces and _ removed.

static unpack_futures(futures)

Combine list of futures results into their native dict format/type.

Parameters:

futures (list) – List of dictionary futures results.

Returns:

out (dict) – Compiled results of the native future results type (dict).

unpack_output(site_gid, site_output)

Unpack a SAM SiteOutput object to the output attribute.

Parameters:
  • site_gid (int) – Resource-native site gid (index).

  • site_output (dict) – SAM site output object.

property year

Get the resource year.

Returns:

_year (int) – Year of the time-series datetime index.