Blog Archives

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 »

Error bars in R

March 5, 2014
By
Error bars in R

Introduction Error propagation can be a fair bit of work with a calculator, but it’s easy with R. Just use R in repeated calculation with perturbed quantities, and inspect the range of results. Two methods are shown below for inspecting the range: sd() and quantile(), the latter using the fact that area under a normal distribution is 0.68...

Read more »

Oce translations

February 26, 2014
By
Oce translations

A new Oce user wondered how to get Spanish labels on axes. This is easy for some plot types because xlab and ylab arguments are obeyed, but in many cases the labels are generated by the code. That meant that it was finally time for me to start localizing Oce, using the GNU gettext scheme. ...

Read more »

Improved filtfilt() for R

February 19, 2014
By
Improved filtfilt() for R

The filtfilt function in R is supposedly based on the Matlab one, but it does quite badly on endpoints. My goal here is to explore alternatives, with a focus on the Octave method. NOTE: I may also try scipy for hints.) The best method of dealing with endpoints is still an open question. Matlab does one thing, Octave...

Read more »

demodulating time series

February 17, 2014
By
demodulating time series

This posting shows how one might perform demodulation in R. It is assumed that readers are generally familiar tith the procedure. First, create some fake data, a carrier signal with period 10, modulated over a long timescale, and with phase drifting linearly over time. 1 2 3 4 5 6 7 8 9 10 period <- 10 fc <- 1/period fs <- 1 n...

Read more »

Valentines-day full moon

February 13, 2014
By
Valentines-day full moon

Introduction A wise person told me that it will be a full moon on the upcoming Valentine’s Day, but that it will be a long time until another one. I decided to check this with astronomical calculation. Procedure The Oce package has a function called moonAngle() that returns, among other things, the illuminated fraction of the moon visible at any given...

Read more »

oce runlm function

February 11, 2014
By
oce runlm function

Introduction As was expected, the runderiv() function has been both useful and deficient. Useful because it offers a good replacement for smooth.spline() calculations of derivatives for things like N^2. And deficient because it only calculated derivatives, not values! Both an extension and a renaming were called for. The result is runlm(). Tests Below are the examples from its manpage, with...

Read more »

oce map projection

February 10, 2014
By
oce map projection

Introduction Soon after map projections were added to Oce, bug reports showed that coastline plots in some projections were subject to anomalous lines that run horizontally on the plot. A ad-hoc scheme was code to try to prevent this, but it does not always work. Problems are compounded for filled coastlines. I had thought this was a basic problem...

Read more »