### Install pvfactors from source for contributing Source: https://sunpower.github.io/pvfactors/installation/index.html Install pvfactors from the root folder of the cloned repository using pip. ```bash $ pip install . ``` -------------------------------- ### Install pvfactors in editable mode Source: https://sunpower.github.io/pvfactors/installation/index.html Install pvfactors in editable mode for development. ```bash $ pip install -e . ``` -------------------------------- ### Install pvfactors with pip Source: https://sunpower.github.io/pvfactors/installation/index.html Install pvfactors using pip. Requires Python 3.6 or higher. ```bash $ pip install pvfactors ``` -------------------------------- ### Get timeseries inputs Source: https://sunpower.github.io/pvfactors/tutorials/Getting_started.html Creates a pandas DataFrame containing the solar and surface parameters required for the simulation. ```python df_inputs = pd.DataFrame( {'solar_zenith': [20., 50.], 'solar_azimuth': [110., 250.], 'surface_tilt': [10., 20.], 'surface_azimuth': [90., 270.], 'dni': [1000., 900.], 'dhi': [50., 100.], 'albedo': [0.2, 0.2]}, index=[datetime(2017, 8, 31, 11), datetime(2017, 8, 31, 15)] ) df_inputs ``` -------------------------------- ### Fit PV array to scalar values Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/geometry/pvarray.html Example of fitting a PV array using scalar parameters converted to numpy arrays. ```python solar_zenith = np.array([pvarray_params['solar_zenith']]) solar_azimuth = np.array([pvarray_params['solar_azimuth']]) surface_tilt = np.array([pvarray_params['surface_tilt']]) surface_azimuth = np.array([pvarray_params['surface_azimuth']]) pvarray.fit(solar_zenith, solar_azimuth, surface_tilt, surface_azimuth) return pvarray ``` -------------------------------- ### Install shapely from conda-forge Source: https://sunpower.github.io/pvfactors/installation/index.html If pip installation of shapely fails with OSError: [WinError 126] The specified module could not be found, install shapely from conda-forge. ```bash $ conda install -c conda-forge shapely ``` -------------------------------- ### Import libraries and set up paths Source: https://sunpower.github.io/pvfactors/tutorials/Account_for_AOI_losses.html Sets up the environment for the tutorial: imports external libraries (os, numpy, matplotlib, datetime, pandas, warnings), configures plotting settings, and defines file paths for input data. Also sets the RUN_FIXED_TILT flag to True. ```python # Import external libraries import os import numpy as np import matplotlib.pyplot as plt from datetime import datetime import pandas as pd import warnings # Settings %matplotlib inline np.set_printoptions(precision=3, linewidth=300) warnings.filterwarnings('ignore') plt.style.use('seaborn-whitegrid') plt.rcParams.update({'font.size': 12}) # Paths LOCAL_DIR = os.getcwd() DATA_DIR = os.path.join(LOCAL_DIR, 'data') filepath = os.path.join(DATA_DIR, 'test_df_inputs_MET_clearsky_tucson.csv') RUN_FIXED_TILT = True ``` -------------------------------- ### Create and fit PVEngine Source: https://sunpower.github.io/pvfactors/tutorials/Account_for_AOI_losses.html Create the PVEngine with the pvarray, vf_calculator, and irradiance_model, then fit it to the input data. ```python # Create engine engine = PVEngine(pvarray, vf_calculator=vf_calculator, irradiance_model=irradiance_model) # Fit engine to data engine.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi, df_inputs.solar_zenith, df_inputs.solar_azimuth, df_inputs.surface_tilt, df_inputs.surface_azimuth, albedo) ``` -------------------------------- ### Import external libraries and configure settings Source: https://sunpower.github.io/pvfactors/tutorials/Getting_started.html Initializes the environment by importing necessary libraries and configuring matplotlib and numpy settings. ```python # Import external libraries import numpy as np import matplotlib.pyplot as plt from datetime import datetime import pandas as pd import warnings warnings.filterwarnings("ignore", category=RuntimeWarning) # Settings %matplotlib inline np.set_printoptions(precision=3, linewidth=300) ``` -------------------------------- ### TsLineCoords.at Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.timeseries.TsLineCoords.html Get coordinates at a given index. ```APIDOC ## TsLineCoords.at ### Description Get coordinates at a given index. ### Method Method ### Parameters - **idx** (int) - Required - Index to retrieve coordinates at ``` -------------------------------- ### PVGround.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.PVGround.html Initializes the PV ground geometry with an optional list of PV segments and an optional original linestring. ```APIDOC ## PVGround.__init__ ### Description Initializes the PV ground geometry. ### Method Constructor ### Signature __init__(list_segments=None, original_linestring=None) ### Parameters - **list_segments** (list of PVSegment, optional) - List of PV segments that will constitute the ground (Default = []) - **original_linestring** (shapely.geometry.LineString, optional) - Full continuous linestring that the ground will be made of (Default = None) ``` -------------------------------- ### TsSurface.get_param Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.timeseries.TsSurface.html Get timeseries parameter values of surface. ```APIDOC ## TsSurface.get_param ### Description Get timeseries parameter values of surface. ### Method Method ### Signature get_param(param) ### Parameters - **param** - The parameter name. ### Returns Timeseries parameter values ``` -------------------------------- ### run_full_mode(fn_build_report=None) Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/engine.html Run all simulation timesteps using the full mode, which calculates the equilibrium of reflections in the system, and returns a report that will be built by the function passed by the user. ```APIDOC ## run_full_mode(fn_build_report=None) ### Description Run all simulation timesteps using the full mode, which calculates the equilibrium of reflections in the system, and returns a report that will be built by the function passed by the user. ### Parameters - **fn_build_report** (function, optional) - Optional - Function that will build the report of the simulation (Default value = None) ### Returns - **report** - Saved results from the simulation, as specified by user's report function. If no function is passed, nothing will be returned. ``` -------------------------------- ### TsSegment.get_param_weighted Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.TsSegment.html Gets timeseries parameter for the segment, after weighting by surface length. ```APIDOC ## TsSegment.get_param_weighted ### Description Get timeseries parameter for the segment, after weighting by surface length. ### Method get_param_weighted(param) ### Parameters - **param** - Required - The parameter to retrieve. ### Returns - Timeseries parameter weighted by surface length. ``` -------------------------------- ### Imports and settings for full timeseries simulations Source: https://sunpower.github.io/pvfactors/tutorials/Run_full_timeseries_simulations.html Sets up the Python environment for the tutorial. Imports external libraries (os, numpy, matplotlib, datetime, pandas, warnings), enables inline plotting, sets numpy print options, ignores warnings, and defines local and data directory paths along with a filepath to a test CSV input file. ```python # Import external libraries import os import numpy as np import matplotlib.pyplot as plt from datetime import datetime import pandas as pd import warnings # Settings %matplotlib inline np.set_printoptions(precision=3, linewidth=300) warnings.filterwarnings('ignore') # Paths LOCAL_DIR = os.getcwd() DATA_DIR = os.path.join(LOCAL_DIR, 'data') filepath = os.path.join(DATA_DIR, 'test_df_inputs_MET_clearsky_tucson.csv') ``` -------------------------------- ### PVSurface.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.base.PVSurface.html Initializes a PV surface with optional coordinates, normal vector, shaded flag, index, parameter names, and parameters. ```APIDOC ## PVSurface.__init__ ### Description Initializes a PV surface object. The only difference from BaseSurface is that PV surfaces have a 'shaded' attribute. ### Method Constructor ### Signature PVSurface(coords=None, normal_vector=None, shaded=False, index=None, param_names=None, params=None) ### Parameters - **coords** (list, optional) - List of linestring coordinates for the surface - **normal_vector** (list, optional) - Normal vector for the surface (Default = None, so will be calculated) - **shaded** (bool, optional) - Flag telling if surface is shaded or not (Default = False) - **index** (int, optional) - Surface index (Default = None) - **param_names** (list of str, optional) - Names of the surface parameters, eg reflectivity, total incident irradiance, temperature, etc. (Default = None) - **params** (dict, optional) - Surface float parameters (Default = None) ### Returns None ``` -------------------------------- ### TsGround.get_param_weighted Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Get timeseries parameter for the ts ground, after weighting by surface length. ```APIDOC ## TsGround.get_param_weighted ### Description Get timeseries parameter for the ts ground, after weighting by surface length. ### Method Method ### Signature `get_param_weighted(param)` ### Parameters - **param** (str) - Required - Name of the parameter to retrieve. ### Returns Weighted timeseries parameter values. ``` -------------------------------- ### PVEngine class with rho initialization Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/engine.html Defines the PVEngine class with its constructor and the with_rho_initialization classmethod. The constructor initializes the view factor calculator, irradiance model, and fast mode indices. The classmethod calculates front and back reflectivity using the VF calculator's rho_from_faoi_fn and initializes the irradiance model's rho values with defaults from pvfactors.config. ```python """This module contains the engine class that will run the complete timeseries simulations.""" import numpy as np from pvfactors.viewfactors import VFCalculator from pvfactors.irradiance import HybridPerezOrdered from pvfactors.config import DEFAULT_RHO_FRONT, DEFAULT_RHO_BACK [docs]class PVEngine(object): """Class putting all of the calculations together into simple workflows. """ [docs] def __init__(self, pvarray, vf_calculator=None, irradiance_model=None, fast_mode_pvrow_index=None, fast_mode_segment_index=None): """Create pv engine class, and initialize timeseries parameters. Parameters ---------- pvarray : BasePVArray (or child) object The initialized PV array object that will be used for calculations vf_calculator : vf calculator object, optional Calculator that will be used to calculate the view factor matrices, will use :py:class:`~pvfactors.viewfactors.calculator.VFCalculator` if None (Default = None) irradiance_model : irradiance model object, optional The irradiance model that will be applied to the PV array, will use :py:class:`~pvfactors.irradiance.models.HybridPerezOrdered` if None (Default = None) fast_mode_pvrow_index : int, optional If a pvrow index is passed, then the PVEngine fast mode will be activated and the engine calculation will be done only for the back surface of the pvrow with the corresponding index (Default = None) fast_mode_segment_index : int, optional If a segment index is passed, then the PVEngine fast mode will calculate back surface irradiance only for the selected segment of the selected back surface (Default = None) """ # Initialize the attributes of the PV engine self.vf_calculator = vf_calculator or VFCalculator() self.irradiance = irradiance_model or HybridPerezOrdered() self.pvarray = pvarray # Save fast mode indices self.fast_mode_pvrow_index = fast_mode_pvrow_index self.fast_mode_segment_index = fast_mode_segment_index # These values will be updated at fitting time self.n_points = None self.skip_step = None @classmethod def with_rho_initialization( cls, pvarray, vf_calculator, irradiance_model, fast_mode_pvrow_index=None, fast_mode_segment_index=None): """Before creating the PV engine object, update the front and back reflectivity scalars using the faoi functions, if those values weren't passed originally Parameters ---------- pvarray : :py:class:`~pvfactors.geometry.pvarray.OrderedPVArray` The initialized PV array object that will be used for calculations vf_calculator : \ :py:class:`~pvfactors.viewfactors.calculator.VFCalculator` Calculator that will be used to calculate the view factor matrices, and AOI losses irradiance_model : irradiance model object The irradiance model that will be applied to the PV array, for instance :py:class:`~pvfactors.irradiance.models.HybridPerezOrdered` fast_mode_pvrow_index : int, optional If a pvrow index is passed, then the PVEngine fast mode will be activated and the engine calculation will be done only for the back surface of the pvrow with the corresponding index (Default = None) fast_mode_segment_index : int, optional If a segment index is passed, then the PVEngine fast mode will calculate back surface irradiance only for the selected segment of the selected back surface (Default = None) Returns ------- PV engine PV engine where the rho values have been initialized """ # Calculate global average reflectivity using VF calculator is_back = False rho_front_calculated = (vf_calculator.vf_aoi_methods .rho_from_faoi_fn(is_back)) is_back = True rho_back_calculated = (vf_calculator.vf_aoi_methods .rho_from_faoi_fn(is_back)) # Initialize rho values for irradiance model irradiance_model.rho_front = irradiance_model.initialize_rho( irradiance_model.rho_front, rho_front_calculated, DEFAULT_RHO_FRONT) irradiance_model.rho_back = irradiance_model.initialize_rho( irradiance_model.rho_back, rho_back_calculated, DEFAULT_RHO_BACK) ``` -------------------------------- ### HybridPerezOrdered.get_full_modeling_vectors Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.irradiance.models.HybridPerezOrdered.html Gets the modeling vectors used in matrix calculations of the mathematical model. ```APIDOC ## HybridPerezOrdered.get_full_modeling_vectors ### Description Gets the modeling vectors used in matrix calculations of the mathematical model. ### Method get_full_modeling_vectors(pvarray, idx) ### Parameters - **pvarray** - The PV array object. - **idx** - Index for the time step. ### Returns Modeling vectors used in matrix calculations. ``` -------------------------------- ### TsShadeCollection.get_param_weighted(param) Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.timeseries.TsShadeCollection.html Gets timeseries parameter for the collection, after weighting by surface length. ```APIDOC ## TsShadeCollection.get_param_weighted(param) ### Description Gets timeseries parameter for the collection, after weighting by surface length. ### Method get_param_weighted ### Parameters - **param** (type not specified) - Required - The parameter to retrieve. ### Returns The weighted timeseries parameter. ``` -------------------------------- ### Create and fit PVEngine with HybridPerezOrdered Source: https://sunpower.github.io/pvfactors/tutorials/Account_for_AOI_losses.html Creates a HybridPerezOrdered irradiance model with 3% front and 5% back reflection, then creates a PVEngine and fits it to the input data. ```python from pvfactors.engine import PVEngine from pvfactors.irradiance import HybridPerezOrdered # Create irradiance model irradiance_model = HybridPerezOrdered(rho_front=0.03, rho_back=0.05) # Create engine engine = PVEngine(pvarray, irradiance_model=irradiance_model) # Fit engine to data engine.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi, df_inputs.solar_zenith, df_inputs.solar_azimuth, df_inputs.surface_tilt, df_inputs.surface_azimuth, albedo) ``` -------------------------------- ### TsSegment.surfaces_at_idx Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.TsSegment.html Gets all PV surface geometries in timeseries segment for a certain index. ```APIDOC ## TsSegment.surfaces_at_idx ### Description Get all PV surface geometries in timeseries segment for a certain index. ### Method surfaces_at_idx(idx) ### Parameters - **idx** - Required - The index for which to retrieve the surfaces. ### Returns - All PV surface geometries in the timeseries segment at the specified index. ``` -------------------------------- ### Prepare PV array parameters Source: https://sunpower.github.io/pvfactors/tutorials/Create_discretized_pvarray.html Define the dictionary of parameters required to initialize the PV array geometry. ```python pvarray_parameters = { 'n_pvrows': 3, # number of pv rows 'pvrow_height': 1, # height of pvrows (measured at center / torque tube) 'pvrow_width': 1, # width of pvrows 'axis_azimuth': 0., # azimuth angle of rotation axis 'surface_tilt': 20., # tilt of the pv rows 'surface_azimuth': 270., # azimuth of the pv rows front surface 'solar_zenith': 40., # solar zenith angle 'solar_azimuth': 150., # solar azimuth angle 'gcr': 0.5, # ground coverage ratio } ``` -------------------------------- ### ShadeCollection.get_param_weighted Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.base.ShadeCollection.html Gets the parameter from the collection's surfaces, after weighting by surface length. ```APIDOC ## ShadeCollection.get_param_weighted ### Description Gets the parameter from the collection's surfaces, after weighting by surface length. ### Method get_param_weighted ### Parameters - **param** (str) - The name of the parameter to retrieve. ### Returns float - The weighted parameter value. ``` -------------------------------- ### Instantiate PVEngine and fit to data Source: https://sunpower.github.io/pvfactors/tutorials/Run_fast_simulations.html Creates an OrderedPVArray from parameters, instantiates a PVEngine with fast_mode_pvrow_index=1, and fits the engine to the timeseries data. ```python # Import PVEngine and OrderedPVArray from pvfactors.engine import PVEngine from pvfactors.geometry import OrderedPVArray # Instantiate PV array pvarray = OrderedPVArray.init_from_dict(pvarray_parameters) # Create PV engine, and specify the index of the PV row for fast mode fast_mode_pvrow_index = 1 # look at the middle PV row eng = PVEngine(pvarray, fast_mode_pvrow_index=fast_mode_pvrow_index) # Fit PV engine to the timeseries data eng.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi, df_inputs.solar_zenith, df_inputs.solar_azimuth, df_inputs.surface_tilt, df_inputs.surface_azimuth, albedo) ``` -------------------------------- ### TsGround.ts_surfaces_side_of_cut_point Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Get a list of all the ts ground surfaces an a request side of a cut point. ```APIDOC ## TsGround.ts_surfaces_side_of_cut_point ### Description Get a list of all the ts ground surfaces an a request side of a cut point. ### Method Method ### Signature `ts_surfaces_side_of_cut_point(side, idx_cut_pt)` ### Parameters - **side** (str) - Required - Side of the cut point (e.g., 'left' or 'right'). - **idx_cut_pt** (int) - Required - Index of the cut point. ### Returns List of ts ground surfaces on the specified side. ``` -------------------------------- ### Create and fit PV array engine Source: https://sunpower.github.io/pvfactors/tutorials/Getting_started.html Initializes the PV array and engine, then fits the engine to the provided timeseries data. ```python from pvfactors.engine import PVEngine from pvfactors.geometry import OrderedPVArray # Create an ordered PV array pvarray = OrderedPVArray.init_from_dict(pvarray_parameters) # Create engine using the PV array engine = PVEngine(pvarray) # Fit engine to data: which will update the pvarray object as well engine.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi, df_inputs.solar_zenith, df_inputs.solar_azimuth, df_inputs.surface_tilt, df_inputs.surface_azimuth, df_inputs.albedo) ``` -------------------------------- ### BaseSurface.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.base.BaseSurface.html Initializes a BaseSurface instance with linestring coordinates and optional normal vector, index, parameter names, and parameters. ```APIDOC ## BaseSurface.__init__ ### Description Create a surface using linestring coordinates. Normal vector can have two directions for a given LineString, so the user can provide it in order to be specific, otherwise it will be automatically calculated, but then the surface won't know if it was supposed to be pointing "up" or "down". If the surface is empty, the normal vector will take the default value. ### Parameters - **coords** (list) - Required - List of linestring coordinates for the surface - **normal_vector** (list, optional) - Normal vector for the surface (Default = None, so will be calculated) - **index** (int, optional) - Surface index (Default = None) - **param_names** (list of str, optional) - Names of the surface parameters, eg reflectivity, total incident irradiance, temperature, etc. (Default = None) - **params** (dict, optional) - Surface float parameters (Default = None) ``` -------------------------------- ### HybridPerezOrdered.get_summed_components Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.irradiance.models.HybridPerezOrdered.html Gets the sum of irradiance components for the irradiance model, either absorbed or only incident. ```APIDOC ## HybridPerezOrdered.get_summed_components ### Description Gets the sum of irradiance components for the irradiance model, either absorbed or only incident. ### Method get_summed_components(pvarray, absorbed=False) ### Parameters - **pvarray** - The PV array object. - **absorbed** (bool, optional) - If True, returns absorbed irradiance; otherwise incident. Default = False. ### Returns Summed irradiance components. ``` -------------------------------- ### TsPVRow.surfaces_at_idx Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.TsPVRow.html Get all PV surface geometries in timeseries PV row for a certain index. ```APIDOC ## TsPVRow.surfaces_at_idx ### Description Get all PV surface geometries in timeseries PV row for a certain index. ### Method Method ### Signature surfaces_at_idx(idx) ### Parameters - **idx** - Required - The index for which to retrieve the surface geometries. ``` -------------------------------- ### PVEngine.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.engine.PVEngine.html Constructor for the PVEngine class. Initializes the engine with a PV array and optional configuration for view factor calculation, irradiance model, and fast mode settings. ```APIDOC ## PVEngine.__init__ ### Description Create pv engine class, and initialize timeseries parameters. ### Method Constructor ### Signature __init__(pvarray, vf_calculator=None, irradiance_model=None, fast_mode_pvrow_index=None, fast_mode_segment_index=None) ### Parameters - **pvarray** (BasePVArray object) - Required - The initialized PV array object that will be used for calculations - **vf_calculator** (vf calculator object, optional) - Optional - Calculator that will be used to calculate the view factor matrices, will use VFCalculator if None (Default = None) - **irradiance_model** (irradiance model object, optional) - Optional - The irradiance model that will be applied to the PV array, will use HybridPerezOrdered if None (Default = None) - **fast_mode_pvrow_index** (int, optional) - Optional - If a pvrow index is passed, then the PVEngine fast mode will be activated and the engine calculation will be done only for the back surface of the pvrow with the corresponding index (Default = None) - **fast_mode_segment_index** (int, optional) - Optional - If a segment index is passed, then the PVEngine fast mode will calculate back surface irradiance only for the selected segment of the selected back surface (Default = None) ``` -------------------------------- ### TsGround.shadow_coords_right_of_cut_point Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Get coordinates of shadows located on the right side of the cut point with given index. ```APIDOC ## TsGround.shadow_coords_right_of_cut_point ### Description Get coordinates of shadows located on the right side of the cut point with given index. ### Method Method ### Signature `shadow_coords_right_of_cut_point(idx_cut_pt)` ### Parameters - **idx_cut_pt** (int) - Required - Index of the cut point. ### Returns Coordinates of shadows on the right side. ``` -------------------------------- ### TsGround.shadow_coords_left_of_cut_point Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Get coordinates of shadows located on the left side of the cut point with given index. ```APIDOC ## TsGround.shadow_coords_left_of_cut_point ### Description Get coordinates of shadows located on the left side of the cut point with given index. ### Method Method ### Signature `shadow_coords_left_of_cut_point(idx_cut_pt)` ### Parameters - **idx_cut_pt** (int) - Required - Index of the cut point. ### Returns Coordinates of shadows on the left side. ``` -------------------------------- ### TsShadeCollection.get_param_ww(param) Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.timeseries.TsShadeCollection.html Gets timeseries parameter from the collection with weight, i.e. after multiplying by the surface lengths. ```APIDOC ## TsShadeCollection.get_param_ww(param) ### Description Gets timeseries parameter from the collection with weight, i.e. after multiplying by the surface lengths. ### Method get_param_ww ### Parameters - **param** (type not specified) - Required - The parameter to retrieve. ### Returns The weighted timeseries parameter. ``` -------------------------------- ### PVRow.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.PVRow.html Initializes a PV row with front and back sides, an index, and an optional original linestring. ```APIDOC ## PVRow.__init__ ### Description Initialize a PV row with front and back sides, an index, and an optional original linestring. ### Method Constructor ### Signature `__init__(front_side=, back_side=, index=None, original_linestring=None)` ### Parameters - **front_side** (`PVRowSide`, optional) - Front side of the PV Row (Default = Empty PVRowSide) - **back_side** (`PVRowSide`, optional) - Back side of the PV Row (Default = Empty PVRowSide) - **index** (`int`, optional) - Index of PV row (Default = None) - **original_linestring** (`shapely.geometry.LineString`, optional) - Full continuous linestring that the PV row will be made of (Default = None) ### Returns None ``` -------------------------------- ### Method signature and docstring for vf_pvrow_surf_to_gnd_surf_obstruction_hottel Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/viewfactors/vfmethods.html This is the method definition and docstring for the view factor calculation method. It takes a PV row surface, ground surface, and other parameters, and returns view factors from the PV row surface to the ground surface and vice versa using reciprocity. ```python def vf_pvrow_surf_to_gnd_surf_obstruction_hottel( self, pvrow_surf, pvrow_idx, n_pvrows, tilted_to_left, ts_pvrows, gnd_surf, pvrow_surf_length, is_back=True, is_left=True): """Calculate view factors from timeseries PV row surface to a timeseries ground surface. This will return the calculated view factors from the PV row surface to the ground surface, AND from the ground surface to the PV row surface (using reciprocity).""" ``` -------------------------------- ### ShadeCollection.get_param_ww Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.base.ShadeCollection.html Gets the parameter from the collection's surfaces with weight, i.e., after multiplying by the surface lengths. ```APIDOC ## ShadeCollection.get_param_ww ### Description Gets the parameter from the collection's surfaces with weight, i.e., after multiplying by the surface lengths. ### Method get_param_ww ### Parameters - **param** (str) - The name of the parameter to retrieve. ### Returns float - The weighted parameter value. ``` -------------------------------- ### Import libraries and configure paths for fast simulations Source: https://sunpower.github.io/pvfactors/tutorials/Run_fast_simulations.html Prepares the Python environment for the fast-mode tutorial. It imports external libraries, enables inline matplotlib output, ignores warnings, and defines LOCAL_DIR, DATA_DIR, and filepath pointing to test_df_inputs_MET_clearsky_tucson.csv. ```python # Import external libraries import os import numpy as np import matplotlib.pyplot as plt from datetime import datetime import pandas as pd import warnings # Settings %matplotlib inline np.set_printoptions(precision=3, linewidth=300) warnings.filterwarnings('ignore') # Paths LOCAL_DIR = os.getcwd() DATA_DIR = os.path.join(LOCAL_DIR, 'data') filepath = os.path.join(DATA_DIR, 'test_df_inputs_MET_clearsky_tucson.csv') ``` -------------------------------- ### TsGround.get_param_ww Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Get timeseries parameter from the ground's surfaces with weight, i.e. after multiplying by the surface lengths. ```APIDOC ## TsGround.get_param_ww ### Description Get timeseries parameter from the ground's surfaces with weight, i.e. after multiplying by the surface lengths. ### Method Method ### Signature `get_param_ww(param)` ### Parameters - **param** (str) - Required - Name of the parameter to retrieve. ### Returns Weighted timeseries parameter values. ``` -------------------------------- ### Engine.run_full_mode method Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/engine.html Runs the full-mode simulation, which computes the equilibrium of reflections. It retrieves the PV array, obtains irradiance modeling vectors, builds the timeseries view-factor matrix, stores it on the array, and reshapes it for broadcasting and inversion. The report is built by the user-supplied function; if none is passed, nothing is returned. ```python def run_full_mode(self, fn_build_report=None): """Run all simulation timesteps using the full mode, which calculates the equilibrium of reflections in the system, and returns a report that will be built by the function passed by the user. Parameters ---------- fn_build_report : function, optional Function that will build the report of the simulation (Default value = None) Returns ------- report Saved results from the simulation, as specified by user's report function. If no function is passed, nothing will be returned. """ # Get pvarray pvarray = self.pvarray # Get the irradiance modeling matrices # shape = n_surfaces + 1, n_timesteps irradiance_mat, rho_mat, invrho_mat, _ = \ self.irradiance.get_full_ts_modeling_vectors(pvarray) # --- Calculate view factors # shape = n_surfaces + 1, n_surfaces + 1, n_timesteps ts_vf_matrix = self.vf_calculator.build_ts_vf_matrix(pvarray) pvarray.ts_vf_matrix = ts_vf_matrix # Reshape for broadcasting and inverting # shape = n_timesteps, n_surfaces + 1, n_surfaces + 1 ts_vf_matrix_reshaped = np.moveaxis(ts_vf_matrix, -1, 0) ``` -------------------------------- ### Create VFCalculator with fAOI functions Source: https://sunpower.github.io/pvfactors/tutorials/Account_for_AOI_losses.html Create a VFCalculator with fAOI functions for front and back surfaces, using 1000 integral points for convergence. ```python from pvfactors.viewfactors import VFCalculator vf_calculator = VFCalculator(faoi_fn_front=faoi_function, faoi_fn_back=faoi_function, n_aoi_integral_sections=1000) ``` -------------------------------- ### Get full modeling vectors Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/irradiance/models.html Retrieves the modeling vectors required for matrix calculations of the mathematical model. ```python def get_full_modeling_vectors(self, pvarray, idx): """Get the modeling vectors used in matrix calculations of mathematical model. Parameters ---------- pvarray : PV array object PV array on which the calculated irradiance values will be applied idx : int, optional Index of the irradiance values to apply to the PV array (in the whole timeseries values) ``` -------------------------------- ### HybridPerezOrdered.get_full_ts_modeling_vectors Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.irradiance.models.HybridPerezOrdered.html Gets the modeling vectors used in matrix calculations of the mathematical model, including the sky values. ```APIDOC ## HybridPerezOrdered.get_full_ts_modeling_vectors ### Description Gets the modeling vectors used in matrix calculations of the mathematical model, including the sky values. ### Method get_full_ts_modeling_vectors(pvarray) ### Parameters - **pvarray** - The PV array object. ### Returns Modeling vectors including sky values. ``` -------------------------------- ### Create OrderedPVArray and fit PVEngine to data Source: https://sunpower.github.io/pvfactors/tutorials/Run_full_timeseries_simulations.html Instantiates an OrderedPVArray from the parameters dictionary, creates a PVEngine, and fits it to the input data with the fixed albedo. ```python from pvfactors.engine import PVEngine from pvfactors.geometry import OrderedPVArray # Create ordered PV array pvarray = OrderedPVArray.init_from_dict(pvarray_parameters) # Create engine engine = PVEngine(pvarray) # Fit engine to data engine.fit(df_inputs.index, df_inputs.dni, df_inputs.dhi, df_inputs.solar_zenith, df_inputs.solar_azimuth, df_inputs.surface_tilt, df_inputs.surface_azimuth, albedo) ``` -------------------------------- ### TsSegment.get_param_ww Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.TsSegment.html Gets timeseries parameter from the segment's surfaces with weight, i.e. after multiplying by the surface lengths. ```APIDOC ## TsSegment.get_param_ww ### Description Get timeseries parameter from the segment's surfaces with weight, i.e. after multiplying by the surface lengths. ### Method get_param_ww(param) ### Parameters - **param** - Required - The parameter to retrieve. ### Returns - Timeseries parameter multiplied by surface lengths. ``` -------------------------------- ### Run full mode simulation and plot PV array at timestep Source: https://sunpower.github.io/pvfactors/tutorials/Run_full_timeseries_simulations.html Runs the simulation for a single timestep using engine.run_full_mode with a report builder that returns the PV array, then plots the shapely geometries at index 15 with surface indices. ```python # Get the PV array pvarray = engine.run_full_mode(fn_build_report=lambda pvarray: pvarray) # Plot pvarray shapely geometries f, ax = plt.subplots(figsize=(10, 3)) pvarray.plot_at_idx(15, ax, with_surface_index=True) ax.set_title(df.index[15]) plt.show() ``` -------------------------------- ### HybridPerezOrdered.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.irradiance.models.HybridPerezOrdered.html Initializes the irradiance model with configurable parameters for horizon band angle, circumsolar angle, reflectivity, module transparency, and fAOI functions. ```APIDOC ## HybridPerezOrdered.__init__ ### Description Initializes the irradiance model values that will be saved later on. ### Method Constructor ### Signature __init__(horizon_band_angle=6.5, circumsolar_angle=30.0, circumsolar_model='uniform_disk', rho_front=0.01, rho_back=0.03, module_transparency=0.0, module_spacing_ratio=0.0, faoi_fn_front=None, faoi_fn_back=None) ### Parameters - **horizon_band_angle** (float, optional) - Width of the horizon band in degrees. Default = 6.5. - **circumsolar_angle** (float, optional) - Diameter of the circumsolar area in degrees. Default = 30.0. - **circumsolar_model** (str) - Circumsolar shading model to use. Default = 'uniform_disk'. - **rho_front** (float, optional) - Reflectivity of the front side of the PV rows. Default = 0.01. - **rho_back** (float, optional) - Reflectivity of the back side of the PV rows. Default = 0.03. - **module_transparency** (float, optional) - Module transparency (0 to 1). Default = 0.0 (fully opaque). - **module_spacing_ratio** (float, optional) - Module spacing ratio (0 to 1). Default = 0.0 (no spacing). - **faoi_fn_front** (function or object, optional) - Function or object with 'faoi' method that takes incidence angles and returns fAOI values for front side. Default = None. - **faoi_fn_back** (function or object, optional) - Function or object with 'faoi' method that takes incidence angles and returns fAOI values for back side. Default = None. ### Returns None ``` -------------------------------- ### PVRowSide.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvrow.PVRowSide.html Initializes a PVRowSide instance using its base class BaseSide with a list of PV segments. ```APIDOC ## PVRowSide.__init__ ### Description Initializes a PVRowSide instance using its base class BaseSide with a list of PV segments. ### Method Constructor ### Signature PVRowSide(list_segments=[]) ### Parameters - **list_segments** (list of PVSegment) - Optional - List of PV segments for PV row side. ### Returns None ### Example ```python from pvfactors.geometry.pvrow import PVRowSide side = PVRowSide(list_segments=[segment1, segment2]) ``` ``` -------------------------------- ### pvfactors.report module source code Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/report.html The complete source code for the pvfactors.report module, including the example report builder function and class. ```python """Module containing examples of report builder functions and classes.""" [docs]def example_fn_build_report(pvarray): """Example function that builds a report when used in the :py:class:`~pvfactors.engine.PVEngine` with full or fast mode simulations. Here it will be a dictionary with lists of calculated values. Parameters ---------- pvarray : PV array object PV array with updated calculation values Returns ------- report : dict Report updated with newly calculated values """ return {'qinc_front': pvarray.ts_pvrows[1].front .get_param_weighted('qinc').tolist(), 'qinc_back': pvarray.ts_pvrows[1].back .get_param_weighted('qinc').tolist(), 'iso_front': pvarray.ts_pvrows[1].front .get_param_weighted('isotropic').tolist(), 'iso_back': pvarray.ts_pvrows[1].back .get_param_weighted('isotropic').tolist()} [docs]class ExampleReportBuilder(object): """A class is required to build reports when running calculations with multiprocessing because of python constraints""" @staticmethod def build(pvarray): """Method that will build the simulation report, using :py:func:`~pvfactors.report.example_fn_build_report`. Parameters ---------- pvarray : PV array object PV array with updated calculation values Returns ------- report : dict Report updated with newly calculated values """ return example_fn_build_report(pvarray) @staticmethod def merge(reports): """Method used to merge multiple reports together. Here it simply concatenates the lists of values saved in the different reports. Parameters ---------- reports : list of dict List of reports that need to be concatenated together Returns ------- report : dict Final report with all concatenated values """ report = reports[0] # merge other reports if any keys_report = list(reports[0].keys()) for other_report in reports[1:]: for key in keys_report: report[key] += other_report[key] return report ``` -------------------------------- ### Instantiate view factor calculator Source: https://sunpower.github.io/pvfactors/tutorials/Calculate_view_factors.html Imports and instantiates the VFCalculator class to prepare for matrix calculation. ```python # import view factor calculator from pvfactors.viewfactors import VFCalculator # instantiate calculator vf_calculator = VFCalculator() ``` -------------------------------- ### HybridPerezOrdered.get_ts_modeling_vectors Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.irradiance.models.HybridPerezOrdered.html Gets matrices of summed up irradiance values from a PV array, as well as the inverse reflectivity values and the total perez irradiance values. ```APIDOC ## HybridPerezOrdered.get_ts_modeling_vectors ### Description Gets matrices of summed up irradiance values from a PV array, as well as the inverse reflectivity values (named 'inv_rho') and the total perez irradiance values. ### Method get_ts_modeling_vectors(pvarray) ### Parameters - **pvarray** - The PV array object. ### Returns Matrices of summed irradiance values, inverse reflectivity, and total perez irradiance. ``` -------------------------------- ### TsPointCoords.at(idx) Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.timeseries.TsPointCoords.html Get coordinates at a given index from the timeseries point coordinates. This method allows accessing the x and y values for a specific time step. ```APIDOC ## TsPointCoords.at(idx) ### Description Get coordinates at a given index. ### Method `at(idx)` ### Parameters - **idx** (index) - Required: The index of the coordinate to retrieve. ### Returns Coordinates at the specified index. (Exact return type not specified in the source.) ``` -------------------------------- ### Create HybridPerezOrdered irradiance model Source: https://sunpower.github.io/pvfactors/tutorials/Account_for_AOI_losses.html Create the irradiance model with the calculated reflectivity values and fAOI functions. ```python irradiance_model = HybridPerezOrdered(rho_front=rho_front, rho_back=rho_back, faoi_fn_front=faoi_function, faoi_fn_back=faoi_function) ``` -------------------------------- ### PVEngine.run_full_mode Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.engine.PVEngine.html Runs all simulation timesteps using the full mode, which calculates the equilibrium of reflections in the system, and returns a report built by the user-provided function. ```APIDOC ## PVEngine.run_full_mode ### Description Run all simulation timesteps using the full mode, which calculates the equilibrium of reflections in the system, and returns a report that will be built by the function passed by the user. ### Method run_full_mode ### Signature run_full_mode(fn_build_report=None) ### Parameters - **fn_build_report** (function, optional) - Optional - Function to build the report from the simulation results ``` -------------------------------- ### Get full timeseries modeling vectors Source: https://sunpower.github.io/pvfactors/_modules/pvfactors/irradiance/models.html Retrieves modeling vectors for the entire timeseries, including sky values. This method is similar to get_full_modeling_vectors but operates on the full timeseries. ```python def get_full_ts_modeling_vectors(self, pvarray): """Get the modeling vectors used in matrix calculations of the mathematical model, including the sky values. Parameters ---------- pvarray : PV array object PV array on which the calculated irradiance values will be applied """ ``` -------------------------------- ### ShadeCollection.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.base.ShadeCollection.html Initializes a ShadeCollection instance with optional list of surfaces, shading status, and parameter names. ```APIDOC ## ShadeCollection.__init__ ### Description Initializes a ShadeCollection instance with optional list of surfaces, shading status, and parameter names. ### Method Constructor ### Parameters - **list_surfaces** (list, optional) - List of PVSurface objects. Default = None. - **shaded** (bool, optional) - Shading status of the collection. If not specified, derived from list of surfaces. Default = None. - **param_names** (list of str, optional) - Names of the surface parameters (e.g., reflectivity, total incident irradiance, temperature). Default = None. ### Returns None ``` -------------------------------- ### Get shaded length on front surface of PV rows Source: https://sunpower.github.io/pvfactors/tutorials/PVArray_introduction.html Computes the shaded length on the front surface of the leftmost and rightmost PV rows using the shaded_length attribute. The leftmost row is shaded (0.48 m) while the rightmost row is not shaded (0.00 m). ```python # Shaded length on first pv row (leftmost) l = pvarray_w_direct_shading.ts_pvrows[0].front.shaded_length print("Shaded length on front surface of leftmost PV row: %.2f m" % l) ``` ```text Shaded length on front surface of leftmost PV row: 0.48 m ``` ```python # Shaded length on last pv row (rightmost) l = pvarray_w_direct_shading.ts_pvrows[-1].front.shaded_length print("Shaded length on front surface of rightmost PV row: %.2f m" %l) ``` ```text Shaded length on front surface of rightmost PV row: 0.00 m ``` -------------------------------- ### Configure and create PV array with direct shading Source: https://sunpower.github.io/pvfactors/tutorials/PVArray_introduction.html Updates the PV array configuration to introduce direct shading, then creates a new OrderedPVArray from the updated parameters and plots its shapely geometries. The plot shows inter-row shading on the PV array. ```python # New configuration with direct shading pvarray_parameters.update({'surface_tilt': 80., 'solar_zenith': 75., 'solar_azimuth': 90.}) ``` ```python pvarray_parameters ``` ```python {'n_pvrows': 4, 'pvrow_height': 1, 'pvrow_width': 1, 'axis_azimuth': 0.0, 'surface_tilt': 80.0, 'surface_azimuth': 90.0, 'solar_zenith': 75.0, 'solar_azimuth': 90.0, 'gcr': 0.5} ``` ```python # Create new PV array pvarray_w_direct_shading = OrderedPVArray.fit_from_dict_of_scalars(pvarray_parameters) ``` ```python # Plot pvarray shapely geometries f, ax = plt.subplots(figsize=(10, 3)) pvarray_w_direct_shading.plot_at_idx(0, ax) plt.show() ``` -------------------------------- ### TsGround.__init__ Source: https://sunpower.github.io/pvfactors/developer/generated/pvfactors.geometry.pvground.TsGround.html Initialize a TsGround object with shadow and illuminated ground elements, optional parameter names, overlap flags, cut point coordinates, and ground y-coordinate. ```APIDOC ## TsGround.__init__ ### Description Initialize a TsGround object with shadow and illuminated ground elements, optional parameter names, overlap flags, cut point coordinates, and ground y-coordinate. ### Method Constructor ### Signature `__init__(shadow_elements, illum_elements, param_names=None, flag_overlap=None, cut_point_coords=None, y_ground=None)` ### Parameters - **shadow_elements** (list of `TsGroundElement`) - Required - Timeseries shaded ground elements - **illum_elements** (list of `TsGroundElement`) - Required - Timeseries illuminated ground elements - **param_names** (list of str, optional) - List of names of surface parameters to use when creating geometries (Default = None) - **flag_overlap** (list of bool, optional) - Flags indicating if the ground shadows are overlapping, for all time steps (Default=None). I.e. is there direct shading on pv rows? - **cut_point_coords** (list of `TsPointCoords`, optional) - List of cut point coordinates, as calculated for timeseries PV rows (Default = None) - **y_ground** (float, optional) - Y coordinate of flat ground [m] (Default=None) ### Returns None ``` -------------------------------- ### Create a PV array Source: https://sunpower.github.io/pvfactors/tutorials/Create_discretized_pvarray.html Import the OrderedPVArray class and instantiate the PV array using the defined parameters. ```python from pvfactors.geometry import OrderedPVArray # Create pv array pvarray = OrderedPVArray.fit_from_dict_of_scalars(pvarray_parameters) ```