# Blog Archives

November 9, 2014
By

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,...

## landsat thermal imaging

July 1, 2014
By

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...

## Gulf Stream centre detection

June 22, 2014
By

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...

## DE solution in R (nonlinear oscillator)

June 15, 2014
By

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 ...

## slumping model

June 8, 2014
By

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 a...

## 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 ...

## colormap

April 30, 2014
By

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....

## 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) ##...

## Sun and moon paths in daily sky

March 22, 2014
By

Introduction This blog started because I was interested in the sunrise position on the winter solstice of 2013. With the Spring equinox, I’m trying something different: plotting the paths of the sun and moon through the day. The code shown here produces a daily graph, and I have a cron job running on a machine so that this graph is...

## Box models in R

March 16, 2014
By

Introduction Box models are popular in some branches of oceanography and other geophysical disciplines, partly because they are simple to construct and to solve. This posting shows how to solve a box model in R, using the lsoda() function in the deSolve package. The basic ideas can be explained in the context of riverine input into a lake that connects...