Ошибка при использовании метода PVlib с именем "m c .run_model (forecast_data);" - PullRequest
0 голосов
/ 13 февраля 2020

Привет! Я работаю над моделированием массива PV с помощью PVlib, но когда я получаю доступ к данным ModelChain, которые я создаю, я получаю ошибку.

TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')

Я знаю, что эта строка вызывает ошибку:

# extract relevant data for model chain
mc.run_model(forecast_data);

Остальная часть моего кода ниже. Спасибо за помощь !!

# built-in python modules
import datetime
import inspect
import os
import pytz

# scientific python add-ons
import numpy as np
import pandas as pd

# plotting
# first line makes the plots appear in the notebook
%matplotlib inline 
import matplotlib.pyplot as plt
import matplotlib as mpl

#import the pvlib library
from pvlib import solarposition,irradiance,atmosphere,pvsystem
from pvlib.forecast import GFS
from pvlib.modelchain import ModelChain

pd.set_option('display.max_rows', 500)
# Choose a location.
# UH Campus Varney Circle
latitude, longitude, tz = 21.300268, -157.818044, 'Pacific/Honolulu'
# specify time range.
# start = pd.Timestamp(datetime.date.today(), tz=tz)
pacific = pytz.timezone('Etc/GMT+10')
# print(pacific)
# datetime.datetime(year, month, day, hour, minute, second, microsecond, tzinfo)
start2 = pd.Timestamp(datetime.datetime(2020, 2, 13, 12, 0, 0, 0, pacific))
# print(start)
# print(start2)
# print(datetime.date.today())

end = start2 + pd.Timedelta(days=1.5)
# Define forecast model
fm = GFS()

# get data from location specified above
forecast_data = fm.get_processed_data(latitude, longitude, start2, end)
# print(forecast_data)
# resampled_data = data.resample('15min').interpolate()
forecast_data = forecast_data.resample('15min').interpolate()
# print(forecast_data)
# Start to build the PV system
# input the PV modules used in system

modules = pvsystem.retrieve_sam('CECMod')
module = modules.Zytech_Solar_ZT320P #PTC = 290 W
# modules = pvsystem.retrieve_sam('SandiaMod')
# print(modules)
# module = modules.Canadian_Solar_CS6X_300M__2013_
# module = modules.Suniva_OPT300_72_4_100__2013_
# print(module)

# input the inverters used
# inverters = pvsystem.retrieve_sam('sandiainverter')
# inverter = inverters['iPower__SHO_5_2__240V_']
inverters = pvsystem.retrieve_sam('adrinverter')
inverter = inverters['Renesola_Zhejiang__Replus_12000TL3B_US__277V__277V__CEC_2013_']
# print(inverter)
# pvlib.pvsystem.PVSystem(surface_tilt=0, surface_azimuth=180, albedo=None, surface_type=None, module=None, module_type='glass_polymer', module_parameters=None, temperature_model_parameters=None, modules_per_string=1, strings_per_inverter=1, inverter=None, inverter_parameters=None, racking_model='open_rack', losses_parameters=None, name=None, **kwargs)

# surface_azimuth = 0 for north, 90 for east, 180 for south, 270 for west
system = pvsystem.PVSystem(surface_tilt=0, surface_azimuth=180, albedo='urban', surface_type='urban', module=module, module_parameters= module, temperature_model_parameters=None, modules_per_string= 10, strings_per_inverter=3, inverter=inverter, inverter_parameters=inverter, racking_model='open_rack', losses_parameters=None, name=None)

# system = pvsystem.PVSystem(surface_tilt=0, surface_azimuth=180, albedo=None, surface_type=None, module=sandia_module, module_parameters= None, temperature_model_parameters=None, modules_per_string= 12, strings_per_inverter=12, inverter=sapm_inverter, inverter_parameters=None, racking_model='open_rack', losses_parameters=None, name=None)

# use a ModelChain object to calculate modeling intermediates
mc = ModelChain(system, fm.location, dc_model=None ,ac_model=None, aoi_model='physical', spectral_model='no_loss', temperature_model='sapm')
# mc = ModelChain(system, fm.location, dc_model=None ,ac_model=None)

