autumnEquinoxPlot.frink

Download or view autumnEquinoxPlot.frink in plain text format


// This program calculates and plots the date of the autumn equinox
// over the course of a few centuries.  This shows how the date of
// the equinox drifts over time (and is corrected back by leap year
// rules.)

use sun.frink
use planets.frink
use secant.frink

longfunc = {|date| highAccuracySunApparentLongitude[date]}
// Let's calculate the longitude angle that corresponds to 1 millisecond of
// time
angleres = ms circle/solaryear

tz = "US/Mountain"
startyear = 1800
endyear = 2150

g = new graphics
g.font["Monospaced", .1 day]
p = new polyline

for y = startyear to endyear
{
   autumnEquinox = secantInvert[longfunc,
                                 0 degrees,
                                 autumnEquinox[y] - 1 hour,
                                 autumnEquinox[y] + 1 hour,
                                 angleres]
   d = autumnEquinox - parseDate["$y $tz"]
   println["$y\t" + (autumnEquinox -> tz) + "\t" + format[d, "days", 2]]
   p.addPoint[y,-d]
   g.fillEllipseCenter[y, -d, 1, .01 day] 
}

g.color[0,0,0,.3]
g.add[p]

for y = startyear to endyear step 50
{
   g.color[0,0,0,.3]
   g.line[y, -263 days, y, -267 days]
   g.color[0,0,0]
   g.text["$y", y, -263 days, "center", "top"]
}

df = ### MM-dd ###
for d = 263 days to 267 days step day
{
   g.color[0,0,0,.3]
   g.line[startyear, -d, endyear, -d]
   usualDate = (parseDate["2015 $tz"] + d) -> [df, tz]
   leapDate = (parseDate["2016 $tz"] + d) -> [df, tz]
   g.color[0,0,0]
   g.text[format[d,"days",0] + "   \n(usually " + usualDate + "   \n on leap years, $leapDate)  ", startyear, -d, "right", "center"]
}

g.color[0,0,0,0]
g.line[startyear-100, -263 days, startyear-100, -267 days]

g.color[0,0,0]
g.font["SansSerif", .15 day]
g.text["Autumn Equinox (days after beginning of year, $tz)", 1975, -267.1 days, "center", "bottom"]
g.show[]

stz = tz =~ %s/\//./g

g.write["autumnequinox$stz.png",2000,1000]
g.write["autumnequinox$stz.html",2000,1000]
g.write["autumnequinox$stz.svg",2000,1000]
//browse["autumnequinox$stz.html"]
//browse["autumnequinox$stz.svg"]
 


Download or view autumnEquinoxPlot.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 19944 days, 16 hours, 5 minutes ago.