Download or view mithengesun.frink in plain text format
// 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 https://futureboy.us/mithenge/
//
// Alan Eliasen, eliasen@mindspring.com
use mithengecorridor.frink
use cambridgetempFourier.frink
use sun.frink
sep = "\t"
preamble = ""
html = false
printall=false
if ARGS.contains["--html"]
{
sep = "<TD>"
preamble = "<TR><TD>"
html = true
}
if ARGS.contains["--printall"]
printall = true
out = ["degrees", "arcmin", "arcsec"]
dateOut = ### yyyy-MM-dd hh:mm:ss a zzz ###
tz = "US/Eastern"
date = beginningOfYear[now[], tz]
enddate = beginningOfYearPlus[date, 2, tz]
temperature = F[59]
while (date <= enddate)
{
date = sunSecantAzimuth[date, lat, long, corridorAzimuthMeeus, temperature, pressure]
// Now refine with temperature for that time of day.
temperature = cambridgeTemp[date]
date = sunSecantAzimuth[date, lat, long, corridorAzimuthMeeus, temperature, pressure]
[azimuth, altitude] = refractedSunAzimuthAltitude[date, lat, long, temperature, pressure]
print[preamble]
print[(date -> [dateOut, tz]) + "$sep"]
print[format[JD[date],day,5] + "$sep"]
print[format[altitude,degrees,2] + "$sep"]
print[format[F[temperature],1,0]]
radiusAngle = sunRadiusAngle[date]
if printall or (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></A>\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] :=
{
tz = "US/Eastern"
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]
// Draw doorway aperture
g.color[0,0,0,.7]
g.drawRectSides[corridorAzimuth - .5 degrees, 0 degrees, corridorAzimuth + .5degrees, -.91 degrees]
// Draw vertical centerline
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,tz]), corridorAzimuth, .2 degrees]
// Render files
sd = ###yyyy-MM-dd###
f1 = "sun" + (date->[sd, tz]) + ".png"
g.write[f1, 640, 480]
f2 = "sunthumb" + (date->[sd, tz]) + ".png"
g.write[f2, 100, 80]
f3 = "sun" + (date->[sd, tz]) + ".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] :=
{
tz = "US/Eastern"
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, tz]), trueAz, -altitude]
// g.text[(date -> [shortDate, tz]), trueAz, -altitude]
}
Download or view 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 20136 days, 3 hours, 35 minutes ago.