Blog Archives

Assessing mapdata world coastline

January 27, 2015
By
Assessing mapdata world coastline

Introduction The mapdata R package contains a coastline called worldHires which is contained within a text file with a bit over 2 million lines. Since the coastlineWorldFine dataset in the ocedata package contains about 0.5 million points, I thought I would explore how much better the mapdata coastline might be. Methods First, I wrote the following C file to translate the...

Read more »

World Ocean Atlas changes

January 25, 2015
By
World Ocean Atlas changes

Introduction The ocedata R package has a dataset named levitus, which stores sea-surface temperature and salinity. Today, the development version of ocedata (available at github) was updated from the 2009 version of this atlas to the 2013 version. Differences between the two datasets are illustrated here. Methods The code provided below requires that the old dataset be saved into an RDA...

Read more »

solar navigation

November 9, 2014
By
solar navigation

Introduction Solar altitude is a function of time, longitude and latitude, and so it can be possible to infer location based on measuring altitude as a function of time. This form of solar navigation can be based on sunrise and sunset times, at least on non-equinox days. I have explored this for a school-based project I call “SkyView” involving light sensors and Arduino microcontrollers,...

Read more »

landsat thermal imaging

July 1, 2014
By
landsat thermal imaging

Introduction The tirs1 band of landsat-8 imagery (see ) is a near-thermal band, from which a quantity called ``brightness temperature’’ may be inferred. As explained in , the brightness temperature in Kelvin is computed with where and are stored in the image metadata, and , where again and are stored in the metadata. In this...

Read more »

Gulf Stream centre detection

June 22, 2014
By
Gulf Stream centre detection

Introduction Definitions of Gulf Stream location sometimes centre on thermal signature, but it might make sense to work with dynamic height instead. This is illustrated here, using a model for , with the distance along the transect. The idea is to select , the halfway point in the function, where the slope is maximum...

Read more »

DE solution in R (nonlinear oscillator)

June 15, 2014
By
DE solution in R (nonlinear oscillator)

Introduction The function lsoda() from the deSolve package is a handy function for solving differential equations in R. This is illustrated here with a classic example: the nonlinear oscillator. Theory As explained in any introductory Physics textbook, the nondimensionalized oscillator equation can be simplified to provided that , i.e. in the “small angle” limit. The linear form has solution for initial conditions ...

Read more »

using C++ within R

June 8, 2014
By

Introduction Quite often I write which(...) to find the first element of a vector matching some condition. One has to wonder whether that’s wasteful, though, since there is no need to do any tests once one works. I decided to try using C++, using Rcpp, to see if speed advances could be made. Procedure 1 2 3 4 5 6 library(Rcpp) library(microbenchmark) cppFunction("\n ...

Read more »

slumping model

June 8, 2014
By
slumping model

Introduction I got interested in layered sedimentation from viewing a video and decided it would be interesting to code this into R. More on that in due course, but my first step was to code a syatem with one sediment “type”. Procedure The following code drops sediment particles at x=1, and lets them roll downhill until they reach the bottom or...

Read more »

colormap

April 30, 2014
By
colormap

Introduction Over the past month or so I have been trying different ways of handling GMT-style colormaps in Oce. I think my present solution is on the right track, but I am posting here to get more eyes on the problem. Note that the function called Colormap() here will be called colormap() if I decided to incorporate it into Oce....

Read more »

Using memoise to cache R values

April 12, 2014
By

Introduction The memoise package can be very handy for caching the results of slow calculations. In interactive work, the slowest calculations can be reading data, so that is demonstrated here. The microbenchmark package shows timing results. Methods and results Setup First, load the package being tested, and also a benchmarking package. 1 2 library(memoise) library(microbenchmark) Test conventional function The demonstration will be for reading a CTD file. 1 library(oce) ##...

Read more »