Articles by Dan Kelley Blog/R

Inferring halocline depth

January 11, 2014 | Dan Kelley Blog/R

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 ... [Read more...]

Smoothing CTD profiles

January 11, 2014 | Dan Kelley Blog/R

Introduction Smoothing hydrographic profiles with conventional time-series methods is problematic for two reasons: (a) the data are commonly not equi-spaced in depth and (b) the data seldom lack trends in depth. The issues and their solutions are illustrated without much discussion here. The first step in making the graph shown ... [Read more...]

PISA scores

January 6, 2014 | Dan Kelley Blog/R

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 ... [Read more...]

Installing oce in R

December 30, 2013 | Dan Kelley Blog/R

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") ... [Read more...]

R interface to WebTide

December 29, 2013 | Dan Kelley Blog/R

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 ... [Read more...]

Sundial calculations

December 28, 2013 | Dan Kelley Blog/R

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 ... [Read more...]

Analemma graphs

December 27, 2013 | Dan Kelley Blog/R

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 [Read more...]

A new Oce coastline

December 22, 2013 | Dan Kelley Blog/R

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 ... [Read more...]

Day length calculation

December 21, 2013 | Dan Kelley Blog/R

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 ... [Read more...]

Solstice sunrise-sunset

December 21, 2013 | Dan Kelley Blog/R

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 ... [Read more...]

Moon phase calculation

December 21, 2013 | Dan Kelley Blog/R

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 [Read more...]
1 2 3

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)