Blog Archives

GMT topography colours (I)

January 30, 2014
By
GMT topography colours (I)

I enjoyed the blog posting by “me nugget”, which I ran across on R-bloggers, and so I decided to try that author’s GMT colourscheme. This revealed some intriguing patterns in the Oce dataset named topoWorld. The following code produces a graph to illustrate. 1. Set up colours as suggested on the “menuggest” blog 1 2 3 4 5 6 7 8 9 ## test GMT colours as...

Read more »

GMT topography colours (II)

January 30, 2014
By
GMT topography colours (II)

This follows an item about GMT colours. In the meantime I have found a website illustrating the colours, and also the definition files for those palettes. The palette in question is named GMT_relief, and it is defined in a file that is as follows. # $Id: GMT_relief.cpt,v 1.1 2001/09/23 23:11:20 pwessel Exp $ # # Colortable for whole earth...

Read more »

Vote splitting in Canada

January 25, 2014
By
Vote splitting in Canada

Analysis District-by-district data reveal that if the Bloc Quebecois, Green, Liberal, and NDP parties were to have been united, the Conservative party would have lost the 41st Canadian election by a dramatic measure, instead of winning a majority. The graph given below shows the results by naming the ridings. Clicking on the graph will let you see results riding by...

Read more »

1D optimization in R

January 22, 2014
By
1D optimization in R

Introduction R provides functions for both one-dimensional and multi-dimensional optimization. The second topic is much more complicated than the former (see e.g. Nocedal 1999) and will be left for another day. A convenient function for 1D optimization is optimize(), also known as optimise(). Its first argument is a function whose minimum (or maximum) is sought, and the second is...

Read more »

Using the plyr package

January 18, 2014
By
Using the plyr package

Introduction The base R system provides lapply() and related functions, and the package plyr provides alternatives that are worth considering. It will be assumed that readers are familiar with lapply() and are willing to spend a few moments reading the plyr documentation, to see why the illustration here will use the ldply() function. The test task will be extraction of...

Read more »

Colourizing a trajectory

January 15, 2014
By
Colourizing a trajectory

Introduction In Oceanography it can be useful to use colour to display z values along an (x,y) trajectory. For example, CTD data might be displayed in this way, with x being distance along track, y being depth, and z being temperature. This post shows how one might do this. Methods The R code given below demonstrates this with fake data. ...

Read more »

Cabelling calculations

January 15, 2014
By
Cabelling calculations

Abstract R code is provided in aide of laboratory demonstration of cabelling. Introduction Setting up a cabelling experiment requires creating two watermasses of equal density, and if only S and T can be measured, that means calculating densities. Using a TS diagram and graphical interpolation is one approach to that task, but another is to use R to do the calculation....

Read more »

Butterworth filter overshoot

January 15, 2014
By
Butterworth filter overshoot

Introduction Butterworth filters with order other than 1 have an overshoot phenomenon that can be problematic in some cases. For example, if smoothing is used on an estimate of kinetic energy, overshoots might yield negative values that are nonphysical. This post simply illustrates this with made-up data that the reader can experiment with. Methods First, create and plot...

Read more »

Smoothing CTD profiles

January 11, 2014
By
Smoothing CTD profiles

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 above is to load the oce library and...

Read more »

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 »