RuntimeWarning: divide by zero encountered in log when using pvlib

Matt Friend

I'm using PVLib to model a PV system. I'm pretty new to coding and Python, and this is my first time using PVLib, so not surprisingly I've hit some difficulties.

Specifically, I've got created the following code using the extensive readthedocs examples at http://pvlib-python.readthedocs.io/en/latest/index.html

import pandas as pd
import numpy as np
from numpy import isnan
import datetime
import pytz

# pvlib imports
import pvlib
from pvlib.forecast import GFS, NAM, NDFD, HRRR, RAP
from pvlib.pvsystem import PVSystem, retrieve_sam
from pvlib.modelchain import ModelChain

# set location (Royal Greenwich Observatory, London, UK)
latitude, longitude, tz = 51.4769, 0.0005, 'Europe/London'

# specify time range.
start = pd.Timestamp(datetime.date.today(), tz=tz)
end = start + pd.Timedelta(days=5)
periods = 8 # number of periods that the GFS model and/or the model chain allows us to forecast power output.

# specify what irradiance variables we want
irrad_vars = ['ghi', 'dni', 'dhi']

# Use Global Forecast System model. The GFS is the US model that provides forecasts for the entire globe.
fx_model = GFS() # note: gives output in 3-hourly intervals

# retrieve data in processed format (convert temps from Kelvin to Celsius, combine elements of wind speed, complete irradiance data)
# Returns pandas.DataFrame object
fx_data = fx_model.get_processed_data(latitude, longitude, start, end)

# load module and inverter specifications
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter')

module = sandia_modules['SolarWorld_Sunmodule_250_Poly__2013_'] 
inverter = cec_inverters['ABB__PVI_3_0_OUTD_S_US_Z_M_A__240_V__240V__CEC_2014_'] 

# model a fixed system in the UK. 10 strings of 250W panels, with 40 panels per string. Gives a nominal 100kW array
system = PVSystem(module_parameters=module, inverter_parameters=inverter, modules_per_string=40, strings_per_inverter=10)

# use a ModelChain object to calculate modelling intermediates
mc = ModelChain(system, fx_model.location, orientation_strategy='south_at_latitude_tilt')

# extract relevant data for model chain
mc.run_model(fx_data.index, weather=fx_data)

# OTHER CODE AFTER THIS TO DO SOMETHING WITH THE DATA

Having used a lot of print() statements in the console to debug, I can see that at the final line

