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 ... [Read more...]

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 ... [Read more...]

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, ... [Read more...]

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 ... [Read more...]

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 10period [Read more...]

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 ... [Read more...]

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 ... [Read more...]

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 ... [Read more...]

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 ... [Read more...]

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 ... [Read more...]

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 ... [Read more...]

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 ... [Read more...]

This follows an item about GMT colours. In the meantime I have found a website illustrating the colours, and also the definition files for those palettes.
The palette in question is named GMT_relief, and it is defined in a file that is as follows.

<span># $Id: GMT_relief.cpt,v 1.1 2001/09/23 23:11:20 pwessel Exp $</span> <span>#</span> <span># Colortable for whole earth relief used in Wessel topomaps</span> <span># Designed by P. Wessel and F. Martinez, SOEST</span> <span># COLOR_MODEL = RGB</span> -8000 0 0 0 -7000 0 5 25 -7000 0 5 25 -6000 0 10 50 -6000 0 10 50 -5000 0 80 125 -5000 0 80 125 -4000 0 150 200 -4000 0 150 200 -3000 86 197 184 -3000 86 197 184 -2000 172 245 168 -2000 172 245 168 -1000 211 250 211 -1000 211 250 211 0 250 255 255 0 70 120 50 500 120 100 50 500 120 100 50 1000 146 126 60 1000 146 126 60 2000 198 178 80 2000 198 178 80 3000 250 230 100 3000 250 230 100 4000 250 234 126 4000 250 234 126 5000 252 238 152 5000 252 238 152 6000 252 243 177 6000 252 243 177 7000 253 249 216 7000 253 249 216 8000 255 255 255 F 255 255 255 B 0 0 0 N 255 255 255R code to read ... [Read more...]

I enjoyed the blog posting by “me nugget”, which I ran across on R-bloggers, and so I decided to try that author’s GMT colourscheme. This revealed some intriguing patterns in the Oce dataset named topoWorld. The following code produces a graph to illustrate.
1. Set up colours as suggested on ... [Read more...]

Analysis
District-by-district data reveal that if the Bloc Quebecois, Green, Liberal, and NDP parties were to have been united, the Conservative party would have lost the 41st Canadian election by a dramatic measure, instead of winning a majority.
The graph given below shows the results by naming the ridings. Clicking ... [Read more...]

Introduction
R provides functions for both one-dimensional and multi-dimensional optimization. The second topic is much more complicated than the former (see e.g. Nocedal 1999) and will be left for another day.
A convenient function for 1D optimization is optimize(), also known as optimise(). Its first argument is a function whose ... [Read more...]

Introduction
The base R system provides lapply() and related functions, and the package plyr provides alternatives that are worth considering. It will be assumed that readers are familiar with lapply() and are willing to spend a few moments reading the plyr documentation, to see why the illustration here will use ... [Read more...]

Abstract R code is provided in aide of laboratory demonstration of
cabelling.
Introduction
Setting up a cabelling experiment requires creating two watermasses of equal density, and if only S and T can be measured, that means calculating densities. Using a TS diagram and graphical interpolation is one approach to that ... [Read more...]

Introduction
In Oceanography it can be useful to use colour to display z values along an (x,y) trajectory. For example, CTD data might be displayed in this way, with x being distance along track, y being depth, and z being temperature. This post shows how one might do this.
... [Read more...]

Introduction
Butterworth filters with order other than 1 have an overshoot phenomenon that can be problematic in some cases. For example, if smoothing is used on an estimate of kinetic energy, overshoots might yield negative values that are nonphysical. This post simply illustrates this with made-up data that the reader can ... [Read more...]

Copyright © 2022 | MH Corporate basic by MH Themes

e-mails with the latest R posts.

(You will not see this message again.)