Blog Archives

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 »

N2 with runlm()

February 9, 2014
By
N2 with runlm()

Introduction The default swN2() calculation in Oce uses a smoothing spline. One disadvantage of this is that few readers will know how it works. A possible alternative is to compute d(rho)/dz using the slope inferred from a running-window linear regression. Such a slope is provided by the new Oce function runlm(), which is tested here. (Note...

Read more »

Hodograph drawing

February 8, 2014
By
Hodograph drawing

Introduction The polar graph known as a hodograph can be useful for vector plots, and also for showing varition within nearly-cyclical time series data. The Oce R package should have a function to create hodographs, but as usual my first step is to start by writing isolated code, testing to find the right match between the function and real-world...

Read more »

Spline wiggles (II)

February 4, 2014
By
Spline wiggles (II)

Introduction This follows up on the previous posting, using data provided by Akima (1972). The four panels of the plot produced by the following code compare the original Akima spline formula with an improved version, and three styles of spline() fits. As noted in the code, two spline() methods are useless for general tasks and are ignored here....

Read more »

Spline wiggles (I)

February 3, 2014
By
Spline wiggles (I)

Introduction An interesting paper (Smith and Wessel, 1990) points out a weakness in using splines in cases with data gaps. Their illustration of the problem with isobaths was particularly compelling. I cannot reproduce their Fig 1b here, owing to copyright problems, but I digitized the data so I could test two R functions for splines. Readers can...

Read more »