### reset
plt.close()

# calculate solar angle of incidence for a summer day in Golden, CO
longitude = 105.2
stdmeridian = 105
latitude = 39.75
x = []
east_wall_normal_from_north = 90
east_theta = []
east_az = []
alt = []
for hour in range(0,24): # gives zero-based hours as expected in the datetime constructor
	x.append(hour)
	dt = datetime(2001, 6, 21, hour, 00, 00)
	east_az.append(solar.wallAzimuthAngle(dt, True, longitude, stdmeridian, latitude, east_wall_normal_from_north).degrees)
	east_theta.append(solar.solarAngleOfIncidence(dt, True, longitude, stdmeridian, latitude, east_wall_normal_from_north).degrees)
	alt.append(solar.altitudeAngle(dt, True, longitude, stdmeridian, latitude).degrees)

plt.plot(x, alt,        'r', label='Solar Altitude Angle')
plt.plot(x, east_az,    'g', label='East Wall Azimuth Angle')
plt.plot(x, east_theta, 'b', label='East Wall Incidence Angle')
plt.xlim([0,23])
plt.ylim([-90,180])
plt.suptitle("Wall Solar Incidence Angles", fontsize=14, fontweight='bold')
plt.xlabel("Hour of Day -- Clock Time")
plt.ylabel("Angle [degrees]")
plt.grid(True, axis='both')
plt.legend()
plt.savefig(os.path.join(os.path.dirname(__file__), '..', '..', 'SolarCalculations.wiki/DemoSolarAnglesSolarIncidence.png'))
	mywriter = csv.writer(csvfile)
	mywriter.writerow(['Hour', 'Hour Angle', 'Solar Altitude', 'Solar Azimuth'])
	for hour in range(0,24): # gives zero-based hours as expected in the datetime constructor
		x = hour
		dt = datetime(2001, 12, 21, hour, 30, 00)
		thour = solar.hourAngle(dt, False, longitude, stdmeridian).degrees
		altitude = solar.altitudeAngle(dt, False, longitude, stdmeridian, latitude).degrees
		azimuth = solar.solarAzimuthAngle(dt, False, longitude, stdmeridian, latitude).degrees
		mywriter.writerow([x, -thour, altitude, azimuth])

with open('/tmp/compare_summer_angles_library.csv', 'w') as csvfile:
	mywriter = csv.writer(csvfile)
	mywriter.writerow(['Hour', 'Hour Angle', 'Solar Altitude', 'Solar Azimuth'])
	for hour in range(0,24): # gives zero-based hours as expected in the datetime constructor
		x = hour
		dt = datetime(2001, 7, 21, hour, 30, 00)
		thour = solar.hourAngle(dt, False, longitude, stdmeridian).degrees
		altitude = solar.altitudeAngle(dt, False, longitude, stdmeridian, latitude).degrees
		azimuth = solar.solarAzimuthAngle(dt, False, longitude, stdmeridian, latitude).degrees
		mywriter.writerow([x, -thour, altitude, azimuth])

with open('/tmp/compare_summer_incidence_library.csv', 'w') as csvfile:
	mywriter = csv.writer(csvfile)
	mywriter.writerow(['Hour', 'East Incidence', 'West Incidence'])
	for hour in range(0,24): # gives zero-based hours as expected in the datetime constructor
		x = hour
		dt = datetime(2001, 7, 21, hour, 30, 00)
		theta_west = solar.solarAngleOfIncidence(dt, False, longitude, stdmeridian, latitude, 270).degrees
		theta_east = solar.solarAngleOfIncidence(dt, False, longitude, stdmeridian, latitude, 90).degrees
		mywriter.writerow([x, theta_east, theta_west])
