springEquinoxPlot.frink

Download or view springEquinoxPlot.frink in plain text format


// This program calculates and plots the date of the spring equinox
// over the course of a few centuries.  I made this because I'm old
// and I remember the equinoxes usually being on the 21st (probably
// in UTC.)  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"

g = new graphics
g.font["Monospaced", .1 day]
p = new polyline
for y = 1800 to 2150
{
   springEquinox = secantInvert[longfunc,
                                180 degrees,
                                springEquinox[y] - 1 hour,
                                springEquinox[y] + 1 hour,
                                angleres]
   d = springEquinox - parseDate["$y $tz"]
   println["$y\t" + (springEquinox -> 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 = 1800 to 2150 step 50
{
   g.color[0,0,0,.3]
   g.line[y, -77 days, y, -80 days]
   g.color[0,0,0]
   g.text["$y", y, -77 days, "center", "top"]
}

df = ### MM-dd ###
for d = 77 days to 80 days step day
{
   g.color[0,0,0,.3]
   g.line[1800, -d, 2150, -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)  ", 1800, -d, "right", "center"]
}

g.color[0,0,0,0]
g.line[1700, -77 days, 1700, -80 days]

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

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

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


Download or view springEquinoxPlot.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 19945 days, 10 hours, 43 minutes ago.