Blog Archives

Inferring halocline depth

January 11, 2014
By
Inferring halocline depth

Introduction There are no agreed-upon methods for inferring halocline depth, but a reasonable method might involve locating the depth at which dS/dp is largest, where S is salinity and p is pressure (Kelley 2014 chapter 5). Calculating the derivative using e.g. diff(S)/diff(p) can be problematic because of sensitivity to noise, especially for data that have not been bin-averaged. Achieving...

Read more »

PISA scores

January 6, 2014
By
PISA scores

The Guardian Newspaper has an interesting article about the Pisa (Program for International Student Assessment) scores for 2012, and it includes data. Since I was interested to see how my own region scored, I downloaded the data into a file called PISA-summary-2012.csv and created a plot summarizing scores in all the sampled regions, with Canada highlighted. Graphical...

Read more »

Installing oce in R

December 30, 2013
By

Several of the blog items have used the oce package. The official version of this can be installed from within R by 1 install.packages("oce") and more up-to-date versions can be installed using the devtools package written by Hadley Wickham, which is itself installed with 1 install.packages("devtools") after which installing the latest development version of oce is accomplished with 1 2 3 library(devtools) install_github('ocedata', 'dankelley', 'master') install_github('oce', 'dankelley', 'develop') Note that the...

Read more »

R interface to WebTide

December 29, 2013
By
R interface to WebTide

A previous posting explained how to install WebTide on an OSX machine. This one shows how to hook up to an installed WebTide database, so that R code can get tidal predictions. The following code in the R language will produce a graph in which the top panel mimics the tidal-elevation graph produced by WebTide itself (see previous blog posting...

Read more »

Sundial calculations

December 28, 2013
By
Sundial calculations

After experimenting with calculations for what I eventually came to realize were analemma-based sundials (with shadow cast by a vertical pole), I remembered that the common sundial has a wedge as the shadow-maker. A bit of research told me that the wedge is called a gnomon. It is a right triangle with one vertex (the centre vertex, shall...

Read more »

Analemma graphs

December 27, 2013
By
Analemma graphs

Continuing on the theme of solar angles, the code given below produces an analemma diagram similar to that of Lynch (2012, figure 2). 1 2 3 4 5 6 7 8 9 10 library(oce) loc <- list(lon=-0.0015, lat=51.4778) # Greenwich Observatory t <- seq.POSIXt(as.POSIXct("2014-01-01 12:00:00", tz="UTC"), as.POSIXct("2015-01-01...

Read more »

A new Oce coastline

December 22, 2013
By
A new Oce coastline

Part 1: coastal applications The oce package has a world coastline file that is visibly crude on a scale suitable for continental-shelf work.  At the cost of about 1 Mbyte of storage, a candidate for a replacement is a 1:10million scale version downloaded from naturalearthdata.com (full link below). As illustrated below with plots near two oceanographic centres, this candidate provides...

Read more »

Day length calculation

December 21, 2013
By
Day length calculation

The winter solstice has been on many minds lately. The days are about to start getting longer … but just how fast will they do that? This post provides R that calculates and graphs day length and its variation, using uniroot() to find sunrises and sunsets as indicated by solar altitude that is calculated with sunAngle() in the oce...

Read more »

Solstice sunrise-sunset

December 21, 2013
By
Solstice sunrise-sunset

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. Methods First, set up the problem; these may be the only lines that need editing for other places or times. 1 2 3 t <- as.POSIXct("2013-12-21 17:11:00", tz="UTC") # winter solstice xy <- list(x=-63.60, y=44.65) ...

Read more »

Moon phase calculation

December 21, 2013
By
Moon phase calculation

The illuminated fraction of the moon can be calculated with moonAngle() in the oce package, as illustrated graphically and in R code below. 1 2 3 4 5 6 7 library(oce) par(mar=c(3, 3, 1, 1), mgp=c(2, 0.7, 0)) # tighten margins t <- as.POSIXct("2013-12-1", tz="UTC") + seq(0, 28*24*3600, 3600) f <- moonAngle(t=t, longitude=-63.6, ...

Read more »