//plot sunrises and sunsets for a year //the following data was 2007 data parsed from the output at http://aa.usno.navy.mil/data/docs/RS_OneYear.php //the *min values are "minutes of the day" (i.e. max would be 24 * 60) //monthdayptr is the starting day ptr for each month. int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; float sunrisemin[] = {433,434,434,434,434,433,433,433,433,433,432,432,432,431,431,430,430,429,429,428,428,427,426,425,425,424,423,422,421,420,419,418,417,416,415,414,413,412,410,409,408,407,405,404,403,401,400,398,397,396,394,393,391,390,388,387,385,383,382,380,379,377,375,374,372,370,369,367,365,364,362,360,359,357,355,353,352,350,348,347,345,343,341,340,338,336,334,333,331,329,327,326,324,322,321,319,317,316,314,312,311,309,307,306,304,302,301,299,298,296,295,293,292,290,289,287,286,284,283,282,280,279,277,276,275,274,272,271,270,269,268,267,265,264,263,262,261,260,260,259,258,257,256,255,255,254,253,253,252,251,251,250,250,250,249,249,248,248,248,248,247,247,247,247,247,247,247,247,247,247,248,248,248,248,248,249,249,249,250,250,251,251,252,252,253,254,254,255,255,256,257,258,258,259,260,261,262,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,335,336,337,338,339,340,341,342,343,344,345,347,348,349,350,351,352,353,354,356,357,358,359,360,361,363,364,365,366,367,369,370,371,372,373,375,376,377,378,380,381,382,383,385,386,387,388,390,391,392,393,395,396,397,398,400,401,402,403,404,406,407,408,409,410,411,412,413,414,416,417,418,419,419,420,421,422,423,424,425,425,426,427,428,428,429,429,430,430,431,431,432,432,432,433,433,433,433}; float sunsetmin[] = {982,983,984,985,986,987,988,989,990,991,992,993,995,996,997,998,999,1000,1002,1003,1004,1005,1007,1008,1009,1010,1012,1013,1014,1016,1017,1018,1019,1021,1022,1023,1025,1026,1027,1029,1030,1031,1032,1034,1035,1036,1038,1039,1040,1041,1043,1044,1045,1046,1048,1049,1050,1051,1053,1054,1055,1056,1058,1059,1060,1061,1062,1063,1065,1066,1067,1068,1069,1071,1072,1073,1074,1075,1076,1077,1079,1080,1081,1082,1083,1084,1085,1086,1088,1089,1090,1091,1092,1093,1094,1095,1097,1098,1099,1100,1101,1102,1103,1104,1106,1107,1108,1109,1110,1111,1112,1113,1115,1116,1117,1118,1119,1120,1121,1122,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1147,1148,1149,1150,1151,1152,1153,1153,1154,1155,1156,1156,1157,1158,1158,1159,1160,1160,1161,1161,1162,1162,1163,1163,1163,1164,1164,1164,1165,1165,1165,1165,1165,1165,1165,1165,1165,1165,1165,1165,1165,1164,1164,1164,1163,1163,1163,1162,1162,1161,1161,1160,1159,1159,1158,1157,1157,1156,1155,1154,1153,1152,1151,1150,1149,1148,1147,1146,1145,1144,1143,1142,1141,1139,1138,1137,1135,1134,1133,1131,1130,1129,1127,1126,1124,1123,1121,1120,1118,1117,1115,1114,1112,1110,1109,1107,1106,1104,1102,1101,1099,1097,1095,1094,1092,1090,1089,1087,1085,1083,1082,1080,1078,1076,1075,1073,1071,1069,1068,1066,1064,1062,1060,1059,1057,1055,1053,1052,1050,1048,1046,1045,1043,1041,1039,1038,1036,1034,1033,1031,1029,1028,1026,1025,1023,1021,1020,1018,1017,1015,1014,1012,1011,1009,1008,1006,1005,1003,1002,1001,999,998,997,996,994,993,992,991,990,989,988,987,986,985,984,983,982,981,980,979,979,978,977,977,976,976,975,975,974,974,973,973,973,972,972,972,972,972,972,972,972,972,972,972,972,973,973,973,974,974,974,975,975,976,976,977,978,978,979,980,981,981}; float monthdayptr[] = {0,31,59,90,120,151,181,212,243,273,304,334}; //as an afterthought I used the same script to parse the civil twilight... float twistartmin[] = {402,402,402,402,402,402,402,402,402,401,401,401,401,400,400,400,399,399,398,398,397,396,396,395,394,394,393,392,391,390,389,388,387,386,385,384,383,382,381,380,379,377,376,375,374,372,371,370,368,367,366,364,363,361,360,358,357,355,354,352,351,349,347,346,344,342,341,339,337,336,334,332,331,329,327,326,324,322,320,319,317,315,313,312,310,308,306,304,303,301,299,297,296,294,292,290,289,287,285,283,282,280,278,277,275,273,272,270,268,267,265,263,262,260,259,257,256,254,252,251,250,248,247,245,244,242,241,240,239,237,236,235,234,232,231,230,229,228,227,226,225,224,223,222,221,221,220,219,218,218,217,217,216,216,215,215,214,214,214,213,213,213,213,212,212,212,212,212,212,213,213,213,213,213,214,214,214,215,215,216,216,217,217,218,219,219,220,221,221,222,223,224,225,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,243,244,245,246,247,248,249,250,252,253,254,255,256,257,259,260,261,262,263,264,266,267,268,269,270,271,272,274,275,276,277,278,279,280,281,283,284,285,286,287,288,289,290,291,292,294,295,296,297,298,299,300,301,302,303,304,305,307,308,309,310,311,312,313,314,315,316,317,318,320,321,322,323,324,325,326,327,329,330,331,332,333,334,335,336,338,339,340,341,342,343,345,346,347,348,349,350,352,353,354,355,356,357,359,360,361,362,363,364,366,367,368,369,370,371,372,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,390,391,392,393,394,394,395,396,396,397,397,398,399,399,399,400,400,401,401,401,401,402}; float twistopmin[] = {1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1034,1035,1036,1037,1038,1039,1041,1042,1043,1044,1045,1047,1048,1049,1050,1052,1053,1054,1055,1057,1058,1059,1060,1062,1063,1064,1065,1066,1068,1069,1070,1071,1073,1074,1075,1076,1077,1079,1080,1081,1082,1083,1084,1086,1087,1088,1089,1090,1091,1093,1094,1095,1096,1097,1098,1100,1101,1102,1103,1104,1105,1107,1108,1109,1110,1111,1112,1114,1115,1116,1117,1118,1119,1121,1122,1123,1124,1125,1126,1128,1129,1130,1131,1132,1134,1135,1136,1137,1138,1140,1141,1142,1143,1144,1146,1147,1148,1149,1151,1152,1153,1154,1155,1157,1158,1159,1160,1161,1163,1164,1165,1166,1167,1169,1170,1171,1172,1173,1174,1175,1176,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1187,1188,1189,1190,1191,1191,1192,1193,1194,1194,1195,1195,1196,1197,1197,1197,1198,1198,1199,1199,1199,1199,1200,1200,1200,1200,1200,1200,1200,1200,1200,1199,1199,1199,1199,1198,1198,1198,1197,1197,1196,1196,1195,1194,1194,1193,1192,1191,1191,1190,1189,1188,1187,1186,1185,1184,1183,1182,1181,1179,1178,1177,1176,1175,1173,1172,1171,1169,1168,1166,1165,1164,1162,1161,1159,1158,1156,1154,1153,1151,1150,1148,1146,1145,1143,1141,1140,1138,1136,1135,1133,1131,1129,1128,1126,1124,1122,1121,1119,1117,1115,1114,1112,1110,1108,1106,1105,1103,1101,1099,1097,1096,1094,1092,1090,1088,1087,1085,1083,1081,1080,1078,1076,1074,1073,1071,1069,1068,1066,1064,1062,1061,1059,1058,1056,1054,1053,1051,1050,1048,1047,1045,1044,1042,1041,1039,1038,1036,1035,1034,1032,1031,1030,1029,1027,1026,1025,1024,1023,1022,1020,1019,1018,1017,1016,1016,1015,1014,1013,1012,1011,1011,1010,1009,1009,1008,1007,1007,1006,1006,1006,1005,1005,1005,1004,1004,1004,1004,1004,1004,1003,1003,1004,1004,1004,1004,1004,1004,1005,1005,1005,1005,1006,1006,1007,1007,1008,1008,1009,1010,1010,1011,1012,1012,1013}; int daycount = 365; String monthCap[] = {"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"}; //in 2007, march 11 was start of DST float DSTstart = monthdayptr[2] + 11; float DSTend = monthdayptr[10] + 4; int SCREENWIDTH = 365; int SCREENHEIGHT = 365; size(365,365); stroke(255,128); background(0,0,60); float BOXHEIGHT = SCREENHEIGHT ; float BOXWIDTH = 365; float MAXMIN = 24 * 60; //then draw in line of daylight for(int i = 0; i < daycount; i++){ stroke(255,128,0,80); //draw twilight line(i,(BOXHEIGHT * (twistartmin[i]/MAXMIN)),i,(BOXHEIGHT * (twistopmin[i]/MAXMIN))); stroke(255,255,0,160); //draw sunrise line(i,(BOXHEIGHT * (sunrisemin[i]/MAXMIN)),i,(BOXHEIGHT * (sunsetmin[i]/MAXMIN))); //for LAN3, draw dotted light halfway between sunrise and sunset if(i % 2 == 0){ float midpointmin = (sunrisemin[i] + sunsetmin[i]) / 2.0; float midpointpixel = BOXHEIGHT * (midpointmin / MAXMIN); stroke(255,255,255,160); line(i, midpointpixel,i,midpointpixel); } } //line(BOXLEFT-1,BOXTOP,BOXLEFT-1,BOXTOP+BOXHEIGHT); float loc; for(int i = 0; i < 24; i++){ loc = (((i*60.0)/MAXMIN)*BOXHEIGHT); line(0,loc,BOXWIDTH,loc); int h = i%12; /*String hr = new Integer(h).toString(); if(hr.length() < 2) { hr = "0"+hr; } if(hr.equals("00")) { hr = "12";} if(i < 12){ hr += "a"; } else { hr += "p"; } text(hr,16,loc+10);*/ } //so with the noon, 3 and 6 lines, we want draw DST versions... float loc12 = (((12*60.0)/MAXMIN)*BOXHEIGHT); float loc6 = (((6*60.0)/MAXMIN)*BOXHEIGHT); float loc18 = (((18*60.0)/MAXMIN)*BOXHEIGHT); float loc12dst = (((11*60.0)/MAXMIN)*BOXHEIGHT); float loc6dst = (((5*60.0)/MAXMIN)*BOXHEIGHT); float loc18dst = (((17*60.0)/MAXMIN)*BOXHEIGHT); stroke(255);fill(255); strokeWeight(2); line(0,loc12,DSTstart,loc12); line(0,loc6,DSTstart,loc6); line(0,loc18,DSTstart,loc18); text("6am",0,loc6-2); text("noon",0,loc12-2); text("6pm",0,loc18-2); line(DSTstart,loc12dst,DSTend,loc12dst); line(DSTstart,loc6dst,DSTend,loc6dst); line(DSTstart,loc18dst,DSTend,loc18dst); line(DSTend,loc12,BOXWIDTH,loc12); line(DSTend,loc6,BOXWIDTH,loc6); line(DSTend,loc18,BOXWIDTH,loc18); //draw month lines stroke(128,128,255,128); for(int i = 1; i < 12; i++){ line(monthdayptr[i],0,monthdayptr[i], BOXHEIGHT); } for(int i = 0; i < 12; i++){ text(monthCap[i],monthdayptr[i]+3,362); } //draw line for day in year... //Calendar rightNow = Calendar.getInstance(); //int dayOfYear = rightNow.get(Calendar.DAY_OF_YEAR);; int dayOfYear = day(); for(int i = 0; i < month()-1; i++){ println("Add in "+daysInMonth[i]); dayOfYear += daysInMonth[i]; } stroke(200,20,20,240); line(dayOfYear,0,dayOfYear,BOXHEIGHT);