Introduction

Sea surface temperatures have a large influence on climate and weather specially in the Northern Indian Ocean. We know, Indian Ocean is the only ocean with a land boundary in its northern part. Because of land area, climate of the coastal countries around it is different than others. Sea surface temperature plays an important role for this climate variability and seasonality in the Indian Ocean.

Data

Sea surface temperature data for this analysis is extracted from The NOAA Physical Science Laboratory (PSL).
Detailed Description:
The monthly Extended Reconstructed Sea SurfaceTemperature(ERSST)dataset,available onglobal 2x2 grids, has been revised herein to version 4 (v4) from v3b. ERSST v4 revisions are based on ERSST v3b. Major improvements include updated and substantially more complete input data from the ICOADS Release 2.5, revised Empirical Orthogonal Teleconnections (EOTs) and EOT acceptance criterion, updated sea surface temperature (SST) quality control procedures, revised SST anomaly (SSTA) evaluation methods, revised low-frequency data filing in data sparse regions using nearby available observations, updated bias adjustments of ship SSTs using Hadley Nighttime Marine Air Temperature version 2 (HadNMAT2), and buoy SST bias adjustments not previously made in v3b. These revisions and their associated improvements are justified in part by subsampling the observations of the modern period (1960–2012) using historical observation masks from the period 1860–1912. The monthly analysis extends from January 1854 to the present, but because of sparse data in the early years, there is damping of the analyzed signal before 1880. After 1880, the strength of the signal is more consistent over time. ERSST is suitable for long-term global and basin-wide studies, and smoothed local and short-term variations are used in the dataset. For more information see https://www.ncdc.noaa.gov/data-access/marineocean-data/extended-reconstructed-sea-surface-temperature-ersst-v4.

Code

#Required packages
library(ncdf4)
library(lubridate)
library(tidyverse)
library(ggeasy)
library(maps)
library(mapproj)
library(maptools)
library(mapdata)
library(RColorBrewer)
library(stargazer)

Area of Interest

library(ggplot2)
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(ggspatial)
theme_set(theme_bw())

world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
## [1] "sf"         "data.frame"
#plot the area of interest
ggplot(world)+geom_sf(fill="lightblue",color="black" )+coord_sf(xlim = c(80,100),ylim = c(12,25),expand = FALSE)+xlab("Longitude")+ylab("Latitude")+annotation_scale(location="bl",width_hint=0.5)+annotation_north_arrow(location="bl",which_north="true",pad_x = unit(0.55, "in"), pad_y = unit(0.4, "in"),style = north_arrow_fancy_orienteering)+annotate(geom = "text", x = 90, y = 18, label = "Bay of Bengal", fontface = "italic", color = "grey22", size = 5)+annotate(geom = "text", x = 90, y = 24, label = "Bangladesh", color = "black", size = 2.5)+annotate(geom = "text", x = 83, y = 22, label = "India", color = "black", size = 2.5)+annotate(geom = "text", x = 96, y = 21, label = "Myanmar",color = "black", size = 2.5)

#load the data(.nc file)in the environment
nc <- nc_open("1854-2020sst.mnmean.v4.nc")

##Extract the variable(lon,lat,time)
#extract variable
lon <- ncvar_get(nc,"lon")
lat <- ncvar_get(nc,"lat")
time <- ncvar_get(nc,"time")

#here time variable is in numeric form,lets convert it into Date format
time <- as.Date(time,origin="1800-1-1 00:00:00",tz="UTC")
#our area of interest is the Bay of Bengal region which is the northern part of the Indian Ocean. we extract longitude from 80E to 100E and latitude from 12N to 25N.
## cropping the Bay of Bengal region
lon_lim <- c(80,100)
lat_lim <- c(12,25)

#we want sst record from 1880 to 2020 but our data has record from 1854. so lets extract the time range as well the lat/lon
time_lim <- c(ymd("1880-01-01"),ymd("2020-01-01"))

lon_ind <- which(lon >= lon_lim[1] & lon <= lon_lim[2])
lat_ind <- which(lat >= lat_lim[1] & lat <= lat_lim[2])
time_ind <- which(time >= time_lim[1] & time <= time_lim[2]) 

#now,lets extract the sst variable from our .nc file according to our need
sst <- ncvar_get(nc,"sst",start=c(lon_ind[1],lat_ind[1],time_ind[1]),count = c(length(lon_ind),length(lat_ind),length(time_ind)))
dim(sst) #3 dimensional
## [1]   11    7 1681
##now,lets extract the 1 dimensional timeseries averaging the lat-lon
ts_sst <- apply(sst,3,mean,na.rm=TRUE)
year <- time[time_ind]
dim(ts_sst)
## NULL
#now,lets plot the time series using ggplot
tempseries <- data.frame(year=year,sst=ts_sst)

tempseries %>% ggplot(aes(x=year,y=ts_sst))+geom_line(alpha=0.4)+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "Monthly averaged SST in the Bay of Bengal from 1880 to 2020", x="year",y="Temperature" )+ scale_y_continuous(breaks = seq(20,35,0.5))+ggeasy::easy_rotate_x_labels()+theme_classic()

Monthly analysis

We will now analyze the time-series of SST of every single months.

##creat a dataframe with extra column `month` presenting factor of months   
tempseries <- tempseries %>% mutate(month=months(tempseries[,1]))
tempseries <- tempseries %>% mutate(fmonth=factor(tempseries$month,levels=c("January","February","March","April","May","June","July","August","September","October","November","December")))

