### Install pvfactors from source for contributing Source: https://solarfactors.readthedocs.io/en/latest/installation/index.html After forking and cloning the repository, run this command in the root folder to install the package. ```bash $ pip install . ``` -------------------------------- ### Install pvfactors with pip Source: https://solarfactors.readthedocs.io/en/latest/installation/index.html Use this command to install the pvfactors package from PyPI. Requires Python 3.6 or later. ```bash $ pip install pvfactors ``` -------------------------------- ### Run full simulation with example report function Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Run_full_timeseries_simulations.html Runs a full timeseries simulation using the example report function from pvfactors.report. The report is stored in a pandas DataFrame and printed for a subset of rows. ```python # Create a function that will build a report from pvfactors.report import example_fn_build_report # Run full simulation report = engine.run_full_mode(fn_build_report=example_fn_build_report) # Print results (report is defined by report function passed by user) df_report = pd.DataFrame(report, index=df_inputs.index) df_report.iloc[6:11] ``` -------------------------------- ### Import libraries and set up paths Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Account_for_AOI_losses.html Imports external libraries, sets up plotting and warning settings, and defines file paths for the tutorial data. ```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 ``` -------------------------------- ### Install shapely from conda-forge Source: https://solarfactors.readthedocs.io/en/latest/installation/index.html If you encounter an OSError about a missing module on Windows, install shapely from conda-forge to get the necessary binary dependencies. ```bash $ conda install -c conda-forge shapely ``` -------------------------------- ### Install pvfactors in editable mode Source: https://solarfactors.readthedocs.io/en/latest/installation/index.html Use this command to install the package in editable mode for development. ```bash $ pip install -e . ``` -------------------------------- ### Import PVEngine and OrderedPVArray and instantiate Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Run_fast_simulations.html Imports the required classes, initializes a PV array from the parameters, and creates a PVEngine with a specified fast-mode PV row index. The engine is then fitted to the input 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) ``` -------------------------------- ### Instantiate PVEngine and fit to data Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Run_full_timeseries_simulations.html Creates an OrderedPVArray from the parameters, instantiates 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) ``` -------------------------------- ### Initialize and fit PVEngine with fAOI Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Account_for_AOI_losses.html Initializes the PVEngine with the discretized pvarray, the VFCalculator with fAOI functions, and the irradiance model. Then fits the engine to the input data (index, DNI, DHI, solar angles, surface angles, and albedo). ```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) ``` -------------------------------- ### BaseSurface.get_param Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.BaseSurface.html Gets a parameter value from the surface. ```APIDOC ## BaseSurface.get_param ### Description Gets a parameter value from the surface. ### Method get_param(param) ### Parameters - **param** - The name of the parameter to retrieve. ``` -------------------------------- ### PVEngine.with_rho_initialization classmethod Source: https://solarfactors.readthedocs.io/en/latest/_modules/pvfactors/engine.html Classmethod that initializes front and back reflectivity values on the irradiance model using the view factor calculator's rho_from_faoi_fn method, falling back to DEFAULT_RHO_FRONT and DEFAULT_RHO_BACK if not provided. ```python @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) ``` -------------------------------- ### PVSurface.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.PVSurface.html Initializes a PVSurface instance with optional coordinates, normal vector, shading flag, index, parameter names, and parameters. ```APIDOC ## PVSurface.__init__ ### Description Initializes a PVSurface object. The PVSurface class inherits from BaseSurface and adds a 'shaded' attribute to indicate if the surface is shaded. ### Method Constructor ### Signature `__init__(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 is None, so it will be calculated. - **shaded** (bool, optional) - Flag indicating if the surface is shaded. Default is False. - **index** (int, optional) - Surface index. Default is None. - **param_names** (list of str, optional) - Names of surface parameters (e.g., reflectivity, total incident irradiance, temperature). Default is None. - **params** (dict, optional) - Surface float parameters. Default is None. ### Returns None ``` -------------------------------- ### TsLineCoords.at(idx) Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.timeseries.TsLineCoords.html Get coordinates at a given index. ```APIDOC ## TsLineCoords.at(idx) ### Description Get coordinates at a given index. ### Method Method ### Parameters - **idx** (type not specified) - Required - Index for which to retrieve coordinates ### Return Value Coordinates at the given index. ``` -------------------------------- ### TsSide.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/_modules/pvfactors/geometry/pvrow.html Get timeseries parameter for the side, after weighting by surface length. ```APIDOC ## TsSide.get_param_weighted ### Description Get timeseries parameter for the side, after weighting by surface length. ### Method get_param_weighted ### Parameters - **param** (str) - Required - Name of parameter ### Returns - **np.ndarray** - Weighted parameter values ``` -------------------------------- ### PVEngine.with_rho_initialization Source: https://solarfactors.readthedocs.io/en/latest/_modules/pvfactors/engine.html Class method to create a PVEngine with initialized reflectivity values. ```APIDOC ## PVEngine.with_rho_initialization ### Description Class method that creates a PVEngine instance after initializing front and back reflectivity values using the view factor calculator's AOI methods. ### Method Class Method ### Parameters - **pvarray** (OrderedPVArray) - Required - The initialized PV array object used for calculations. - **vf_calculator** (VFCalculator) - Required - Calculator for view factor matrices and AOI losses. - **irradiance_model** (irradiance model object) - Required - Irradiance model applied to the PV array, e.g., HybridPerezOrdered. - **fast_mode_pvrow_index** (int) - Optional - If provided, activates fast mode for the back surface of the specified PV row index. - **fast_mode_segment_index** (int) - Optional - If provided, calculates back surface irradiance only for the selected segment of the selected back surface. ### Returns - **PV engine** - PV engine with initialized rho values. ``` -------------------------------- ### TsSegment.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.pvrow.TsSegment.html Gets a 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 Instance Method ### Signature `get_param_weighted(param)` ### Parameters - **param** - Required - The parameter to retrieve. ### Returns The weighted timeseries parameter. ``` -------------------------------- ### PVEngine.__init__ Source: https://solarfactors.readthedocs.io/en/latest/_modules/pvfactors/engine.html Constructor for the PVEngine class that initializes the engine with a PV array and optional calculators. ```APIDOC ## PVEngine.__init__ ### Description Initializes the PVEngine object with a PV array, optional view factor calculator, optional irradiance model, and optional fast mode indices for optimized calculations. ### Method Constructor ### Parameters - **pvarray** (BasePVArray or child) - Required - The initialized PV array object used for calculations. - **vf_calculator** (vf calculator object) - Optional - Calculator for view factor matrices; defaults to VFCalculator. - **irradiance_model** (irradiance model object) - Optional - Irradiance model applied to the PV array; defaults to HybridPerezOrdered. - **fast_mode_pvrow_index** (int) - Optional - If provided, activates fast mode for the back surface of the specified PV row index. - **fast_mode_segment_index** (int) - Optional - If provided, calculates back surface irradiance only for the selected segment of the selected back surface. ### Returns None ``` -------------------------------- ### TsShadeCollection.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.timeseries.TsShadeCollection.html Gets a timeseries parameter for the collection, after weighting by surface length. ```APIDOC ## TsShadeCollection.get_param_weighted ### Description Gets a timeseries parameter for the collection, after weighting by surface length. ### Method Method ### Signature `get_param_weighted(param)` ### Parameters - **param** (str) - Required - The name of the parameter to retrieve. ### Returns The weighted timeseries parameter value. ``` -------------------------------- ### Run simulation with PVEngine Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Account_for_AOI_losses.html Creates a PVEngine with the irradiance model, fits it to input data, runs a full mode simulation, and converts the report to a DataFrame. ```python # 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) # Run full mode simulation report = engine.run_full_mode(fn_build_report=fn_report) # Turn report into dataframe df_report = pd.DataFrame(report, index=df_inputs.index) ``` -------------------------------- ### IsotropicOrdered.get_full_modeling_vectors Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.irradiance.models.IsotropicOrdered.html Gets the modeling vectors used in matrix calculations of the mathematical model. ```APIDOC ## IsotropicOrdered.get_full_modeling_vectors ### Description Gets the modeling vectors used in matrix calculations of the mathematical model. ### Parameters - **pvarray** (OrderedPVArray) - The PV array object - **idx** (int) - Index for the time step ### Returns - Modeling vectors as a dictionary or similar structure ``` -------------------------------- ### PVEngine.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.engine.PVEngine.html Constructor for the PVEngine class. Initializes the engine with a PV array and optional custom calculators for view factors and irradiance, as well as optional fast mode parameters. ```APIDOC ## PVEngine.__init__ ### Description Create a 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 or child object) - Required - The initialized PV array object that will be used for calculations. - **vf_calculator** (vf calculator object, optional) - Calculator used to calculate view factor matrices. Uses `VFCalculator` if None (Default = None). - **irradiance_model** (irradiance model object, optional) - The irradiance model applied to the PV array. Uses `HybridPerezOrdered` if None (Default = None). - **fast_mode_pvrow_index** (int, optional) - If a pvrow index is passed, activates fast mode, calculating only for the back surface of the specified pvrow (Default = None). - **fast_mode_segment_index** (int, optional) - If a segment index is passed, fast mode calculates back surface irradiance only for the selected segment of the selected back surface (Default = None). ### Response No return value. ``` -------------------------------- ### Create and fit PVEngine with HybridPerezOrdered Source: https://solarfactors.readthedocs.io/en/latest/tutorials/Account_for_AOI_losses.html Creates a HybridPerezOrdered irradiance model with 3% front and 5% back reflection, builds a PVEngine, and fits it to the input timeseries 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://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.pvrow.TsSegment.html Gets all PV surface geometries in the 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 Instance Method ### Signature `surfaces_at_idx(idx)` ### Parameters - **idx** - Required - The index for which to retrieve surfaces. ### Returns A list of PV surface geometries. ``` -------------------------------- ### IsotropicOrdered.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.irradiance.models.IsotropicOrdered.html Initializes the irradiance model with parameters for reflectivity, module transparency, spacing, and fAOI functions. ```APIDOC ## IsotropicOrdered.__init__ ### Description Initializes the irradiance model with parameters for reflectivity, module transparency, spacing, and fAOI functions. ### Method Constructor ### Parameters - **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 (from 0 to 1), which lets some direct light pass through the PV modules (default = 0., fully opaque) - **module_spacing_ratio** (float, optional) - Module spacing ratio (from 0 to 1), ratio of area covered by space between modules over total area of PV rows (default = 0., no spacing) - **faoi_fn_front** (function or object, optional) - Function or object with `faoi` method that takes a list of 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 a list of incidence angles and returns fAOI values for back side (default = None) ### Returns None ``` -------------------------------- ### TsGround.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/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 get_param_weighted(param) ### Parameters - **param** - Required - The parameter to retrieve. ``` -------------------------------- ### ShadeCollection.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.ShadeCollection.html Gets a parameter from the collection's surfaces, weighted by surface length. ```APIDOC ## ShadeCollection.get_param_weighted ### Description Gets a parameter from the collection's surfaces, weighted by surface length. ### Method Method ### Signature `get_param_weighted(param)` ### Parameters - **param** (str) - The name of the parameter to retrieve. ### Returns float - The weighted parameter value. ``` -------------------------------- ### TsGround.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.pvground.TsGround.html Initializes a timeseries ground using lists of timeseries surfaces for ground shadows and illuminated ground elements. ```APIDOC ## TsGround.__init__ ### Description Initialize timeseries ground using list of timeseries surfaces for the ground shadows. ### Method Constructor ### 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) - Optional - List of names of surface parameters to use when creating geometries (Default = None) - **flag_overlap** (list of bool, optional) - 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) - Optional - List of cut point coordinates, as calculated for timeseries PV rows (Default = None) - **y_ground** (float, optional) - Optional - Y coordinate of flat ground [m] (Default=None) ``` -------------------------------- ### PVSegment.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.PVSegment.html Get a parameter from the segment's surfaces, weighted by surface length. ```APIDOC ## PVSegment.get_param_weighted ### Description Get a parameter from the segment's surfaces, weighted by surface length. ### Method get_param_weighted ### Signature `get_param_weighted(param)` ### Parameters - **param** - The parameter to retrieve. ``` -------------------------------- ### BaseSurface.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.BaseSurface.html Creates a surface using linestring coordinates. The normal vector can be provided to specify orientation; otherwise it is automatically calculated. Parameters include coordinates, normal vector, index, parameter names, and parameter values. ```APIDOC ## BaseSurface.__init__ ### Description Creates a surface using linestring coordinates. The normal vector can be provided to specify orientation; otherwise it is automatically calculated. Parameters include coordinates, normal vector, index, parameter names, and parameter values. ### Method Constructor ### Signature `__init__(coords, normal_vector=None, index=None, param_names=None, params=None)` ### 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) ``` -------------------------------- ### TsGroundElement.get_param_weighted Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.pvground.TsGroundElement.html Gets a timeseries parameter for the ground element after weighting by surface length. ```APIDOC ## TsGroundElement.get_param_weighted ### Description Get timeseries parameter for the ground element, after weighting by surface length. ### Method Method ### Signature `get_param_weighted(param)` ### Parameters - **param**: The parameter to retrieve, weighted by surface length. ### Returns Timeseries parameter weighted by surface length. ``` -------------------------------- ### IsotropicOrdered.get_summed_components Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.irradiance.models.IsotropicOrdered.html Gets the sum of irradiance components for the irradiance model, either absorbed or only incident. ```APIDOC ## IsotropicOrdered.get_summed_components ### Description Gets the sum of irradiance components for the irradiance model, either absorbed or only incident. ### Parameters - **pvarray** (OrderedPVArray) - The PV array - **absorbed** (bool, optional) - If True, return absorbed components; otherwise incident ### Returns - Summed irradiance components ``` -------------------------------- ### ShadeCollection.__init__ Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.base.ShadeCollection.html Constructor for the ShadeCollection class. ```APIDOC ## ShadeCollection.__init__ ### Description Initializes a shade collection with a list of PV surfaces, an optional shading status, and optional parameter names. ### Method Constructor ### Signature `__init__(list_surfaces=None, shaded=None, param_names=None)` ### Parameters - **list_surfaces** (list, optional) - List of `PVSurface` objects. Default is None. - **shaded** (bool, optional) - Shading status of the collection. If not specified, derived from the list of surfaces. Default is None. - **param_names** (list of str, optional) - Names of the surface parameters (e.g., reflectivity, total incident irradiance, temperature). Default is None. ### Returns None ``` -------------------------------- ### TsShadeCollection.get_param_ww Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.geometry.timeseries.TsShadeCollection.html Gets a timeseries parameter from the collection with weight, i.e., after multiplying by the surface lengths. ```APIDOC ## TsShadeCollection.get_param_ww ### Description Gets a timeseries parameter from the collection with weight, i.e., after multiplying by the surface lengths. ### Method Method ### Signature `get_param_ww(param)` ### Parameters - **param** (str) - Required - The name of the parameter to retrieve. ### Returns The weighted timeseries parameter value. ``` -------------------------------- ### BaseModel.__init__() Source: https://solarfactors.readthedocs.io/en/latest/developer/generated/pvfactors.irradiance.base.BaseModel.html Initializes a new instance of the BaseModel class. ```APIDOC ## BaseModel.__init__() ### Description Initializes a new instance of the BaseModel class. ### Method Constructor ### Signature `__init__()` ### Parameters None ### Returns None ### Example ```python model = BaseModel() ``` ```