Skip to content

bifacial.pvfactors expects arrays for surface_tilt and surface_azimuth inputs #1127

Closed
@cwhanse

Description

@cwhanse

The docstring for bifacial.pvfactors describes these two parameters:

    surface_azimuth: numeric
        Azimuth angle of the front surface of the PV modules, using pvlib's
        convention (deg)
    surface_tilt: numeric
        Tilt angle of the PV modules, going from 0 to 180 (deg)

Based on the docstring I would expect the function to run with e.g. surface_azimuth being a float. But it doesn't; it only runs when surface_azimuth is an array or Series of the same length as other time-dependent inputs. Providing surface_azimuth as a float yields IndexError: too many indices for array

Issue originally reported in #1125

To reproduce:

from datetime import datetime
import numpy as np
import pandas as pd
import pvlib


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)])

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
                      'gcr': 0.4,               # ground coverage ratio
                      }

pvfactor = pvlib.bifacial.pvfactors_timeseries(
    solar_azimuth=df_inputs['solar_azimuth'],
    solar_zenith=df_inputs['solar_zenith'],
    surface_azimuth=180, 
    surface_tilt=40, 
    axis_azimuth=0.0,
    timestamps=df_inputs.index, 
    dni=df_inputs['dni'],
    dhi=df_inputs['dhi'],
    gcr=2.0/7.0,
    pvrow_height=1,
    pvrow_width=7,
    albedo=0.2,
    n_pvrows=2,
    index_observed_pvrow=3,
    rho_front_pvrow=0.03,
    rho_back_pvrow=0.05,
    horizon_band_angle=15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions