// Program to calculate sun crossing of the Infinite Corridor at MIT
// known as "MIThenge"
//
// More info at also http://web.mit.edu/planning/www/mithenge.html
// Thanks to Keith Winstein and Ken Olum for various data.
//
// For worked predictions, see http://futureboy.us/mithenge/
//
// Alan Eliasen, eliasen@mindspring.com
use mithengecorridor.frink
use sun.frink
sep = "\t"
preamble = ""
html = false
if length[ARGS] > 0 && ARGS@0 == "--html"
{
sep = "<TD>"
preamble = "<TR><TD>"
html = true
}
out = ["degrees", "arcmin", "arcsec"]
dateOut = ### yyyy-MM-dd hh:mm:ss a zzz ###
date = #2007-01-01#
while (date <= #2010-12-31#)
{
date = sunSecantAzimuth[date, lat, long, corridorAzimuthMeeus, temperature, pressure]
 // Generate date key suitable for use in looking up in "mean" dictionary
dateKey = date -> ###M-d###
 // Comment out this line to use hardcoded temperature in mithengecorridor
temperature = mean@dateKey
[azimuth, altitude] = refractedSunAzimuthAltitude[date, lat, long, temperature, pressure]
print[preamble]
print[(date -> [dateOut, "Eastern"]) + "$sep"]
print[format[JD[date],day,5] + "$sep"]
print[format[altitude,degrees,2] + "$sep"]
print[format[F[temperature],1,0]]
radiusAngle = sunRadiusAngle[date]
if altitude < (0.91 degrees + radiusAngle) and altitude > -radiusAngle
{
if !html
print["$sep*"]
[f1,f2,f3] = drawSuns[date, lat, long, temperature, pressure, corridorAzimuth]
if html
println["$sep\n $sep<A HREF=\"images/$f1\">\n <IMG SRC=\"images/$f2\" WIDTH=100 HEIGHT=80>\n $sep<A HREF=\"images/$f3\">[SVG]</A>"]
}
println[]
date = date + 1 day
}
// Function to draw the path of the sun as it crosses the corridor.
drawSuns[date, lat, long, temperature, pressure, corridorAzimuth] :=
{
g = new graphics
g.font["SansSerif", .05 deg]
d1 = date - 2 min
do
{
[az, alt] = refractedSunAzimuthAltitude[d1, lat, long, temperature, pressure]
drawSun[g, d1, lat, long, temperature, pressure]
d1 = d1 - 2 min
} while alt < 1.2 degrees
d1 = date + 2 min
do
{
[az, alt] = refractedSunAzimuthAltitude[d1, lat, long, temperature, pressure]
drawSun[g, d1, lat, long, temperature, pressure]
d1 = d1 + 2 min
} while alt > 0 degrees
drawSun[g, date, lat, long, temperature, pressure, true]
g.color[0,0,0,.7]
g.drawRectSides[corridorAzimuth - .5 degrees, 0 degrees, corridorAzimuth + .5degrees, -.91 degrees]
g.line[corridorAzimuth, 0 degrees, corridorAzimuth, -.91 degrees]
 // Draw floor
g.fillRectSides[corridorAzimuth - 1 degree, 0 degrees, corridorAzimuth + 1 degree, .5 degrees]
 // Text description
g.color[1,1,1]
df = ###yyyy-MM-dd hh:mm:ss a zzz###
g.font["SansSerif", "bold", .1 degrees]
g.text[(date->[df,"Eastern"]), corridorAzimuth, .2 degrees]
 // Render files
sd = ###yyyy-MM-dd###
f1 = "sun" + (date->[sd, "Eastern"]) + ".png"
g.write[f1, 640, 480]
f2 = "sunthumb" + (date->[sd, "Eastern"]) + ".png"
g.write[f2, 100, 80]
f3 = "sun" + (date->[sd, "Eastern"]) + ".svg"
g.write[f3, 640, 480]
// g.show[]
return [f1,f2,f3]
}
// Draw a single sun image with time/date stamp.
drawSun[g, date, lat, long, temperature, pressure, yellow=false] :=
{
shortDate = ###hh:mm:ss a###
[azimuth, altitude] = refractedSunAzimuthAltitude[date, lat, long, temperature, pressure]
trueAz = (azimuth + 180 degrees) mod circle
// println["True azimuth at $date is " + (trueAz->degrees)]
ra = sunRadiusAngle[date]
da = 2 ra
// println["Radius angle is " + (ra->"degrees")]
 // Draw the sun
if yellow
{
g.color[1,1,0,0.7]
g.fillEllipseCenter[trueAz, -altitude, da, da]
}
g.color[0,0,0]
g.drawEllipseCenter[trueAz, -altitude, da, da]
g.text[(date -> [shortDate, "Eastern"]), trueAz, -altitude]
// g.text[(date -> [shortDate, "Eastern"]), trueAz, -altitude]
}
View or download mithengesun.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 14705 days, 3 hours, 9 minutes ago.