Я пытаюсь переслать временные ряды в ModelChain.
Код выглядит так:
import pandas as pd
import pvlib
from pvlib.pvsystem import PVSystem
from pvlib.location import Location
from pvlib.modelchain import ModelChain
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']
CEC_modules = pvlib.pvsystem.retrieve_sam('CECMod')
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter')
CEC_module = CEC_modules['SunPower_SPR_E20_327_COM']
cec_inverter = cec_inverters['Fronius_International_GmbH__Fronius_Symo_10_0_3_208_240__240V_']
location = Location(latitude=14.35, longitude=47.97, altitude=300,
name='xy',)
system = PVSystem(surface_tilt=20, surface_azimuth=160,
....)
mc = ModelChain(system, location, .....,
spectral_model='no_loss', #spectral model 'no loss' otherwise error
temperature_model='sapm', losses_model='no_loss')
df = pd.read_csv('test.csv', parse_dates=['Time'], sep=";",)
df.fillna(0, inplace=True)
Timeseries = df['Time']
print(Timeseries)
print(df)
print(df.dtypes)
print(type(Timeseries))
weather = pd.DataFrame([df['Irradiation Horizontal (W/m2) 15min avg.'],
df['Irradiation Diffuse (W/m2) 15min avg.'],
df['Direct Normal Irradiation (W/m²) 15 min avg.'],
df['Temperature Ambient (C)'],
df['Wind Speed (Meteo) (m/s)']],
columns=['ghi', 'dhi', 'dni', 'temp_air', 'wind_speed'],
index=[pd.DatetimeIndex(Timeseries, tz='Europe/Vienna')])
#forwarding the dates from the excel data doesn't work
mc.run_model(weather);
Spyder (Python 3.7) показывает эта ошибка:
0 2020-01-23 07:30:00
1 2020-01-23 07:45:00
......
36 2020-01-23 16:30:00
37 2020-01-23 16:45:00
Name: Time, dtype: datetime64[ns]
<class 'pandas.core.series.Series'>
Time datetime64[ns]
Irradiation Horizontal (W/m2) 15min avg. object
Irradiation Diffuse (W/m2) 15min avg. object
Direct Normal Irradiation (W/m²) 15 min avg. object
Temperature Ambient (C) object
Wind Speed (Meteo) (m/s) object
dtype: object
Traceback (most recent call last):
File "<ipython-input-157-e72efaf102a2>", line 1, in <module>
runfile('C:/Users/maki4/Python/files/timestamp problem.py', wdir='C:/Users/maki4/Python/files')
File "C:\Users\maki4\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\maki4\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/maki4/Python/files/timestamp problem.py", line 59, in <module>
index=[pd.DatetimeIndex(Timeseries, tz='Europe/Vienna')])
File "C:\Users\maki4\Anaconda3\lib\site-packages\pandas\core\frame.py", line 462, in __init__
mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype)
File "C:\Users\maki4\Anaconda3\lib\site-packages\pandas\core\internals\construction.py", line 87, in arrays_to_mgr
return create_block_manager_from_arrays(arrays, arr_names, axes)
File "C:\Users\maki4\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 1699, in create_block_manager_from_arrays
construction_error(len(arrays), arrays[0].shape, axes, e)
File "C:\Users\maki4\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 1719, in construction_error
"Shape of passed values is {0}, indices imply {1}".format(passed, implied)
ValueError: Shape of passed values is (5, 5), indices imply (38, 5)
Ошибка выглядит так, как будто с форматом таблицы что-то не так ...
Я был бы очень признателен за любую помощь или рекомендацию, чтобы исправить проблема.
С уважением, Маркус