- Posts: 1
PySAM Non-annual simulation yields different results based on selected hours
- Aziz
- Topic Author
Less
More
19 Jun 2023 09:16 #12236
by Aziz
PySAM Non-annual simulation yields different results based on selected hours was created by Aziz
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: [url] github.com/NREL/pysam/blob/main/Examples/NonAnnualSimulation.ipynb [/url].
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:
The weather file used is in the attachments. I am using Python 3.11.3 with nrel-pysam 4.1.0
Thanks!
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: [url] github.com/NREL/pysam/blob/main/Examples/NonAnnualSimulation.ipynb [/url].
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:
Code:
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!
Attachments:
Please Log in or Create an account to join the conversation.
- Paul Gilman
Less
More
- Posts: 5476
12 Jul 2023 15:46 #12317
by Paul Gilman
Replied by Paul Gilman on topic PySAM Non-annual simulation yields different results based on selected hours
Hi Aziz,
Many of SAM's performance models, including pvwattsv8, calculate the hour of year using this function , which assumes that the time series data starts at hour = 0.
For this reason, it is not possible to run the Pvwattsv8 module using weather data that does not start with Hour 0. Unfortunately, the module does not return a helpful message about this.
If you need to run the module for a slice of time steps that does not start with Hour 0 of the year, you can use dummy data for the time steps you don't need. For example, to get results for Hours 24-48, you can create an array with weather data for Hours 0-48 with dummy data for Hours 0-23, and then slice the output array to read the results you want from Hours 24-48.
Best regards,
Paul.
Many of SAM's performance models, including pvwattsv8, calculate the hour of year using this function , which assumes that the time series data starts at hour = 0.
For this reason, it is not possible to run the Pvwattsv8 module using weather data that does not start with Hour 0. Unfortunately, the module does not return a helpful message about this.
If you need to run the module for a slice of time steps that does not start with Hour 0 of the year, you can use dummy data for the time steps you don't need. For example, to get results for Hours 24-48, you can create an array with weather data for Hours 0-48 with dummy data for Hours 0-23, and then slice the output array to read the results you want from Hours 24-48.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
Moderators: Paul Gilman