- Posts: 2
import PySAM.PySSC as pssc
import PySAM.Pvwattsv8 as pv8
from datetime import datetime, timedelta
start_time = datetime(2022, 1, 1)
time_delta = timedelta(hours=1)
num_hours = 8760
solar_resource_data = {
"lat": info["Latitude"][0],
"lon": info["Longitude"][0],
"tz": info["Time Zone"][0],
"elev": info["Elevation"][0],
"year": [],
"month": [],
"day": [],
"hour": [],
"minute": [30] * num_hours,
# "dn": list(site_generation["DNI"]),
# "df": list(site_generation["DHI"]),
# "gh": list(site_generation["GHI"]),
# "wspd": list(site_generation["Wind Speed"]),
# "tdry": list(site_generation["Temperature"])
"dn": [500]*num_hours, # Example values, replace with actual data
"df": [100]*num_hours, # Example values, replace with actual data
"gh": [600]*num_hours, # Example values, replace with actual data
"wspd": [3]*num_hours, # Example values, replace with actual data
"tdry": [20]*num_hours # Example values, replace with actual data
}
for hour in range(num_hours):
current_time = start_time + time_delta * hour
solar_resource_data["year"].append(current_time.year)
solar_resource_data["month"].append(current_time.month)
solar_resource_data["day"].append(current_time.day)
solar_resource_data["hour"].append(current_time.hour)
pv_model = pv8.new()
pv_dat = pssc.dict_to_ssc_table(pvwatts_json, "pvwattsv8")
pv_model = pv8.wrap(pv_dat)
pv_model.SolarResource.assign({"solar_resource_data": solar_resource_data})
pv_model.execute()
pv_model.Outputs.dc
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Pvwattsv8.SolarResource.assign({'solar_resource_data': solar_resource_data_var})
Please Log in or Create an account to join the conversation.
import PySAM.Pvwattsv8 as pv8
import json
from datetime import datetime, timedelta
start_time = datetime(2022, 1, 1)
time_delta = timedelta(hours=1)
num_hours = 8760
solar_resource_data = {
"lat": 0,
"lon": 0,
"tz": 0,
"elev": 0,
"year": ,
"month": ,
"day": ,
"hour": ,
"minute": [30] * num_hours,
# "dn": list(site_generation["DNI"]),
# "df": list(site_generation["DHI"]),
# "gh": list(site_generation["GHI"]),
# "wspd": list(site_generation["Wind Speed"]),
# "tdry": list(site_generation["Temperature"])
"dn": [500]*num_hours, # Example values, replace with actual data
"df": [100]*num_hours, # Example values, replace with actual data
"gh": [600]*num_hours, # Example values, replace with actual data
"wspd": [3]*num_hours, # Example values, replace with actual data
"tdry": [20]*num_hours # Example values, replace with actual data
}
for hour in range(num_hours):
current_time = start_time + time_delta * hour
solar_resource_data["year"].append(current_time.year)
solar_resource_data["month"].append(current_time.month)
solar_resource_data["day"].append(current_time.day)
solar_resource_data["hour"].append(current_time.hour)
pv_model = pv8.default("PVWattsNone") # see https://nrel-pysam.readthedocs.io/en/main/sam-configurations.html
print("== Test with no weather data ==")
# model will fail because defaults do not include weather
verbose_simulation = 1
try:
pv_model.execute(verbose_simluation)
except:
print("\npv_model failed")
print("\n== Test with constructed data ==");
# assign resource data constructed above
pv_model.SolarResource.assign({"solar_resource_data": solar_resource_data})
print("\nDNI from inputs:")
print(pv_model.SolarResource.solar_resource_data["dn"][0:23])
pv_model.execute()
print("\nDC output:")
print(pv_model.Outputs.dc[0:23])
print("\nDNI from outputs:")
print(pv_model.Outputs.dn[0:23])
print("\n== Test with data from JSON ==");
with open( 'example.json', 'r') as f:
pv_inputs = json.load( f )
print("\nDNI from inputs:")
print(pv_model.SolarResource.solar_resource_data["dn"][0:23])
pv_model.execute()
print("\nDC output:")
print(pv_model.Outputs.dc[0:23])
print("\nDNI from outputs:")
print(pv_model.Outputs.dn[0:23])
Please Log in or Create an account to join the conversation.
NREL is a national laboratory of the U.S. Department of Energy, Office of Energy Efficiency and Renewable Energy, operated by the Alliance for Sustainable Energy, LLC.
NREL is a national laboratory of the U.S. Department of Energy, Office of Energy Efficiency and Renewable Energy, operated by the Alliance for Sustainable Energy, LLC.