mc.run_model(fx_data.index....

I get the following error:

/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/pvlib/pvsystem.py:1317: 
RuntimeWarning: divide by zero encountered in log
  module['Voco'] + module['Cells_in_Series']*delta*np.log(Ee) +
/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/pvlib/pvsystem.py:1323: 
RuntimeWarning: divide by zero encountered in log
  module['C3']*module['Cells_in_Series']*((delta*np.log(Ee)) ** 2) +

As a result, when I then go on to look at the ac_power outputs, I get what looks like erroneous data (every hour with a forecast that is not NaN = 3000 W).

I'd really appreciate any help you can give as I don't know what's causing it. Maybe I'm specifying the system incorrectly?

Thanks, Matt

Will Holmgren

I think the warnings you're seeing are ok to ignore. A handful of pvlib algorithms spit out warnings due to things like 0 values at night.

I think your problem with the non-NaN values is unrelated to the warnings. Study the other modeling results (stored as mc attributes -- see documentation and source code) to see if you can track down the source of your problem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

RuntimeWarning: divide by zero encountered in log

From Dev

Numpy RuntimeWarning: divide by zero encountered in log10

From Dev

"Divide by zero encountered in log" when not dividing by zero

From Dev

python divide by zero encountered in log - logistic regression

From Dev

python divide by zero encountered in log - logistic regression

From Dev

How to avoid "RuntimeWarning: invalid value encountered in divide" in NumPy?

From Dev

Warning of divide by zero encountered in log2 even after filtering out negative values

From Dev

RuntimeWarning: Divide by Zero error: How to avoid? PYTHON, NUMPY

From Dev

SQL Server Divide by zero error encountered COALESCE()

From Dev

Stored procedure is working fine. But when use in SSRS report, I hit an error - Divide by zero error encountered

From Dev

Python numpy.corrcoef() RuntimeWarning: invalid value encountered in true_divide c /= stddev[:, None]

From Dev

Why cant I get rid of RuntimeWarning: invalid value encountered in true_divide

From Dev

Divide by zero exception using awk

From Dev

When is a divide by zero not a divide by zero? A puzzle in the debugger (static variable issues)

From Dev

scipy curve_fit error: divide by zero encountered

From Dev

divide by zero encountered in double_scalars for derivative calculations

From Dev

scipy curve_fit error: divide by zero encountered

From Dev

Divide by zero encountered in python 2 but works on python 3

From Dev

What happens when I divide by zero?

From Dev

Divide column A when Greater than Zero

From Dev

Batch file returns "divide by zero error" only when run using Task Scheduler

From Dev

RuntimeWarning: invalid value encountered in arccos

From Dev

Allow for divide by zero to = zero

From Dev

RuntimeWarning: overflow encountered in ulong_scalars

From Dev

How to deal with "divide by zero" with pandas dataframes when manipulating columns?

From Dev

why there is no ArithmeticException( divide by zero) when both values are double?

From Dev

why there is no ArithmeticException( divide by zero) when both values are double?

From Dev

prevent divide by zero when both values are obtained from a calculation

From Dev

SQL Divide by Zero Error

Related Related

  1. 1

    RuntimeWarning: divide by zero encountered in log

  2. 2

    Numpy RuntimeWarning: divide by zero encountered in log10

  3. 3

    "Divide by zero encountered in log" when not dividing by zero

  4. 4

    python divide by zero encountered in log - logistic regression

  5. 5

    python divide by zero encountered in log - logistic regression

  6. 6

    How to avoid "RuntimeWarning: invalid value encountered in divide" in NumPy?

  7. 7

    Warning of divide by zero encountered in log2 even after filtering out negative values

  8. 8

    RuntimeWarning: Divide by Zero error: How to avoid? PYTHON, NUMPY

  9. 9

    SQL Server Divide by zero error encountered COALESCE()

  10. 10

    Stored procedure is working fine. But when use in SSRS report, I hit an error - Divide by zero error encountered

  11. 11

    Python numpy.corrcoef() RuntimeWarning: invalid value encountered in true_divide c /= stddev[:, None]

  12. 12

    Why cant I get rid of RuntimeWarning: invalid value encountered in true_divide

  13. 13

    Divide by zero exception using awk

  14. 14

    When is a divide by zero not a divide by zero? A puzzle in the debugger (static variable issues)

  15. 15

    scipy curve_fit error: divide by zero encountered

  16. 16

    divide by zero encountered in double_scalars for derivative calculations

  17. 17

    scipy curve_fit error: divide by zero encountered

  18. 18

    Divide by zero encountered in python 2 but works on python 3

  19. 19

    What happens when I divide by zero?

  20. 20

    Divide column A when Greater than Zero

  21. 21

    Batch file returns "divide by zero error" only when run using Task Scheduler

  22. 22

    RuntimeWarning: invalid value encountered in arccos

  23. 23

    Allow for divide by zero to = zero

  24. 24

    RuntimeWarning: overflow encountered in ulong_scalars

  25. 25

    How to deal with "divide by zero" with pandas dataframes when manipulating columns?

  26. 26

    why there is no ArithmeticException( divide by zero) when both values are double?

  27. 27

    why there is no ArithmeticException( divide by zero) when both values are double?

  28. 28

    prevent divide by zero when both values are obtained from a calculation

  29. 29

    SQL Divide by Zero Error

HotTag

Archive