reV.SAM.generation.LinearDirectSteam
- class LinearDirectSteam(resource, meta, sam_sys_inputs, site_sys_inputs=None, output_request=None, drop_leap=False)[source]
Bases:
AbstractSamGenerationFromWeatherFile
Process heat linear Fresnel direct steam generation
Initialize a SAM generation object.
- Parameters:
resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)
meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.
sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.
site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.
output_request (list) – Requested SAM outputs (e.g., ‘cf_mean’, ‘annual_energy’, ‘cf_profile’, ‘gen_profile’, ‘energy_yield’, ‘ppa_price’, ‘lcoe_fcr’).
drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.
Methods
add_scheduled_losses
([resource])Add stochastically scheduled losses to SAM config file.
Get annual energy generation value in kWh from SAM.
Assign the self.sam_sys_inputs attribute to the PySAM object.
cf_mean
()Calculate mean capacity factor (fractional) from SAM.
Get hourly capacity factor (frac) profile in local timezone.
check_resource_data
(resource)Check resource dataframe for NaN values
collect_outputs
([output_lookup])Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.
default
()Get the executed default pysam linear Fresnel object.
drop_leap
(resource)Drop Feb 29th from resource df with time index.
Get annual energy yield value in kwh/kw from SAM.
ensure_res_len
(arr, time_index)Ensure time_index has a constant time-step and only covers 365 days (no leap days).
execute
()Call the PySAM execute method.
Get power generation profile (local timezone) in kW.
get_sam_res
(*args, **kwargs)Get the SAM resource iterator object (single year, single file).
get_time_interval
(time_index)Get the time interval.
make_datetime
(series)Ensure that pd series is a datetime series with dt accessor
Convert array-like SAM outputs to UTC np.ndarrays
reV_run
(points_control, res_file, site_df[, ...])Execute SAM generation based on a reV points control instance.
run
()Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.
Run SAM generation and possibility follow-on econ analysis.
set_resource_data
(resource, meta)Generate the weather file and set the path as an input.
tz_elev_check
(sam_sys_inputs, ...)Check timezone+elevation input and use json config timezone+elevation if not in resource meta.
Attributes
DIR
IGNORE_ATTRS
MODULE
Specify outage information in the config file using this key.
Specify a randomizer seed in the config file using this key.
PYSAM_WEATHER_TAG
WF_META_DROP_COLS
Get the heirarchical PySAM object attribute dictionary.
Returns true if instance has a timezone set
Get the list of lowest level input attribute/variable names.
Get meta data property.
Get module property.
A value to use as the seed for the outage losses.
Get the pysam object.
Get the site number for this SAM simulation.
- PYSAM = <module 'PySAM.LinearFresnelDsgIph' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/PySAM/LinearFresnelDsgIph.cpython-38-x86_64-linux-gnu.so'>
- cf_mean()[source]
Calculate mean capacity factor (fractional) from SAM.
- Returns:
output (float) – Mean capacity factor (fractional).
- static default()[source]
Get the executed default pysam linear Fresnel object.
- Returns:
PySAM.LinearFresnelDsgIph
- OUTAGE_CONFIG_KEY = 'reV_outages'
Specify outage information in the config file using this key.
- OUTAGE_SEED_CONFIG_KEY = 'reV_outages_seed'
Specify a randomizer seed in the config file using this key.
- add_scheduled_losses(resource=None)
Add stochastically scheduled losses to SAM config file.
This function reads the information in the
reV_outages
key of thesam_sys_inputs
dictionary and computes stochastically scheduled losses from that input. If the value forreV_outages
is a string, it must have been generated by callingjson.dumps()
on the list of dictionaries containing outage specifications. Otherwise, the outage information is expected to be a list of dictionaries containing outage specifications. SeeOutage
for a description of the specifications allowed for each outage. The scheduled losses are passed to SAM via thehourly
key to signify which hourly capacity factors should be adjusted with outage losses. If no outage info is specified insam_sys_inputs
, no scheduled losses are added.- Parameters:
resource (pd.DataFrame, optional) – Time series resource data for a single location with a pandas DatetimeIndex. The
year
value of the index will be used to seed the stochastically scheduled losses. If None, no yearly seed will be used.
See also
Outage
Single outage specification.
Notes
The scheduled losses are passed to SAM via the
hourly
key to signify which hourly capacity factors should be adjusted with outage losses. If the user specifies other hourly adjustment factors via thehourly
key, the effect is combined. For example, if the user inputs a 33% hourly adjustment factor and reV schedules an outage for 70% of the farm down for the same hour, then the resulting adjustment factor isThis means the generation will be reduced by ~80%, because the user requested 33% losses for the 30% the farm that remained operational during the scheduled outage (i.e. 20% remaining of the original generation).
- annual_energy()
Get annual energy generation value in kWh from SAM.
- Returns:
output (float) – Annual energy generation (kWh).
- assign_inputs()
Assign the self.sam_sys_inputs attribute to the PySAM object.
- property attr_dict
Get the heirarchical PySAM object attribute dictionary.
- Returns:
_attr_dict (dict) –
- Dictionary with:
keys: variable groups values: lowest level attribute/variable names
- cf_profile()
Get hourly capacity factor (frac) profile in local timezone. See self.outputs attribute for collected output data in UTC.
- Returns:
cf_profile (np.ndarray) – 1D numpy array of capacity factor profile. Datatype is float32 and array length is 8760*time_interval.
- check_resource_data(resource)
Check resource dataframe for NaN values
- Parameters:
resource (pd.DataFrame) – Timeseries solar or wind resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed)
- collect_outputs(output_lookup=None)
Collect SAM output_request, convert timeseries outputs to UTC, and save outputs to self.outputs property.
- Parameters:
output_lookup (dict | None) – Lookup dictionary mapping output keys to special output methods. None defaults to generation default outputs.
- static drop_leap(resource)
Drop Feb 29th from resource df with time index.
- Parameters:
resource (pd.DataFrame) – Resource dataframe with an index containing a pandas time index object with month and day attributes.
- Returns:
resource (pd.DataFrame) – Resource dataframe with all February 29th timesteps removed.
- energy_yield()
Get annual energy yield value in kwh/kw from SAM.
- Returns:
output (float) – Annual energy yield (kwh/kw).
- static ensure_res_len(arr, time_index)
Ensure time_index has a constant time-step and only covers 365 days (no leap days). If not remove last day
- Parameters:
arr (ndarray) – Array to truncate if time_index has a leap day
time_index (pandas.DatatimeIndex) – Time index associated with arr, used to check time-series frequency and number of days
- Returns:
arr (ndarray) – Truncated array of data such that there are 365 days
- execute()
Call the PySAM execute method. Raise SAMExecutionError if error. Include the site index if available.
- gen_profile()
Get power generation profile (local timezone) in kW. See self.outputs attribute for collected output data in UTC.
- Returns:
output (np.ndarray) – 1D array of hourly power generation in kW. Datatype is float32 and array length is 8760*time_interval.
- static get_sam_res(*args, **kwargs)
Get the SAM resource iterator object (single year, single file).
- classmethod get_time_interval(time_index)
Get the time interval.
- Parameters:
time_index (pd.series) – Datetime series. Must have a dt attribute to access datetime properties (added using make_datetime method).
- Returns:
time_interval (int:) – This value is the number of indices over which an hour is counted. So if the timestep is 0.5 hours, time_interval is 2.
- property has_timezone
Returns true if instance has a timezone set
- property input_list
Get the list of lowest level input attribute/variable names.
- Returns:
_inputs (list) – List of lowest level input attributes.
- static make_datetime(series)
Ensure that pd series is a datetime series with dt accessor
- property meta
Get meta data property.
- property module
Get module property.
- outputs_to_utc_arr()
Convert array-like SAM outputs to UTC np.ndarrays
- property pysam
Get the pysam object.
- classmethod reV_run(points_control, res_file, site_df, lr_res_file=None, output_request=('cf_mean',), drop_leap=False, gid_map=None, nn_map=None, bias_correct=None)
Execute SAM generation based on a reV points control instance.
- Parameters:
points_control (config.PointsControl) – PointsControl instance containing project points site and SAM config info.
res_file (str) – Resource file with full path.
site_df (pd.DataFrame) – Dataframe of site-specific input variables. Row index corresponds to site number/gid (via df.loc not df.iloc), column labels are the variable keys that will be passed forward as SAM parameters.
lr_res_file (str | None) – Optional low resolution resource file that will be dynamically mapped+interpolated to the nominal-resolution res_file. This needs to be of the same format as resource_file, e.g. they both need to be handled by the same rex Resource handler such as WindResource
output_request (list | tuple) – Outputs to retrieve from SAM.
drop_leap (bool) – Drops February 29th from the resource data. If False, December 31st is dropped from leap years.
gid_map (None | dict) – Mapping of unique integer generation gids (keys) to single integer resource gids (values). This enables the user to input unique generation gids in the project points that map to non-unique resource gids. This can be None or a pre-extracted dict.
nn_map (np.ndarray) – Optional 1D array of nearest neighbor mappings associated with the res_file to lr_res_file spatial mapping. For details on this argument, see the rex.MultiResolutionResource docstring.
bias_correct (None | pd.DataFrame) – Optional DataFrame or CSV filepath to a wind or solar resource bias correction table. This has columns:
gid
: GID of site (can be index name of dataframe)method
: function name fromrex.bias_correction
module
The
gid
field should match the true resourcegid
regardless of the optionalgid_map
input. Onlywindspeed
orGHI
+DNI
+DHI
are corrected, depending on the technology (wind for the former, PV or CSP for the latter). See the functions in therex.bias_correction
module for available inputs formethod
. Any additional kwargs required for the requestedmethod
can be input as additional columns in thebias_correct
table e.g., for linear bias correction functions you can includescalar
andadder
inputs as columns in thebias_correct
table on a site-by-site basis. IfNone
, no corrections are applied. By default,None
.
- Returns:
out (dict) – Nested dictionaries where the top level key is the site index, the second level key is the variable name, second level value is the output variable value.
- run()
Run a reV-SAM generation object by assigning inputs, executing the SAM simulation, collecting outputs, and converting all arrays to UTC.
- run_gen_and_econ()
Run SAM generation and possibility follow-on econ analysis.
- set_resource_data(resource, meta)
Generate the weather file and set the path as an input.
Some PySAM models require a data file, not raw data. This method generates the weather data, writes it to a file on disk, and then sets the file as an input to the generation module. The function
run_gen_and_econ()
deletes the file on disk after a run is complete.- Parameters:
resource (pd.DataFrame) – Time series resource data for a single location with a pandas DatetimeIndex. There must be columns for all the required variables to run the respective SAM simulation. Remapping will be done to convert typical NSRDB/WTK names into SAM names (e.g. DNI -> dn and wind_speed -> windspeed).
meta (pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.
- property site
Get the site number for this SAM simulation.
- static tz_elev_check(sam_sys_inputs, site_sys_inputs, meta)
Check timezone+elevation input and use json config timezone+elevation if not in resource meta.
- Parameters:
sam_sys_inputs (dict) – Site-agnostic SAM system model inputs arguments.
site_sys_inputs (dict) – Optional set of site-specific SAM system inputs to complement the site-agnostic inputs.
meta (pd.DataFrame | pd.Series) – Meta data corresponding to the resource input for the single location. Should include values for latitude, longitude, elevation, and timezone.
- Returns:
meta (pd.DataFrame | pd.Series) – Dataframe or series for a single site. Will include “timezone” and “elevation” from the sam and site system inputs if found.