I've started using PVLib a week ago and managed to forecast my PV-Yield inverter output.
import pandas as pd
import matplotlib.pyplot as plt
import datetime
import pvlib
from pvlib import pvsystem
from pvlib.forecast import GFS, NAM, NDFD, HRRR
import numpy as np
from pvlib.pvsystem import PVSystem, retrieve_sam
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
from pvlib.tracking import SingleAxisTracker
from pvlib.modelchain import ModelChain
if __name__ == '__main__':
# latitude, longitude, name, altitude, timezone
timeZone = "Europe/Brussels"
location = pvlib.location.Location(latitude=50.874, longitude=5.274, tz=timeZone, altitude=43+6, name='Alken')
# import the database
module_database = pvlib.pvsystem.retrieve_sam(name='CECMod') #https://github.com/NREL/SAM/blob/develop/deploy/libraries/CEC%20Modules.csv
module = module_database["Seraphim_Solar_USA_Manufacturing_Inc__SRP_365_6QA_WS_50"]
inverter_database = pvlib.pvsystem.retrieve_sam(name="cecinverter")
inverter = inverter_database["Huawei_Technologies_Co___Ltd___SUN2000_7_6KTL_USL0__240V_"]
temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass'] # check
mount_east = pvsystem.Array(pvsystem.FixedMount(surface_tilt=20, surface_azimuth=-83), module_parameters=module, modules_per_string=13, strings=1, temperature_model_parameters=temperature_model_parameters)
mount_south = pvsystem.Array(pvsystem.FixedMount(surface_tilt=20, surface_azimuth=97), module_parameters=module, modules_per_string=13, strings=1, temperature_model_parameters=temperature_model_parameters)
system_multi_array = pvsystem.PVSystem(arrays=[mount_east, mount_south], inverter_parameters=inverter)
weatherForecastModel = GFS(resolution="quarter", set_type="best") # Global Forecast System (GFS) (27-28km)
start = pd.Timestamp(datetime.date.today(), tz=timeZone)
end = start + datetime.timedelta(days=1)
raw_data = weatherForecastModel.get_data(location.latitude, location.longitude, start, end)
data =raw_data
irrad_vars = ['ghi', 'dni', 'dhi']
data = weatherForecastModel.rename(data)
data['temp_air'] = weatherForecastModel.kelvin_to_celsius(data['temp_air'])
data['wind_speed'] = weatherForecastModel.uv_to_speed(data)
irrad_data = weatherForecastModel.cloud_cover_to_irradiance(data['total_clouds'])
data = data.join(irrad_data, how='outer')
data = data[weatherForecastModel.output_variables]
data = weatherForecastModel.process_data(raw_data)
data['precipitable_water'] = 0.1
print(data.columns)
PVSystemModel = ModelChain(system_multi_array, weatherForecastModel.location, aoi_model="no_loss")
print(system_multi_array)
print(PVSystemModel)
PVSystemModel.run_model(data)
PVSystemModel.results.ac.fillna(0).plot()
plt.ylim(0, None)
plt.ylabel('AC Power (W)')
plt.show()
I have a long road ahead to refine and extend the code. However, I have a few questions:
- Using CEC modules and inverters seems less straight forward than de scandia devices. The reason I used the CEC database is that I found the devices I needed. In this respect I am considering of defining my modules and inverters or are there other databases I can use which also include european devices?
- I had to bypass "precipitable_water" weather info. The documentation suggests that you can calculate this by using the gueymard94_pw model. However I need relative_humidity in the weather forecast which the GFS model does not provide. Any suggestions where to retrieve this?
- Are there any good european weather forecast services available?
Thanks in advance for your thoughts, Kind Regards,