def plotIncident(lats, days, tilts, dirs, attenuate=False): if np.isscalar(lats): lats = [lats] if np.isscalar(days): days = [days] if np.isscalar(tilts): tilts = [tilts] if np.isscalar(dirs): dirs = [dirs] ts = np.arange(0,24,0.25) h = np.radians(solar.hourAngle(ts)) for lat in lats: for day in days: for tilt in tilts: for dir in dirs: (mon,md) = solar.findDay(day) plt.plot(ts,solar.incident(lat,day,ts,tilt,dir,attenuate),label= mon + " " + str(md) + " " + str(lat) + " deg @" +str(tilt)+"["+str(dir)+"]" ) plt.title('Effective Incident Solar') plt.xlabel('Hour') axes = plt.axes() handles, labels = axes.get_legend_handles_labels() axes.legend(handles, labels, loc=2) return axes
def plotAzimuthDaysFix(lats,days): ts = np.arange(0,24,0.25) h = np.radians(solar.hourAngle(ts)) for lat in lats: for day in days: d = np.radians(solar.declination(day)) l = np.radians(lat) print 'day: ' + str(day) + " lat: " + str(lat), np.tan(d), np.tan(l), np.tan(d)/np.tan(l) (mon,md) = solar.findDay(day) plt.plot(ts,solar.azimuthRaw(lat,day,ts),label= mon + " " + str(md) + " " + str(lat) + " deg") plt.plot(ts, np.cos(h)) plt.plot(ts, (np.tan(d)/np.tan(l)) * np.ones(len(ts))) plt.title('Solar Azimuth Angle Day') plt.xlabel('Hour') plt.ylabel('rad') axes = plt.axes() handles, labels = axes.get_legend_handles_labels() axes.legend(handles, labels, loc=3) return axes
plt.legend() plt.savefig(os.path.join(os.path.dirname(__file__), '..', '..', 'SolarCalculations.wiki/DemoSolarAnglesCivilSolarTime.png')) #### reset plt.close() # calculate hour angle for a summer day in Golden, CO longitude = 105.2 stdmeridian = 105 latitude = 39.75 x = [] hours = [] 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) hours.append(solar.hourAngle(dt, True, longitude, stdmeridian).degrees) plt.plot(x, hours, 'b', label='Hour Angle') plt.xlim([0,23]) plt.suptitle("Hour Angle", 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/DemoSolarAnglesHour.png')) #### reset plt.close() # calculate solar altitude angles for Winter and Summer days in Golden, CO longitude = 105.2
# import the csv library for easier output import csv # Golden, CO longitude = 104.85 stdmeridian = 105 latitude = 39.57 with open('/tmp/compare_winter_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, 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])
#### reset plt.close() # calculate hour angle for a summer day in Golden, CO longitude = 105.2 stdmeridian = 105 latitude = 39.75 x = [] hours = [] 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) hours.append(solar.hourAngle(dt, True, longitude, stdmeridian).degrees) plt.plot(x, hours, 'b', label='Hour Angle') plt.xlim([0, 23]) plt.suptitle("Hour Angle", 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/DemoSolarAnglesHour.png')) #### reset plt.close()
stdmeridian = 105 east_wall_normal_from_north = 90 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:
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)