south_wall_normal_from_north = 180
west_wall_normal_from_north = 270
with open('/tmp/eplus_validation_location.csv', 'w') as csvfile:
	mywriter = csv.writer(csvfile)
	mywriter.writerow(['Hour', 'Hour Angle', 'Solar Altitude', 'Solar Azimuth', 'Cos East Wall Theta', 'Cos South Wall Theta', 'Cos West Wall Theta'])
	for month in range(1,3): # just january and february
		thisLat = getLat(month)
		thisLong = getLong(month)
		for day in range(1,monthrange(2011, month)[1]+1): # just make sure it isn't a leap year
			for hour in range(0,24): # gives zero-based hours as expected in the datetime constructor
				x = hour
				dt = datetime(2011, month, day, hour, 30, 00)
				thour = solar.hourAngle(dt, False, thisLong, stdmeridian).degrees
				altitude = solar.altitudeAngle(dt, False, thisLong, stdmeridian, thisLat).degrees
				azimuth = solar.solarAzimuthAngle(dt, False, thisLong, stdmeridian, thisLat).degrees
				east_theta = solar.solarAngleOfIncidence(dt, False, thisLong, stdmeridian, thisLat, east_wall_normal_from_north).radians
				south_theta = solar.solarAngleOfIncidence(dt, False, thisLong, stdmeridian, thisLat, south_wall_normal_from_north).radians
				west_theta = solar.solarAngleOfIncidence(dt, False, thisLong, stdmeridian, thisLat, west_wall_normal_from_north).radians
				if east_theta != None:
					east_theta = math.cos(east_theta)
				if south_theta != None:
					south_theta = math.cos(south_theta)
				if west_theta != None:
					west_theta = math.cos(west_theta)
				mywriter.writerow([x, -thour, altitude, azimuth, east_theta, south_theta, west_theta])

def getWallOrientation(month):
	if month <= 1:
		return 0
	elif month == 2:
		return 90
latitude = 39.75
x = []
east_wall_normal_from_north = 90
east_theta = []
east_az = []
alt = []
for hour in range(
        0,
        24):  # gives zero-based hours as expected in the datetime constructor
    x.append(hour)
    dt = datetime(2001, 6, 21, hour, 00, 00)
    east_az.append(
        solar.wallAzimuthAngle(dt, True, longitude, stdmeridian, latitude,
                               east_wall_normal_from_north).degrees)
    east_theta.append(
        solar.solarAngleOfIncidence(dt, True, longitude, stdmeridian, latitude,
                                    east_wall_normal_from_north).degrees)
    alt.append(
        solar.altitudeAngle(dt, True, longitude, stdmeridian,
                            latitude).degrees)

plt.plot(x, alt, 'r', label='Solar Altitude Angle')
plt.plot(x, east_az, 'g', label='East Wall Azimuth Angle')
plt.plot(x, east_theta, 'b', label='East Wall Incidence Angle')
plt.xlim([0, 23])
plt.ylim([-90, 180])
plt.suptitle("Wall Solar Incidence Angles", fontsize=14, fontweight='bold')
plt.xlabel("Hour of Day -- Clock Time")
plt.ylabel("Angle [degrees]")
plt.grid(True, axis='both')
plt.legend()
plt.savefig(
示例#5
0
 for day in range(1,
                  monthrange(2011, month)[1] +
                  1):  # just make sure it isn't a leap year
     for hour in range(
             0, 24
     ):  # gives zero-based hours as expected in the datetime constructor
         x = hour
         dt = datetime(2011, month, day, hour, 30, 00)
         thour = solar.hourAngle(dt, False, thisLong,
                                 stdmeridian).degrees
         altitude = solar.altitudeAngle(dt, False, thisLong,
                                        stdmeridian, thisLat).degrees
         azimuth = solar.solarAzimuthAngle(dt, False, thisLong,
                                           stdmeridian, thisLat).degrees
         east_theta = solar.solarAngleOfIncidence(
             dt, False, thisLong, stdmeridian, thisLat,
             east_wall_normal_from_north).radians
         south_theta = solar.solarAngleOfIncidence(
             dt, False, thisLong, stdmeridian, thisLat,
             south_wall_normal_from_north).radians
         west_theta = solar.solarAngleOfIncidence(
             dt, False, thisLong, stdmeridian, thisLat,
             west_wall_normal_from_north).radians
         if east_theta != None:
             east_theta = math.cos(east_theta)
         if south_theta != None:
             south_theta = math.cos(south_theta)
         if west_theta != None:
             west_theta = math.cos(west_theta)
         mywriter.writerow([
             x, -thour, altitude, azimuth, east_theta, south_theta,