30 min read

Easy access of El Nino-Southern Oscillation data in R

El Niño-Southern Oscillation (ENSO) is one of the most important climate phenomena on Earth due to its ability to change the global atmospheric circulation, which in turn, influences temperature and precipitation across the globe. ENSO is a recurring climate pattern involving changes in the temperature of waters in the central and eastern tropical Pacific Ocean. On periods ranging from about three to seven years, the surface waters across a large swath of the tropical Pacific Ocean warm or cool by anywhere from 1°C to 3°C, compared to normal.

This oscillating warming and cooling pattern, referred to as the ENSO cycle, directly affects rainfall distribution in the tropics and can have a strong influence on weather across the United States and other parts of the world. El Niño and La Niña are the extreme phases of the ENSO cycle; between these two phases is a third phase called ENSO-neutral.

  • El Niño: A warming of the ocean surface, or above-average sea surface temperatures (SST), in the central and eastern tropical Pacific Ocean. Over Indonesia, rainfall tends to become reduced while rainfall increases over the central and eastern tropical Pacific Ocean. The low-level surface winds, which normally blow from east to west along the equator (“easterly winds”), instead weaken or, in some cases, start blowing the other direction (from west to east or “westerly winds”). In general, the warmer the ocean temperature anomalies, the stronger the El Niño (and vice-versa).

  • La Niña: A cooling of the ocean surface, or below-average sea surface temperatures (SST), in the central and eastern tropical Pacific Ocean. Over Indonesia, rainfall tends to increase while rainfall decreases over the central and eastern tropical Pacific Ocean. The normal easterly winds along the equator become even stronger. In general, the cooler the ocean temperature anomalies, the stronger the La Niña (and vice-versa).

  • Neutral: Neither El Niño or La Niña. Often tropical Pacific SSTs are generally close to average. However, there are some instances when the ocean can look like it is in an El Niño or La Niña state, but the atmosphere is not playing along (or vice versa).

Sam Albers (2020) developed a rsoi package that made access and download of ENSO data with easy. In this post I will focus on getting the ENSO data and work in R. 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.

enso = rsoi::download_enso()

The enso 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 El Niño-Southern Oscillation that we just downloaded.

Table 1: Sample of the El Niño-Southern Oscillation
Date ONI phase SOI NPGO
1951-08-01 0.89 Warm Phase/El Nino -0.2 -1.17
1951-12-01 0.81 Warm Phase/El Nino -0.7 -1.22
1951-02-01 -0.54 Cool Phase/La Nina 0.9 -0.41
1951-07-01 0.70 Warm Phase/El Nino -1.0 -1.10
1951-06-01 0.59 Warm Phase/El Nino 0.2 -1.44
2019-02-01 0.82 Warm Phase/El Nino -1.4 -2.41
2019-01-01 0.80 Warm Phase/El Nino 0.0 -0.45
2019-07-01 0.30 Neutral Phase -0.4 -2.28
2019-06-01 0.52 Warm Phase/El Nino -0.5 -1.99
2019-03-01 0.80 Warm Phase/El Nino -0.3 -2.11
2019-05-01 0.63 Warm Phase/El Nino -0.4 -1.76

Looking the ENSO data in table 1 hide important patterns of El Niño (La Niña) episodes. The chunk below highlight the lines of code from ggplot2 package (Wickham 2016) used to generate figure 1 that show clearly the periods of ENSO phases over time.

enso.plot = ggplot(data = enso, aes(x = Date, y = ONI, fill = phase))+
  geom_col()+
  # ggsci::scale_fill_jama() +
  scale_fill_manual(values = c("blue","green", "red"), name = "") +
  cowplot::theme_minimal_grid()+
  labs(x = "", y = "ENSO Index") +
  theme(legend.position = "top", panel.grid = element_line(linetype = "dotted"))

enso.plot %>% 
  plotly::ggplotly() %>%
  plotly::layout(legend = list(orientation = "h", x = 0.4, y = 1.1))

Figure 1: El Niño-Southern Oscillation episodes. Place mouse on a plot and window will popup that allows you to interact with the plot.

Summary

We have seen how to access ENSO data in R using the rsoi and plot the value with ggplot2 package. In the previous post we accessed and plotted SOI. 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.

References

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.