// Program to calculate moon 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, Ken Olum, Lenny Foner, and Matthias Huerlemann
// for various data and surveying assistance.
//
// 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
if length[ARGS] > 0 && ARGS@0 == "--html"
{
sep = "
"
html = true
}
date = #2019#
dateOut = ### yyyy-MM-dd hh:mm:ss a zzz ###
dateShort = ### yyyy-MM-dd ###
tz = "US/Eastern"
date = beginningOfYear[now[], tz]
enddate = beginningOfYearPlus[date, 2, tz]
temperature = cambridgeTemp[date]
while (date <= enddate)
{
temperature = cambridgeTemp[date]
date = moonSecantAzimuth[date, lat, long, corridorAzimuthMeeus, temperature, pressure]
// Now refine with temperature for that time of day.
temperature = cambridgeTemp[date]
date = moonSecantAzimuth[date, lat, long, corridorAzimuthMeeus, temperature, pressure]
[azimuth, altitude] = refractedMoonAzimuthAltitude[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"]
iFrac = moonIlluminatedFraction[date]
print[format[iFrac, percent, 1] + "$sep"]
radiusAngle = moonRadiusAngle[date]
print[format[F[temperature],1,0]]
if altitude < (1.16 degrees + radiusAngle) and altitude > -radiusAngle
{
if !html
print["$sep*"]
else
{
f = date -> [dateShort, tz]
print[" | | | [SVG]"]
}
// println["\n$date, $lat, $long, $temperature, $pressure, $corridorAzimuth"]
drawMoons[date, lat, long, temperature, pressure, corridorAzimuth]
}
println[]
date = date + 25 hours
}
// Function to draw the path of the moon as it crosses the corridor.
drawMoons[date, lat, long, temperature, pressure, corridorAzimuth] :=
{
tz = "US/Eastern"
g = new graphics
g.font["SansSerif", .05 deg]
// Draw doorway aperture
[skyr,skyg,skyb] = skyDarkness[date, lat, long, [[.1,.1,.1], [.1,.1,.2], [.1,.1,.3], [.1,.1,.4], [.8,.8,1]]]
g.color[skyr,skyg,skyb]
g.fillRectSides[corridorAzimuth - .5 degrees, 0 degrees, corridorAzimuth + .5degrees, -.91 degrees]
g.color[0,0,0,.7]
g.drawRectSides[corridorAzimuth - .5 degrees, 0 degrees, corridorAzimuth + .5degrees, -.91 degrees]
g.line[corridorAzimuth, 0 degrees, corridorAzimuth, -.93 degrees]
g.color[0,0,0]
d1 = date - 2 min
do
{
[az, alt] = refractedMoonAzimuthAltitude[d1, lat, long, temperature, pressure]
drawMoon[g, d1, lat, long, temperature, pressure]
d1 = d1 - 2 min
} while alt < 1.2 degrees
d1 = date + 2 min
do
{
[az, alt] = refractedMoonAzimuthAltitude[d1, lat, long, temperature, pressure]
drawMoon[g, d1, lat, long, temperature, pressure]
d1 = d1 + 2 min
} while alt > 0 degrees
drawMoon[g, date, lat, long, temperature, pressure]
g.color[0,0,0,.7]
// 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]
g.text["Illuminated fraction: " + format[moonIlluminatedFraction[date], percent, 1] + "%", corridorAzimuth, .3 degrees]
// Render files
sd = ###yyyy-MM-dd###
g.write["moon" + (date->[sd, tz]) + ".png", 640, 480]
g.write["moonthumb" + (date->[sd, tz]) + ".png", 100, 80]
g.write["moon" + (date->[sd, tz]) + ".svg", 640, 480]
// g.show[]
}
// Draw a single moon image with time/date stamp.
drawMoon[g, date, lat, long, temperature, pressure] :=
{
tz = "US/Eastern"
shortDate = ###hh:mm:ss a###
[azimuth, altitude] = refractedMoonAzimuthAltitude[date, lat, long, temperature, pressure]
trueAz = (azimuth + 180 degrees) mod circle
// println["True azimuth at $date is " + (trueAz->degrees)]
ra = moonRadiusAngle[date]
// println["Radius angle is " + (ra->"degrees")]
// Draw the moon
g.color[1,1,1,.9]
g.add[drawMoonPolygonRelativeToZenith[date, lat, long, trueAz, -altitude, ra , true]]
g.color[0,0,0]
g.add[drawMoonPolygonRelativeToZenith[date, lat, long, trueAz, -altitude, ra , false]]
// Draw horizontal line to center of moon
g.color[.7,.7,.7]
g.line[trueAz - ra - 0.02 degree, -altitude, trueAz, -altitude]
g.fillRectCenter[trueAz, -altitude, .02 degree, .02 degree]
g.color[1,1,1,0.5]
g.fillRectSides[trueAz - ra - .35 degree, -altitude - 0.025 deg, trueAz - ra - .02 degree, -altitude + 0.025 deg]
g.color[0,0,0]
g.text[(date -> [shortDate, tz]), trueAz - ra - .03 degree, -altitude, "right", "center"]
// g.text[(date -> [shortDate, tz]), trueAz, -altitude]
}
|