manhattanhengemoon.frink

View or download manhattanhengemoon.frink in plain text format


// Program to calculate moon alignments with the East-West streets in
// Manhattan.

use sun.frink
use Grid.frink

North = +1
South = -1
West = +1
East = -1

lat = DMS[40,45,261.16] North
long = DMS[73,59,9.02] West

// Approximate direction of the streets.
// see http://en.wikipedia.org/wiki/Manhattanhenge
// http://www.charlespetzold.com/etc/AvenuesOfManhattan/index.html
axis = (270 + 29.008) degrees

// Conversion to coordinate system used by Meeus
axisMeeus = (axis + 180 degrees) mod circle

date = #2000-01-01 12:00#
dateOut = ### yyyy-MM-dd hh:mm:ss a zzz ###

sep = "\t"
tz = "US/Eastern"

g = new graphics

while (date <= #2031-12-31#)
{
   date = moonSecantAzimuth[date, lat, long, axisMeeus]
   
   [azimuth, altitude] = refractedMoonAzimuthAltitude[date, lat, long]

   if (altitude > -0.25 deg)
   {
      print[(date -> [dateOut, tz]) + sep]
      print[format[JD[date],day,5] + sep]
      print[format[altitude,degrees,2] + sep]
      print[format[moonIlluminatedFraction[date], percent, 1] + sep]
      print[skyDarkness[date, lat, long] + sep]
      radiusAngle = moonRadiusAngle[date]
      g.fillRectCenter[JD[date], -altitude, 3 day, 2 radiusAngle]
      println[]
   }
   
   date = date + 1 day
}

grid = new Grid
grid.font["Monospaced", 0.1 degree]

minorxtick = 1 month
minorytick = .1 degree
//grid.makeHorizontalLines[g, minorytick, false]
grid.makeVerticalCalendarLines[g, Grid.MONTH, false, tz]

majorytick = 1 degree

// Major labels
grid.color[0,0,0]
grid.makeHorizontalLabels[g, majorytick, -1 degree, false]
grid.makeVerticalCalendarLabels[g, Grid.YEAR, false, tz]

grid.color[0.5,0.5,0.5,0.3]
grid.makeHorizontalLines[g, majorytick, false]
grid.makeVerticalCalendarLines[g, Grid.YEAR, false, tz]

g.add[grid.g2]

g.show[]
g.write["manhattanhengemoon.svg",2048, 2048]
g.write["manhattanhengemoon.html",2048, 2048]


View or download manhattanhengemoon.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 18350 days, 2 hours, 25 minutes ago.