RuntimeWarning:使用pvlib时在日志中遇到的除以零

时间:2017-11-29 13:29:20

标签: python-3.x pvlib

我正在使用PVLib来建模光伏系统。我是编码和Python的新手,这是我第一次使用PVLib,所以我遇到了一些困难并不奇怪。

具体来说,我使用http://pvlib-python.readthedocs.io/en/latest/index.html

中广泛的readthedocs示例创建了以下代码
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

在控制台中使用了很多print()语句进行调试,我可以在最后一行看到

mc.run_model(fx_data.index....

我收到以下错误:

/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) +

结果,当我继续查看ac_power输出时,我得到的是错误的数据(每小时预测不是NaN = 3000 W)。

我真的很感激你能给予的任何帮助,因为我不知道是什么导致了它。也许我在错误地指定系统?

谢谢,马特

1 个答案:

答案 0 :(得分:1)

我认为你看到的警告可以忽略不计。少数pvlib算法会因夜间0值等问题而吐出警告。

我认为您对非NaN值的问题与警告无关。研究其他建模结果(存储为mc属性 - 请参阅文档和源代码),看看是否可以追踪问题的根源。