# extract relevant data for model chain
mc.run_model(forecast_data);

Полная трассировка стека:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
//anaconda3/lib/python3.7/site-packages/pandas/core/ops.py in na_op(x, y)
   1504         try:
-> 1505             result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
   1506         except TypeError:

//anaconda3/lib/python3.7/site-packages/pandas/core/computation/expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
    207     if use_numexpr:
--> 208         return _evaluate(op, op_str, a, b, **eval_kwargs)
    209     return _evaluate_standard(op, op_str, a, b)

//anaconda3/lib/python3.7/site-packages/pandas/core/computation/expressions.py in _evaluate_numexpr(op, op_str, a, b, truediv, reversed, **eval_kwargs)
    122     if result is None:
--> 123         result = _evaluate_standard(op, op_str, a, b)
    124 

//anaconda3/lib/python3.7/site-packages/pandas/core/computation/expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
     67     with np.errstate(all='ignore'):
---> 68         return op(a, b)
     69 

TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-39-72adf11f4810> in <module>
     12 
     13 # extract relevant data for model chain
---> 14 mc.run_model(forecast_data);

~/Downloads/pvlib-python-0.7.1/pvlib/modelchain.py in run_model(self, weather, times)
    941                           'is used for times.', pvlibDeprecationWarning)
    942 
--> 943         self.prepare_inputs(weather)
    944         self.aoi_model()
    945         self.spectral_model()

~/Downloads/pvlib-python-0.7.1/pvlib/modelchain.py in prepare_inputs(self, weather, times)
    902             self.weather['dhi'],
    903             airmass=self.airmass['airmass_relative'],
--> 904             model=self.transposition_model)
    905 
    906         if self.weather.get('wind_speed') is None:

~/Downloads/pvlib-python-0.7.1/pvlib/pvsystem.py in get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra, airmass, model, **kwargs)
    315                                                model=model,
    316                                                albedo=self.albedo,
--> 317                                                **kwargs)
    318 
    319     def get_iam(self, aoi, iam_model='physical'):

~/Downloads/pvlib-python-0.7.1/pvlib/irradiance.py in get_total_irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra, airmass, albedo, surface_type, model, model_perez, **kwargs)
    361 
    362     poa_ground_diffuse = get_ground_diffuse(surface_tilt, ghi, albedo,
--> 363                                             surface_type)
    364     aoi_ = aoi(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth)
    365     irrads = poa_components(aoi_, dni, poa_sky_diffuse, poa_ground_diffuse)

~/Downloads/pvlib-python-0.7.1/pvlib/irradiance.py in get_ground_diffuse(surface_tilt, ghi, albedo, surface_type)
    553         albedo = SURFACE_ALBEDOS[surface_type]
    554 
--> 555     diffuse_irrad = ghi * albedo * (1 - np.cos(np.radians(surface_tilt))) * 0.5
    556 
    557     try:

//anaconda3/lib/python3.7/site-packages/pandas/core/ops.py in wrapper(left, right)
   1581             rvalues = rvalues.values
   1582 
-> 1583         result = safe_na_op(lvalues, rvalues)
   1584         return construct_result(left, result,
   1585                                 index=left.index, name=res_name, dtype=None)

//anaconda3/lib/python3.7/site-packages/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
   1527         try:
   1528             with np.errstate(all='ignore'):
-> 1529                 return na_op(lvalues, rvalues)
   1530         except Exception:
   1531             if is_object_dtype(lvalues):

//anaconda3/lib/python3.7/site-packages/pandas/core/ops.py in na_op(x, y)
   1505             result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
   1506         except TypeError:
-> 1507             result = masked_arith_op(x, y, op)
   1508 
   1509         result = missing.fill_zeros(result, x, y, op_name, fill_zeros)

//anaconda3/lib/python3.7/site-packages/pandas/core/ops.py in masked_arith_op(x, y, op)
   1024         if mask.any():
   1025             with np.errstate(all='ignore'):
-> 1026                 result[mask] = op(xrav[mask], y)
   1027 
   1028     result, changed = maybe_upcast_putmask(result, ~mask, np.nan)

TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
...