23 min read

Access Southern Oscillation Index Data with rsoi package in R

Introduction

The Southern Oscillation Index (SOI) is defined as the standardized difference between barometric pressure between Tahiti and Darwin, Australia. The SOI is one measure of the large-scale fluctuations in air pressure occurring between the western and eastern tropical Pacific (i.e., the state of the Southern Oscillation) during El Niño and La Niña episodes. In general, smoothed time series of the SOI correspond very well with changes in ocean temperatures across the eastern tropical Pacific.

The negative phase of the SOI represents below-normal air pressure at Tahiti and above-normal air pressure at Darwin. Prolonged periods of negative (positive) SOI values coincide with abnormally warm (cold) ocean waters across the eastern tropical Pacific typical of El Niño (La Niña) episodes. The information of the methodology used to calculate SOI is available at the Climate Prediction Center SOI page.

Sam Albers (2020) developed a rsoi package that provide tools to access Various Northern and Southern Hemisphere Climate Indices. Some of these indices include;

  1. Southern Oscillation Index
  2. Oceanic Nino Index
  3. North Pacific Gyre Oscillation
  4. North Atlantic Oscillation
  5. Arctic Oscillation
  6. Antarctic Oscillation
  7. Multivariate ENSO Index Version 2

In this post I will take you through how to install the package and download the data and plot the downloaded data. The rsoi package is available from the The Comprehensive R Archive Network (CRAN) and you can install using the chunk below

install.packages("rsoi")

Once you have installed the package you need to load the package into the session to access its functions. First we need to load the package into the session using the require function as highlighted in the chunk below. I also load the tidyverse package (Wickham 2017), which contains tools that I will use for data manipulation and plotting.

require(rsoi)
require(tidyverse)

The good thing about the **rsoi* is that all functions to download the indices begin with the world dowload_ followed by the specific index. For instance, the function download_soi is used to access and download the Southern Oscillation Index data.

soi = download_soi()

The SOI data that we have just downloaded is in data frame format and we can check the internal structure of the dataset using either str function from base R or glimpse function from dplyr package (Wickham et al. 2018). Table 1 shows the sample of the southern Oscillation Index values that we just downloaded.

Table 1: Sample of the southern Oscillation Index
Year Month Date SOI
1951 Mar 1951-03-01 -0.1
1951 Apr 1951-04-01 -0.3
1951 May 1951-05-01 -0.7
1951 Jun 1951-06-01 0.2
1951 Jul 1951-07-01 -1.0
2019 Aug 2019-08-01 -0.1
2019 Sep 2019-09-01 -1.2
2019 Oct 2019-10-01 -0.4
2019 Nov 2019-11-01 -0.8
2019 Dec 2019-12-01 -0.6
2020 Jan 2020-01-01 0.2

Once we have have the data we can plot to them to visualize the periods of negative (positive) SOI values, which coincide with abnormally warm (cold) ocean waters across the eastern tropical Pacific typical of El Niño (La Niña) episodes. The figure 1 that show the SOI oscillation was plotted using the tools in ggplot2 package (Wickham 2016).

soi.status = soi %>% mutate(status = if_else(SOI >= 0, "positive", "negative"))

soi.plot = ggplot(data = soi.status, aes(x = Date, y = SOI, fill = status))+
  geom_col()+
  # ggsci::scale_fill_d3() +
  scale_fill_manual(values = c("red", "blue")) +
  cowplot::theme_minimal_grid()+
  labs(x = "", y = "SOI Index") +
  scale_y_continuous(breaks = seq(-3,3,1)) +
  # scale_x_date(date_breaks = "10 years", date_labels = "%Y")+
  theme(legend.position = "none", panel.grid = element_line(linetype = "dotted"))

soi.plot %>% plotly::ggplotly()

Figure 1: Southern Oscillation Index (SOI). Place mouse on a plot and window will popup that allows you to interact with the plot.

Summary

We have seen how to access SOI data in R using the rsoi and plot the value with ggplot2 package. Note that isn’t the only index you can get its data. rsoi package offers you more function to download other indices introduced in this post. You can explore more of other indices and get the data using almost similar catalytic approach explained in this post.

Reference

Albers, Sam. 2020. Rsoi: Import Various Northern and Southern Hemisphere Climate Indices. https://CRAN.R-project.org/package=rsoi.

Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. http://ggplot2.org.

———. 2017. Tidyverse: Easily Install and Load the ’Tidyverse’. https://CRAN.R-project.org/package=tidyverse.

Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2018. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.