#Filter sst timeseries of every single month
jan_sst <- tempseries %>% filter(month == "January")
feb_sst <- tempseries %>% filter(month == "February")
mar_sst <- tempseries %>% filter(month == "March")
apr_sst <- tempseries %>% filter(month == "April")
may_sst <- tempseries %>% filter(month == "May")
jun_sst <-tempseries %>% filter(month == "June")
july_sst <-tempseries %>% filter(month == "July")
aug_sst <-tempseries %>% filter(month == "August")
sep_sst <-tempseries %>% filter(month == "September")
oct_sst<-tempseries %>% filter(month == "October")
nov_sst <-tempseries %>% filter(month == "November")
dec_sst <-tempseries %>% filter(month == "December")

##Now,plot every months time series 
jan_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "January", x="year",y="SST(C)",caption="Time series of monthly SST for January,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(25,28,0.2))+theme_classic()

feb_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "February", x="year",y="SST(C)",caption="Time series of monthly SST for February,
versus time in years. The linear trend in least
square sense is shown " )+ theme_update(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(23,28.2,0.2))+theme_classic()

mar_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "March", x="year",y="SST(C)",caption="Time series of monthly SST for March,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(25.8,29.4,0.2))+theme_classic()

apr_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "April", x="year",y="SST(C)",caption="Time series of monthly SST for April,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(27,30.6,0.2))+theme_classic()

may_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "May", x="year",y="SST(C)",caption="Time series of monthly SST for May,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(28,31,0.2))+theme_classic()

jun_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "June", x="year",y="SST(C)",caption="Time series of monthly SST for June,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(27,31,0.2))+theme_classic()

july_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "July", x="year",y="SST(C)",caption="Time series of monthly SST for July,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(27,30,0.2))+theme_classic()

aug_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "August", x="year",y="SST(C)",caption="Time series of monthly SST for August,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(27,30.6,0.2))+theme_classic()

sep_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "September", x="year",y="SST(C)",caption="Time series of monthly SST for September,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(26,30,0.2))+theme_classic()

oct_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "October", x="year",y="SST(C)",caption="Time series of monthly SST for October,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(26,30.4,0.2))+theme_classic()

nov_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "November", x="year",y="SST(C)",caption="Time series of monthly SST for November,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(26,30,0.2))+theme_classic()

dec_sst %>% ggplot(aes(x=year,y=sst))+geom_line()+geom_smooth(method = "lm",se=FALSE,size=0.5,color="red")+scale_x_date(limits =ymd(c("1880-01-01","2020-12-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-12-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+labs(title = "December", x="year",y="SST(C)",caption="Time series of monthly SST for December,
versus time in years. The linear trend in least
square sense is shown " )+ theme(plot.title = element_text(hjust = 0.5))+scale_y_continuous(breaks = seq(24,28,0.2))+theme_classic()

#Now,plot monthly sst vs. time
tempseries %>% ggplot(aes(x=year,y=sst,color=fmonth))+geom_line(linetype="solid",size=0.8)+scale_x_date(limits =ymd(c("1880-01-01","2020-01-01")) ,breaks = seq(ymd("1880-01-01"),ymd("2020-01-01"),"10 years"),minor_breaks = "1 years",date_labels ="%Y")+ scale_y_continuous(breaks = seq(20,35,1))+theme_classic()+labs(caption = "(Monthly SST versus time,in years)",x="year",y="SST(C)")+theme(legend.title = element_blank(),legend.key.size=unit(0.5,"cm"),legend.key.width = unit(1,"cm"))+scale_color_brewer(type='seq',palette='Oranges')

Monthly Summary statistics

summary <- data.frame(January=head(jan_sst$sst,140),February=feb_sst$sst,March=mar_sst$sst,April=apr_sst$sst,May=may_sst$sst,June=jun_sst$sst,July=july_sst$sst,August=aug_sst$sst,September=sep_sst$sst,October=oct_sst$sst,November=nov_sst$sst,December=dec_sst$sst)

library(htmlTable)
## apply a list of functions to a list or vector
f <- function(X, FUN, ...) {
  fn <- as.character(match.call()$FUN)[-1]
  out <- sapply(FUN, mapply, X, ...)
  setNames(as.data.frame(out), fn)
}

out <- round(f(summary, list(mean, sd, median, min, max)), 2)
htmlTable(out, cgroup = 'Statistic', n.cgroup = 5, caption = 'Monthly SST statistics from 1880 to 2020',css.cell = 'padding: 0px 10px 0px;')
Monthly SST statistics from 1880 to 2020
Statistic
mean sd median min max
January 26.32 0.46 26.3 25.35 27.84
February 26.63 0.47 26.61 24.56 27.94
March 27.78 0.43 27.77 26.81 29.03
April 29.11 0.43 29.1 27.97 30.27
May 29.7 0.42 29.74 28.6 30.72
June 29.31 0.51 29.33 27.85 30.86
July 28.72 0.51 28.67 27.15 29.9
August 28.5 0.41 28.47 27.04 29.57
September 28.72 0.46 28.72 26.37 29.64
October 28.86 0.5 28.85 27.04 30.25
November 28.18 0.5 28.18 26.27 29.27
December 26.96 0.55 26.98 24.48 28.35