iv module
iv.extractor module
Derive the effective diode parameters from a set of input curves.
- class pvops.iv.extractor.BruteForceExtractor(input_df, current_col, voltage_col, irradiance_col, temperature_col, T_type, windspeed_col=None, Simulator_mod_specs=None, Simulator_pristine_condition=None)[source]
Bases:
object
Process measured IV curves to extract diode parameters. Requires a set of curves to create Isc vs Irr and Voc vs Temp vs Isc(Irr)
- Parameters:
input_df (DataFrame) – Contains IV curves with a datetime index
current_col (string) – Indicates column where current values in IV curve are located; each cell is an array of current values in a single IV curve
voltage_col (string) – Indicates column where voltage values in IV curve are located; each cell is an array of voltage values in a single IV curve
irradiance_col (string) – Indicates column where irradiance value (W/m2)
temperature_col (string) – Indicates column where temperature value (C)
T_type (string) – Describe input temperature, either ‘ambient’ or ‘module’ or ‘cell’
- fit_params(cell_parameters, n_mods, bounds_func, user_func=None, verbose=0)[source]
Fit diode parameters from a set of IV curves.
- Parameters:
cell_parameters (dict) – Cell-level parameters, usually extracted from the CEC database, which will be used as the initial guesses in the optimization process.
n_mods (int) – if int, defines the number of modules in a string(1=simulate a single module)
bounds_func (function) – Function to establish the bounded search space See below for an example:
def bounds_func(iph,io,rs,rsh,nnsvth,perc_adjust=0.5): return ((iph - 0.5*iph*perc_adjust, iph + 2*iph*perc_adjust), (io - 40*io*perc_adjust, io + 40*io*perc_adjust), (rs - 20*rs*perc_adjust, rs + 20*rs*perc_adjust), (rsh - 150*rsh*perc_adjust, rsh + 150*rsh*perc_adjust), (nnsvth - 10*nnsvth*perc_adjust, nnsvth + 10*nnsvth*perc_adjust))
user_func (function) – Optional, a function similar to self.create_string_object which has the following inputs: self, iph, io, rs, rsh, nnsvth. This can be used to extract unique failure parameterization.
verbose (int) – if verbose >= 1, print information about fitting if verbose >= 2, plot information about each iteration
iv.physics_utils module
- pvops.iv.physics_utils.T_to_tcell(POA, T, WS, T_type, a=-3.56, b=-0.075, delTcnd=3)[source]
Ambient temperature to cell temperature according to NREL weather-correction. See Dierauf et al. [DGK+13].
- Parameters:
Tamb (numerical,) – Ambient temperature, in Celcius
WS (numerical,) – Wind speed at height of 10 meters, in m/s
a, b, delTcnd (numerical,) – Page 12 in [DGK+13]
T_type (string,) – Describe input temperature, either ‘ambient’ or ‘module’
- Returns:
numerical – Cell temperature, in Celcius
- pvops.iv.physics_utils.add_series(voltage_1, current_1, voltage_2=None, current_2=None, v_bypass=None)[source]
Adds two IV curves in series.
- Parameters:
voltage_1 (numeric) – Voltage for first IV curve [V]
current_1 (numeric) – Current for first IV curve [A]
voltage_2 (numeric or None, default None) – Voltage for second IV curve [V]
current_1 (numeric or None, default None) – Voltage for second IV curve [A]
v_bypass (float or None, default None) – Forward (positive) turn-on voltage of bypass diode, e.g., 0.5V [V]
- Returns:
voltage (numeric) – Voltage for combined IV curve [V]
current (numeric) – Current for combined IV curve [V]
Note
Current for the combined IV curve is the sorted union of the current of the two input IV curves. At current values in the other IV curve, voltage is determined by linear interpolation. Voltage at current values outside an IV curve’s range is determined by linear extrapolation.
If voltage_2 and current_2 are None, returns (voltage_1, current_1) to facilitate starting a loop over IV curves.
- pvops.iv.physics_utils.bypass(voltage, v_bypass)[source]
Limits voltage to greater than -v_bypass.
- Parameters:
voltage (numeric) – Voltage for IV curve [V]
v_bypass (float or None, default None) – Forward (positive) turn-on voltage of bypass diode, e.g., 0.5V [V]
- Returns:
voltage (numeric) – Voltage clipped to greater than -v-bpass
- pvops.iv.physics_utils.calculate_IVparams(v, c)[source]
Calculate parameters of IV curve.
This needs to be reworked: extrapolate parameters from linear region instead of hardcoded regions.
- Parameters:
x (numpy array) – X-axis data
y (numpy array) – Y-axis data
npts (int) – Optional, number of points to resample curve
deg (int) – Optional, polyfit degree
- Returns:
Dictionary of IV curve parameters
- pvops.iv.physics_utils.gt_correction(v, i, gact, tact, cecparams, n_units=1, option=3)[source]
IV Trace Correction using irradiance and temperature. Three correction options are provided, two of which are from an IEC standard.
- Parameters:
v (numpy array) – Voltage array
i (numpy array) – Current array
gact (float) – Irradiance upon measurement of IV trace
tact (float) – Temperature (C or K) upon measuremnt of IV trace
cecparams (dict) – CEC database parameters, as extracted by pvops.iv.utils.get_CEC_params.
n_units (int) – Number of units (cells or modules) in string, default 1
option (int) – Correction method choice. See method for specifics.
- Returns:
vref – Corrected voltage array
iref – Corrected current array
- pvops.iv.physics_utils.intersection(x1, y1, x2, y2)[source]
Compute intersection of curves, y1=f(x1) and y2=f(x2). Adapted from https://stackoverflow.com/a/5462917
- Parameters:
x1 (numpy array) – X-axis data for curve 1
y1 (numpy array) – Y-axis data for curve 1
x2 (numpy array) – X-axis data for curve 2
y2 (numpy array) – Y-axis data for curve 2
- Returns:
intersection coordinates
- pvops.iv.physics_utils.iv_cutoff(Varr, Iarr, val)[source]
Cut IV curve greater than voltage val (usually 0)
- Parameters:
V (numpy array) – Voltage array
I (numpy array) – Current array
val (numeric) – Filter threshold
- Returns:
V_cutoff, I_cutoff
- pvops.iv.physics_utils.smooth_curve(x, y, npts=50, deg=12)[source]
Smooth curve using a polyfit
- Parameters:
x (numpy array) – X-axis data
y (numpy array) – Y-axis data
npts (int) – Optional, number of points to resample curve
deg (int) – Optional, polyfit degree
- Returns:
smoothed x array
smoothed y array
- pvops.iv.physics_utils.voltage_pts(npts, v_oc, v_rbd)[source]
Provide voltage points for an IV curve.
Points range from v_brd to v_oc, with denser spacing at both limits. v=0 is included as the midpoint.
Based on method PVConstants.npts from pvmismatch
- Parameters:
npts (integer) – Number of points in voltage array.
v_oc (float) – Open circuit voltage [V]
v_rbd (float) – Reverse bias diode voltage (negative value expected) [V]
- Returns:
array [V]
iv.preprocess module
- pvops.iv.preprocess.preprocess(input_df, resmpl_resolution, iv_col_dict, resmpl_cutoff=0.03, correct_gt=False, normalize_y=True, CECmodule_parameters=None, n_mods=None, gt_correct_option=3)[source]
IV processing function which supports irradiance & temperature correction
- Parameters:
input_df (DataFrame)
resmpl_resolution (float)
iv_col_dict (dict)
resmpl_cutoff (float)
correct_gt (bool)
normalize_y (bool)
CECmodule_parameters (None)
n_mods (int)
gt_correct_option (int)
- Returns:
df (DataFrame)
iv.simulator module
- class pvops.iv.simulator.Simulator(mod_specs={'Jinko_Solar_Co___Ltd_JKM270PP_60': {'ncols': 6, 'nsubstrings': 3}}, pristine_condition={'E': 1000, 'Il_mult': 1, 'Io_mult': 1, 'Rs_mult': 1, 'Rsh_mult': 1, 'Tc': 50, 'identifier': 'pristine', 'nnsvth_mult': 1}, replacement_5params={'I_L_ref': None, 'I_o_ref': None, 'R_s': None, 'R_sh_ref': None, 'a_ref': None}, num_points_in_IV=200, simulation_method=2)[source]
Bases:
object
An object which simulates Photovoltaic (PV) current-voltage (IV) curves with failures
- Parameters:
mod_specs (dict) – Define the module and some definitions of that module which are not included in the the CEC database. The key in this dictionary is the name of the module in the CEC database. The values are ncols, which is the number of columns in the module, and nsubstrings, which is the number of substrings.
pristine_condition (dict) – Defines the pristine condition. A full condition is defined as a dictionary with the following key/value pairs:
{ 'identifier': IDENTIFIER_NAME, # (str) Name used to define condition 'E': IRRADIANCE, # (numeric) Value of irradiance (Watts per meter-squared) 'Tc': CELL_TEMPERATURE, # (numeric) Multiplier usually less than 1 # to simulate a drop in Rsh 'Rsh_mult': RSH_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in RSH 'Rs_mult': RS_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate an increase in RS 'Io_mult': IO_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in IO 'Il_mult': IL_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in IL 'nnsvth_mult': NNSVTH_MULTIPLIER, # (numeric) Multiplier usually less # than 1 to simulate a drop in NNSVTH, and therefore a_ref 'modname': MODULE_NAME_IN_CECDB # (str) Module name in CEC database # (e.g. Jinko_Solar_Co___Ltd_JKMS260P_60) }
replacement_5params (dict) – Optional, replace the definitions of the five electrical parameters, which normally are extracted from the CEC database. These parameters can be determined by the
IVProcessor
classKey/value pairs:
{ 'I_L_ref': None, 'I_o_ref': None, 'R_s': None, 'R_sh_ref': None, 'a_ref': None }
simulation_method (int) – Module simulation method (1 or 2)
Avalanche breakdown model, as hypothesized in Ref. [1]
: Add-on to method 1, includes a rebalancing of the $I_sc$ prior to adding in series
- Variables:
multilevel_ivdata (dict) –
Dictionary containing the simulated IV curves
For nth-definition of string curves,
multilevel_ivdata['string']['STRING IDENTIFIER'][n]
For nth-definition of module curves,
multilevel_ivdata['module']['MODULE IDENTIFIER'][n]
For nth-definition of substring (substr_id = 1,2,3,…) curves,
multilevel_ivdata['module']['MODULE IDENTIFIER']['substr{sbstr_id}'][n]
pristine_condition (dict) – Dictionary of conditions defining the pristine case
module_parameters (dict) – Dictionary of module-level parameters
cell_parameters (dict) – Dictionary of cell-level parameters
- add_manual_conditions(modcell, condition_dict)[source]
Create cell-level fault conditions manually
- Parameters:
modcell (dict) – Key: name of the condition Value: list,
1D list: Give a single situation for this condition
2D list: Give multiple situations for this condition
A list where each value signifies a cell’s condition.
If key is same as an existing key, the list is appended to list of scenarios which that key owns
condition_dict (dict) – Define the numerical value written in modcell
Note
If the variable is not defined, values will default to those specified in the pristine condition, defined in __init__.
A full condition is defined as:
{ID: {'identifier': IDENTIFIER_NAME, # (str) Name used to define condition 'E': IRRADIANCE, # (numeric) Value of irradiance (Watts per meter-squared) 'Tc': CELL_TEMPERATURE, # (numeric) Value of cell temperature (Celcius) 'Rsh_mult': RSH_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in Rsh 'Rs_mult': RS_MULTIPLIER, # (numeric) Multiplier usually greater than 1 # to simulate increase in Rs 'Io_mult': IO_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in IO 'Il_mult': IL_MULTIPLIER, # (numeric) Multiplier usually less than 1 # to simulate a drop in IL 'nnsvth_mult': NNSVTH_MULTIPLIER # (numeric) Multiplier usually less than 1 to # simulate a drop in NNSVTH, and therefore a_ref } }
- add_preset_conditions(fault_name, fault_condition, save_name=None, **kwargs)[source]
Create cell-level fault conditions from presets defined by authors
- Parameters:
fault_name (str) – Options:
‘complete’: entire module has fault_condition (e.g. Full module shading) Requires no other specifications e.g. add_preset_conditions(‘complete’, fault_condition)
‘landscape’: entire rows are affected by fault_condition (e.g. interrow shading) Requires specification of rows_aff e.g. add_preset_conditions(‘landscape’, fault_condition, rows_aff = 2)
‘portrait’: entire columns are affected by fault_condition (e.g. vegetation growth shading) Requires specification of cols_aff
e.g. add_preset_conditions(‘portrait’, fault_condition, cols_aff = 2)
‘pole’: Place pole shadow over module Requires specification of width (integer), which designates the width of main shadow and requires light_shading fault_condition specification which specifies less intense shading on edges of shadow
Optional: pos = (left, right) designates the start and end of the pole shading, where left is number in the first column and right is number in last column if pos not specified, the positions are chosen randomly e.g. add_preset_conditions(‘pole’, fault_condition, light_shading = light_fault_condition, width = 2, pos = (5, 56))
‘bird_droppings’: Random positions are chosen for bird_dropping simulations
Optional specification is n_droppings. If not specified, chosen as random number between 1 and the number of cells in a column e.g. add_preset_conditions(‘bird_droppings’, fault_condition, n_droppings = 3)
fault_location (dict) – Same dict as one shown in __init__.
kwargs (variables dependent on which fault_name you choose, see above)
Tip
For a wider spectrum of cases, run all of these multiple times. Each time it’s run, the case is saved
- build_strings(config_dict)[source]
Pass a dictionary into object memory
e.g. For 6 modules faulted with modcell specification ‘complete’
config_dict = { 'faulting_bottom_mods': [ 'pristine', 'pristine', 'pristine', 'pristine', 'pristine', 'pristine', 'complete', 'complete', 'complete', 'complete', 'complete', 'complete' ] }
- generate_many_samples(identifier, N, distributions=None, default_sample=None)[source]
For cell identifier, create N more samples by randomly sampling a gaussian or truncated gaussian distribution.
- Parameters:
identifier (str) – Cell identifier to upsample
N (int) – Number of samples to generate
distributions (dict) – Dictionary of distribution definitions, either gaussian or truncated gaussian. Each definition must note a ‘mean’ and ‘std’, however if ‘low’ and ‘upp’ thresholds are also included, then a truncated gaussian distribution will be generated.
One does not need to define distributions for all parameters, only those that you want altered.
distributions = { 'Rsh_mult':{'mean':None, 'std': None, 'low': None, 'upp': None}, 'Rs_mult': {'mean':None, 'std': None, 'low': None, 'upp': None}, ... # All keys in self.acceptible_keys }
default_sample – If provided, use this sample to replace the parameters which do not have distributions specified. Else, uses the pristine condition as a reference.
- sims_to_df(focus=['string', 'module'], cutoff=False)[source]
Return the failure definitions as a dataframe.
- Parameters:
focus (list of string) – Subset the definitions to a level of the system Currently available: ‘substring’, ‘module’, ‘string’
cutoff (bool) – Cutoff curves to only return on positive voltage domain
- Returns:
Dataframe with columns –
‘current’: IV trace current
’voltage’: IV trace voltage
’E’: Average irradiance for all samples used to build this array
’T’: Average cell temperature for all samples used to build this array
’mode’: failure name
’level’: level of system (i.e. module, string), as defined by the input focus parameter
#TODO (create focus for cell. For now, one can do it manually themselves.)
- simulate(sample_limit=None)[source]
Simulate the cell, substring, module, and string-level IV curves using the defined conditions
- Parameters:
sample_limit (int) – Optional, used when want to restrict number of combinations of failures at the string level.
- simulate_module(mod_key)[source]
Wrapper method which simulates a module depending on the defined simulation_method.
- Parameters:
mod_key (str) – Module name as defined in condiction_dict and modcells
- visualize(lim=False)[source]
Run visualization suite to visualize information about the simulated curves.
- visualize_cell_level_traces(cell_identifier, cutoff=True, table=True, axs=None)[source]
Visualize IV curves for cell_identifier and tabulate the definitions.
- Parameters:
cell_identifier (str) – Cell identifier. Call self.print_info() for full list.
cutoff (bool) – If True, only visualize IV curves in positive voltage domain
table (bool) – If True, append table to bottom of figure
axs (maplotlib axes) – Matplotli subplots axes
- Returns:
matplotlib axes
- visualize_module_configurations(module_identifier, title=None, n_plots_atonce=3)[source]
Visualize failure locations on a module.
- Parameters:
module_identifier (int) – Module identifier. Call self.print_info() for full list.
title (str) – Optional, add this title to figure.
n_plots_atonce (int) – Number of plots to render in a single figure.
- Returns:
matplotlib axes
TODO (MAKE COLOR either 1) same as condition color from other tables) – 2) colored by intensity of param definition, given a param (e.g. ‘E’)
- visualize_multiple_cells_traces(list_cell_identifiers, cutoff=True)[source]
Visualize multiple cell traces
- Parameters:
list_cell_identifiers (list) – list of cell identifiers. call self.print_info() for full list.
cutoff (bool) – If True, only visualize IV curves in positive voltage domain
- Returns:
matplotlib axes
- visualize_specific_iv(ax=None, string_identifier=None, module_identifier=None, substring_identifier=None, cutoff=True, correct_gt=False)[source]
Visualize a string, module, or substring IV curve. If the object has multiple definitions, all definitions will be plotted
- Parameters:
ax (matplotlib axes) – Optional, pass an axes to add visualization
string_identifier (str) – Optional, Identification of string definition
module_identifier (str) – Optional, Identification of module definition
substring_identifier (str) – Optional, Identification of module definition
cutoff (bool) – If True, only visualize IV curves in positive voltage domain
correct_gt (bool) – If True, correct curves according to irradiance and temperature Here, cutoff must also be True.
- Returns:
matplotlib axes
iv.utils module
- pvops.iv.utils.get_CEC_params(name, mod_spec)[source]
Query module-level parameters from CEC database and derive cell-level parameters.
Utilizing methods from pvsystem.retrieve_sam(‘CECMod’)
- Parameters:
name (string) – Representing module name in CEC database
mod_specs (dict) – Provide ‘ncols’ and ‘nsubstrings’
- Returns:
module_parameters (dict), cell_parameters (dict)
iv.timeseries_simulator module
- class pvops.iv.timeseries_simulator.IVTimeseriesGenerator(**iv_sim_kwargs)[source]
Bases:
Simulator
- class pvops.iv.timeseries_simulator.TimeseriesFailure[source]
Bases:
object
- trend(longterm_fcn_dict=None, annual_fcn_dict=None, daily_fcn_dict=None, **kwargs)[source]
Define a failure’s trend across intraday (trending with time of day) and longterm timeframes.
- Parameters:
longterm_fcn_dict (dict) – A dictionary where keys are the diode-multipliers in IVSimulator (‘Rsh_mult’, ‘Rs_mult’, ‘Io_mult’, ‘Il_mult’, ‘nnsvth_mult’) and values are either a function or a string. If a function, the function should be a mathematical operation as a function of the number of float years since operation start, a value on domain [0,inf), and outputs the chosen diode-multiplier’s values across this timeseries. If a string, must use a pre-defined definition:
‘degrade’ : degrade over time at specified rate. Specify rate by passing a definition for degradation_rate
For example,
# 2 Ways of Doing Same Thing # Method 1 longterm_fcn_dict = { 'Rs_mult': lambda x : 1.005 * x } f = Failure() f.trend(longterm_fcn_dict) # Method 2 longterm_fcn_dict = { 'Rs_mult': 'degrade' } f = Failure() f.trend(longterm_fcn_dict, degradation_rate=1.005)
annual_fcn_dict (dict) – A dictionary where keys are the diode-multipliers in IVSimulator (‘Rsh_mult’, ‘Rs_mult’, ‘Io_mult’, ‘Il_mult’, ‘nnsvth_mult’) and values are either a function or a string. If a function, the function should be a mathematical operation as a function of the percentage through this year, a value on domain [0,1], and outputs the chosen diode-multiplier’s values across this timeseries. If a string, must use a pre-defined definition:
daily_fcn_dict (function or str) – A dictionary where keys are the diode-multipliers in IVSimulator (‘Rsh_mult’, ‘Rs_mult’, ‘Io_mult’, ‘Il_mult’, ‘nnsvth_mult’) and values are either a function or a string. If a function, the function should be a mathematical operation as a function of the percentage through this day, a value on domain [0,1], and outputs the chosen diode-multiplier’s values across this timeseries. If a string, must use a pre-defined definition:
iv.models.nn module
- class pvops.iv.models.nn.IVClassifier(nn_config)[source]
Bases:
object
- predict(batch_size=8)[source]
Predict using the trained model.
- Parameters:
batch_size (int) – Number of samples per gradient update
- structure(train, test)[source]
Structure the data according to the chosen network model’s input structure.
- Parameters:
train (dataframe) – Train data containing IV data and associated features
test (dataframe) – Test data containing IV data and associated features
nn_config (dict) – Parameters used for the IV trace classifier.
- pvops.iv.models.nn.balance_df(df, iv_col_dict, balance_tactic='truncate')[source]
Balance data so that an equal number of samples are found at each unique ycol definition.
- Parameters:
bigdf (dataframe) – Dataframe containing the ycol column.
iv_col_dict (dict) – Dictionary containing at least the following definition: - mode (str), column in df which holds the definitions which must contain a balanced number of samples for each unique definition.
balance_tactic (str) – mode balancing tactic, either “truncate” or “gravitate”. Truncate will utilize the exact same number of samples for each category. Gravitate will sway the original number of samples towards a central target.
- Returns:
balanced_df (DataFrame) – balanced according to the balance_tactic.
- pvops.iv.models.nn.classify_curves(df, iv_col_dict, nn_config)[source]
Build and evaluate an IV trace failure mode classifier.
- Parameters:
df (dataframe) – Data with columns in iv_col_dict
iv_col_dict (dict) – Dictionary containing definitions for the column names in df mode (str): column name for failure mode identifier
nn_config (dict) – Parameters used for the IV trace classifier.
- pvops.iv.models.nn.feature_generation(bigdf, iv_col_dict, pristine_mode_identifier='Pristine array')[source]
Generate features of an IV curve data set including: 1. Current differential between a sample IV curve and a pristine IV curve 2. Finite difference of the IV curve along the y-axis, indicating the slope of the cuve.
- Parameters:
bigdf (dataframe) – Dataframe holding columns from iv_col_dict, except for the derivative and current_diff which are calculated here.
iv_col_dict (dict) – Dictionary containing definitions for the column names in df
current (str): column name for IV current arrays.
voltage (str): column name for IV voltage arrays.
mode (str): column name for failure mode identifier.
irradiance (str): column name for the irradiance definition.
temperature (str): column name for the temperature definition.
derivative (str): column name for the finite derivative, as calculated in this function.
current_diff (str): column name for current differential, as calculated in get_diff_array.
pristine_mode_identifier (str) – Pristine array identifier. The pristine curve is utilized in
get_diff_array
. If multiple rows exist at thispristine_mode_identifier
, the one with the highest irradiance and lowest temperature definitions is chosen.
- Returns:
all_V (array) – Combined voltage array
diff (array) – Current differential calculation
- pvops.iv.models.nn.get_diff_array(sample_V, sample_I, pristine_V, pristine_I, debug=False)[source]
Generate IV current differential between sample and pristine.
- Parameters:
sample_V (array) – Voltage array for a sample’s IV curve
sample_I (array) – Current array for a sample’s IV curve
pristine_V (array) – Voltage array for a pristine IV curve
pristine_I (array) – Current array for a pristine IV curve
- Returns:
all_V (array) – Combined voltage array
diff (array) – Current differential calculation
- pvops.iv.models.nn.plot_profiles(df, colx, coly, iv_col_dict, cmap_name='brg')[source]
Plot curves also with area colorizations to display the deviation in definitions.
- Parameters:
df (dataframe) – Dataframe containing the colx, coly, and iv_col_dict[‘mode’] column
colx (str) – Column containing x-axis array of data on each sample.
coly (str) – Column containing y-axis array of data on each sample.
iv_col_dict (dict) – Dictionary containing at least the following definition: - mode (str), column in df which holds the definitions which must contain a balanced number of samples for each unique definition.
cmap_name (str) – Matplotlib colormap.
- Returns:
matplotlib figure