solstice sunrise-sunset

Abstract. This post shows how to determine sunrise-sunset angles on the winter solstice in Halifax, NS, Canada.

1. Introduction

The sunAngle() function in the oce package provides a handy way to determine sunrise/sunset azimuth angles, and this is used to find alignments for the winter solstice in Halifax, NS.

2. Methods

## Map with lines for sunrise/sunset direction on 2013 winter solstice.

# should not need to edit below the next four lines
t <- as.POSIXct("2013-12-21 17:11:00", tz="UTC") # winter solstice
xy <- list(x=-63.60, y=44.65)          # centre of map (Halifax)
D <- 6                                 # map span in km

library(oce)
library(OpenStreetMap)

t0 <- t - 86400 / 4
sunrise <- uniroot(function(t)
                   sunAngle(t, lat=xy$y, lon=xy$x)$altitude,
                   interval=as.numeric(c(t0, t)))$root
sunrise <- numberAsPOSIXct(sunrise)
print(sunrise)
azimuth <- 90 - sunAngle(sunrise, lat=xy$y, lon=xy$x)$azimuth
D <- D / 111                           # deg
Dlon <- D / cos(xy$y * pi / 180)
map <- openmap(c(lat=xy$y+D/2, lon=xy$x-Dlon/2),
               c(lat=xy$y-D/2, lon=xy$x+Dlon/2),
               minNumTiles=9)
if (!interactive()) png("solstice_sunrise_sunset.png",
                        width=7, height=7,
                        unit="in", res=200, pointsize=12)
plot(map)
## cx and cy are in "map units", needed for lines
cx <- mean(par('usr')[1:2])
cy <- mean(par('usr')[3:4])
points(cx, cy, col='red')
d <- diff(par('usr')[3:4]) # scales as the map
for (o in d*seq(-1, 1, length.out=30)) {
    lines(cx+c(-1,1)*d*cos(azimuth*pi/180),
          cy+o+c(-1,1)*d*sin(azimuth*pi/180), col='red')
}
mtext(sprintf("sunrise angles on day of winter solstice (%s)",
              format(t, "%Y-%m-%d")), side=3, line=2, cex=1.5)
if (!interactive()) dev.off()

If run non-interactively, the code will produce a PNG file like that given below.

3. Results

Sun angles for sunrise and sunset in Halifax, NS, Canada, on the 2014 winter solstice.

Sun angles for sunrise and sunset in Halifax, NS, Canada, on the 2014 winter solstice.

Exercise.

  1. Alter line 4 to set another day, or line 5 to set another location.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s