- Posts: 16
How to write SamUL script to get spreadsheet of a year of hourly kWh
- Mary Knipe
- Topic Author
Less
More
10 Dec 2012 15:10 #1071
by Mary Knipe
How to write SamUL script to get spreadsheet of a year of hourly kWh was created by Mary Knipe
Hi,
I have successfully used the script below to obtain the estimated annual kWh for a list of sites in a csv file.
I would like to be able to get spreadsheet of a year of hourly kWh data for each site in the csv file. Is there a simple way to do this with the script so that I don't have to manually enter each site into the PV Watts model to get the data table after running the simulation.
Thank you,
Mary Knipe
My Script for annual kWh:
setactivecase("New PVWatts Case 1")
workdir = samdir() + "/samples"
outln("working folder: " + workdir)
input = open( workdir + "/input8tilt.csv", "r" )
if (not input)
outln("could not open input file")
exit
end
output = open( workdir + "/output8tilt.csv", "w" )
if (not output)
outln("could not open output file")
exit
end
write( output, "ApplicationNumber,lat,lon,enet,kWh, \n" )
declare buffer
readln(input, buffer)
while( readln( input, buffer ) )
cols = split( buffer, "," )
address = cols[0]
size = double(cols[1])
tilt = double(cols[4])
azimuth = double(cols[5])
derate = double(cols[6])
ApplicationNumber= string(cols[7])
declare weatherfile=""
weatherfile = "C:/SAM/2011.12.2/samples/my_tmy3_Whiteplainsfile.csv"
setinput( "climate.location", weatherfile )
setinput( "pvwatts.dcrate", size )
setinput( "pvwatts.tilt", tilt)
setinput( "pvwatts.azimuth", azimuth)
setinput( "pvwatts.derate", derate)
outln("Simulating location: " + address)
simulate()
declare lat=0, lon=0, enet=0,kWh=0
enet = getoutput("system.annual.e_net")
kWh = getoutput ("sv.annual_output")
outln("Nameplate Capacity kW: " + size)
outln("Net annual output: " + kWh + "kWh")
outln("Application Number: " + ApplicationNumber)
write( output, ApplicationNumber + "," + lat + ","+ lon + ","+ enet + "," + kWh + "," + "\n")
end
close(input)
close(output)
' main script ends here
I have successfully used the script below to obtain the estimated annual kWh for a list of sites in a csv file.
I would like to be able to get spreadsheet of a year of hourly kWh data for each site in the csv file. Is there a simple way to do this with the script so that I don't have to manually enter each site into the PV Watts model to get the data table after running the simulation.
Thank you,
Mary Knipe
My Script for annual kWh:
setactivecase("New PVWatts Case 1")
workdir = samdir() + "/samples"
outln("working folder: " + workdir)
input = open( workdir + "/input8tilt.csv", "r" )
if (not input)
outln("could not open input file")
exit
end
output = open( workdir + "/output8tilt.csv", "w" )
if (not output)
outln("could not open output file")
exit
end
write( output, "ApplicationNumber,lat,lon,enet,kWh, \n" )
declare buffer
readln(input, buffer)
while( readln( input, buffer ) )
cols = split( buffer, "," )
address = cols[0]
size = double(cols[1])
tilt = double(cols[4])
azimuth = double(cols[5])
derate = double(cols[6])
ApplicationNumber= string(cols[7])
declare weatherfile=""
weatherfile = "C:/SAM/2011.12.2/samples/my_tmy3_Whiteplainsfile.csv"
setinput( "climate.location", weatherfile )
setinput( "pvwatts.dcrate", size )
setinput( "pvwatts.tilt", tilt)
setinput( "pvwatts.azimuth", azimuth)
setinput( "pvwatts.derate", derate)
outln("Simulating location: " + address)
simulate()
declare lat=0, lon=0, enet=0,kWh=0
enet = getoutput("system.annual.e_net")
kWh = getoutput ("sv.annual_output")
outln("Nameplate Capacity kW: " + size)
outln("Net annual output: " + kWh + "kWh")
outln("Application Number: " + ApplicationNumber)
write( output, ApplicationNumber + "," + lat + ","+ lon + ","+ enet + "," + kWh + "," + "\n")
end
close(input)
close(output)
' main script ends here
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
10 Dec 2012 15:55 #1072
by pgilman
Replied by pgilman on topic How to write SamUL script to get spreadsheet of a year of hourly kWh
Hi Mary,
The output variable system.hourly.e_net should be what you need. It is a 8,760 x 1 array that stores the hourly output values. The sum of the array elements should equal system.annual.e_net.
Best regards,
Paul.
The output variable system.hourly.e_net should be what you need. It is a 8,760 x 1 array that stores the hourly output values. The sum of the array elements should equal system.annual.e_net.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
Moderators: pgilman