Blog Archives

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 »

Sun and moon paths in daily sky

March 22, 2014
By
Sun and moon paths in daily sky

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

Read more »

Box models in R

March 16, 2014
By
Box models in R

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

Read more »

Digitizing plots

March 12, 2014
By
Digitizing plots

Introduction It is not uncommon to want to digitize values from a graph in a paper, whether to do some initial analysis without bothering an author, or to get data from a paper published so long ago that the data are available only graphically. Although there are several software applications that do this well, it is also possible to...

Read more »