Example #1
0
	file.close()
	return dataOut

def parseEx_line(string, col):
  #split this string using whitespace as delimiter
  data = [int(n) for n in string.split()] 
  return data[col-1] #return only the first three values


fileName = "dirNormals.txt"
number_of_header_lines = 2
columnNumber = 4 #the column that we want to extract
dirNormalData = parseEx_file(fileName, number_of_header_lines, columnNumber)


# Since I've chosen a file that has complete data, i.e. 8760 hours in a year, I can easily
# extract out the direct normal for any (whole) hour of the year
import solarGeom as sg

date = "3/23"
h = "13:00"
day = sg.calc_dayOfYear(date)
hour = sg.calc_hourDecimal(h)
hourYear = (day-1)*24 + int(hour)-1
print "Direct Normal Irradiation on "+date+" at "+h+" is "+str(dirNormalData[hourYear])+" w/m^2"

# we don't have data that gives us continuous measurement between hours.  You can either decide
# to just take the data on the whole hour -- i.e. 13:30 has the same data as at 13:00 -- or
# you can interpolate the data

Example #2
0
#longitude = 143.28
#timezone = 9.0

latitude = 45.36
longitude = -79.20
timezone = -5.0

dateStart = "1/1"
dateEnd = "12/31"
dayStart = sg.calc_dayOfYear(dateStart)
dayEnd = sg.calc_dayOfYear(dateEnd)

startTime= "7:00"
endTime = "19:30"

hourStart = sg.calc_hourDecimal(startTime)
hourEnd = sg.calc_hourDecimal(endTime)
#print hourStart, hourEnd
#print sg.calc_solarAngles(latitude, longitude, timezone, dayNow, hourStart)

N = 20
R = 20

#for i in range(N+1):
#	sun = sg.calc_sunVector(latitude, longitude, timezone, dayStart, hourStart+i*(hourEnd-hourStart)/N)
#	if sun[2] > 0:
#		sun[:] = [x*R for x in sun]
#		rs.AddPoint(sun)
for dayNow in range(dayStart, dayEnd, 3):
	for i in range(N+1):
		sun = sg.calc_sunVector(latitude, longitude, timezone, dayNow, hourStart+i*(hourEnd-hourStart)/N)
Example #3
0
#longitude = 143.28
#timezone = 9.0

latitude = 45.36
longitude = -79.20
timezone = -5.0

dateStart = "1/1"
dateEnd = "12/31"
dayStart = sg.calc_dayOfYear(dateStart)
dayEnd = sg.calc_dayOfYear(dateEnd)

startTime = "7:00"
endTime = "19:30"

hourStart = sg.calc_hourDecimal(startTime)
hourEnd = sg.calc_hourDecimal(endTime)
#print hourStart, hourEnd
#print sg.calc_solarAngles(latitude, longitude, timezone, dayNow, hourStart)

N = 20
R = 20

#for i in range(N+1):
#	sun = sg.calc_sunVector(latitude, longitude, timezone, dayStart, hourStart+i*(hourEnd-hourStart)/N)
#	if sun[2] > 0:
#		sun[:] = [x*R for x in sun]
#		rs.AddPoint(sun)
for dayNow in range(dayStart, dayEnd, 3):
    for i in range(N + 1):
        sun = sg.calc_sunVector(latitude, longitude, timezone, dayNow,