Skip to content

pvwatts_ac raises ZeroDivisionError for scalar pdc=0, RuntimeWarning for array(0) input #675

Closed
@wholmgren

Description

@wholmgren

Describe the bug
pvwatts_ac raises ZeroDivisionError when called with pdc=0 scalar input. It raises RuntimeWarning and returns nan when called with array input.

To Reproduce
scalar:

pvsystem.pvwatts_ac(0., 100)

        # eta < 0 if zeta < 0.006. pac is forced to be >= 0 below. GH 541
>       eta = eta_inv_nom / eta_inv_ref * (-0.0162*zeta - 0.0059/zeta + 0.9858)
E       ZeroDivisionError: float division by zero

pvlib/pvsystem.py:2971: ZeroDivisionError

array:

In [50]: pvlib.pvsystem.pvwatts_ac(np.array([0]), 1.)
/Users/holmgren/miniconda3/envs/sfacore/lib/python3.7/site-packages/pvlib/pvsystem.py:2971: RuntimeWarning: divide by zero encountered in true_divide
  eta = eta_inv_nom / eta_inv_ref * (-0.0162*zeta - 0.0059/zeta + 0.9858)
/Users/holmgren/miniconda3/envs/sfacore/lib/python3.7/site-packages/pvlib/pvsystem.py:2973: RuntimeWarning: invalid value encountered in multiply
  pac = eta * pdc
/Users/holmgren/miniconda3/envs/sfacore/lib/python3.7/site-packages/pvlib/pvsystem.py:2974: RuntimeWarning: invalid value encountered in minimum
  pac = np.minimum(pac0, pac)
/Users/holmgren/miniconda3/envs/sfacore/lib/python3.7/site-packages/pvlib/pvsystem.py:2975: RuntimeWarning: invalid value encountered in maximum
  pac = np.maximum(0, pac)     # GH 541
Out[50]: array([nan])

Expected behavior
The function should return 0s in the appropriate type.

Versions:

  • pvlib.__version__: 0.6.1+7.g8658205.dirty
  • pandas.__version__: 0.24.1
  • python: 3.7

Additional context
In #541 we fixed behavior close to, but not at, 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsolarfx2DOE SETO Solar Forecasting 2 / Solar Forecast Arbiter

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions