Hi,
I am trying to speed up simulating solar panel generation by using a subset of the hours in weather file.
I tried to follow the example shown here:
github.com/NREL/pysam/blob/main/Examples/NonAnnualSimulation.ipynb
.
However, I ran into an issue where the PVWatts model yields different results depending on the selection of hours I use.
As an example, I downloaded a weather file from the NSRDB and tried the following simulations to demonstrate the issue:
When performing a simulation with every hour in the weather file, the models works fine.
When I perform a simulation for the first 96 hours in the weather file, the models also works perfectly.
However, when I perform a simulation from hour 24 to hour 96 in the weather file, the models yields different results as the output from hour 72 to hour 96 appears to be missing.
Also, when performing a simulation from hour 24 to hour 48, the output of the simulation is zero for every hour.
What is the cause of this behavior?
Here the code I used to generate the plots:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import PySAM.Pvwattsv8 as pv
def simulate_hourly_generation(capacity, tilt, azimuth, weather_data, weather_meta_data):
solar_resource_data = {
"tz": weather_meta_data["Time Zone"][0],
"elev": weather_meta_data["Elevation"][0],
"lat": weather_meta_data["Latitude"][0],
"lon": weather_meta_data["Longitude"][0],
"year": tuple(weather_data["Year"]),
"month": tuple(weather_data["Month"]),
"day": tuple(weather_data["Day"]),
"hour": tuple(weather_data["Hour"]),
"minute": tuple(weather_data["Minute"]),
"dn": tuple(weather_data["DNI"]),
"df": tuple(weather_data["DHI"]),
"gh": tuple(weather_data["GHI"]),
"wspd": tuple(weather_data["Wind Speed"]),
"tdry": tuple(weather_data["Temperature"]),
}
pv_system = pv.default("PVWattsNone")
pv_system.SystemDesign.system_capacity = capacity
pv_system.SystemDesign.tilt = tilt
pv_system.SystemDesign.azimuth = azimuth
pv_system.SolarResource.assign({"solar_resource_data": solar_resource_data})
pv_system.AdjustmentFactors.assign({'constant': 0})
pv_system.execute(0)
panel_gen = np.array(pv_system.export()["Outputs"]["gen"])
return panel_gen
weather_file_data = pd.read_csv('weather.csv', skiprows=2)
weather_file_meta_data = pd.read_csv('weather.csv', nrows=1)
plt.plot(simulate_hourly_generation(0.3, 0, 180, weather_file_data, weather_file_meta_data))
plt.title('Hour 0 to Hour 8760')
plt.show()
plt.plot(simulate_hourly_generation(0.3, 0, 180, weather_file_data[:96], weather_file_meta_data))
plt.title('Hour 0 to Hour 96')
plt.show()
plt.plot(simulate_hourly_generation(0.3, 0, 180, weather_file_data[24:96], weather_file_meta_data))
plt.title('Hour 24 to Hour 96')
plt.show()
plt.plot(simulate_hourly_generation(0.3, 0, 180, weather_file_data[24:48], weather_file_meta_data))
plt.title('Hour 24 to Hour 48')
plt.show()
The weather file used is in the attachments. I am using Python 3.11.3 with nrel-pysam 4.1.0
Thanks!