plotCambridgeTemp.frink

View or download plotCambridgeTemp.frink in plain text format


/** This program plots the average cambridge temperature for any moment of
    the year, based on Fourier analysis of average temperatures. */

use cambridgetempFourier.frink

g = new graphics
g.stroke[2 hours]
g.font["SansSerif", 2 degF]
p = new polyline

tz = "US/Eastern"

startYear = 2017
sd = parseDate["$startYear $tz"]
ed = parseDate[(startYear+1) + " $tz"]

for d = sd to ed step 30 min
   p.addPoint[MJD[d], -cambridgeTemp[d]]

g.add[p]
[first, highest, last, lowest] = getBoundingBox[g]

monthMarker = ###MMM###

// Draw month lines
for month = 1 to 12
{
   x = parseDate["$startYear-" + padLeft[month, 2, "0"] + " $tz"]
   g.line[MJD[x], highest, MJD[x], lowest]
   g.text[x->[monthMarker, tz], MJD[x], lowest, "center", "top"]
}

// Draw degree lines
g.font["SansSerif", .9 degF]
for temp = floor[F[-lowest]] to ceil[F[-highest]]
{
   f = F[temp]
   g.line[first, -f, last, -f]
   g.text[temp, first, -f, "right", "center"]
}


g.show[]
g.write["plotCambridgeTemp.svg", 1024, 800]
g.write["plotCambridgeTemp.html", 1024, 800]


View or download plotCambridgeTemp.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 17596 days, 22 hours, 1 minutes ago.