Timeseries of frontal areas size¶

Author: Kai Yang

Manuscript: Global trends in ocean fronts: impacts on air-sea CO2 flux and chlorophyll concentrations

Creation date: 2024-Aug-21

Latest update: 2025-Jun-03

This Jupyter notebook produces Supplementary Fig. 3 of the manuscript.

In [1]:
# Import libraries
import xarray as xr
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt 
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
from matplotlib import ticker
/Users/kyang7/anaconda3/lib/python3.11/site-packages/pandas/core/arrays/masked.py:60: UserWarning: Pandas requires version '1.3.6' or newer of 'bottleneck' (version '1.3.5' currently installed).
  from pandas.core import (
In [2]:
# Import plot utilities
from plot_utils_v2 import (significance_mk, compute_trends)
In [3]:
# read timeseries of area size (key, intensifying, and declining frontal areas)
dataset1 = xr.open_dataset('../datasets/size_timeseries/timeseries_key_area_2025.nc')
dataset2 = xr.open_dataset('../datasets/size_timeseries/timeseries_intensify_decline_mean_threshold_2025.nc')
key = dataset1.key_value
intensify = dataset2.intensify_value
decline = dataset2.decline_value
In [4]:
# calculate trends
slope_key, intercept_key  = compute_trends(key)
slope_intensify, intercept_intensify  = compute_trends(intensify)
slope_decline, intercept_decline  = compute_trends(decline)
In [5]:
import matplotlib.font_manager as font_manager
In [6]:
fig = plt.figure(figsize=(5,5),dpi=400)

ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)

colors= ['#F6944B', '#ec3232', '#0787c3']
########################################################################################################################
# Panel a
# plot timeseries and trend line
year1 = np.linspace(2003, 2023, num=21)
year2 = np.linspace(2005, 2021, num = 17)
ts1 = ax1.plot(year1,key, color = colors[0],linewidth = 1)
x = np.linspace(1,21,num=21)
y = slope_key*x+intercept_key
ts1 = ax1.plot(year1,y, color = colors[0],linewidth = 2,linestyle = 'dashed')

# plot settings
xticks = np.arange(2003, 2024, 4)
ax1.set_xticks(xticks)
ax1.set_ylabel('km$^2$',fontname = 'Arial', fontsize=8)
ax1.set_xticklabels([],rotation=90, ha="center",va='top',fontname = 'Arial', fontsize=12)
ax1.set_title(r"a  Key Frontal Areas",fontname = 'Arial', fontsize=9,fontweight = 'bold', loc = 'left')
# ax1.yaxis.set_major_locator(MultipleLocator(5000000))
# ax1.yaxis.set_minor_locator(MultipleLocator(2500000))
ax1.xaxis.set_major_locator(MultipleLocator(2))
ax1.xaxis.set_minor_locator(MultipleLocator(1))
ax1.set_ylim(68000000,80000000)
ax1.tick_params(axis='y', labelsize=7)
formatter = ticker.ScalarFormatter(useMathText=True)
formatter.set_scientific(True) 
formatter.set_powerlimits((-1,1)) 
ax1.yaxis.set_major_formatter(formatter)
ax1.yaxis.tick_right()
ax1.yaxis.set_label_position("right")

# label 
ax1.text(2019.5,78000000,'+0.11 %/year',color = colors[0],fontname = 'Arial', fontsize = 7,fontweight = 'bold')

########################################################################################################################
# Panel b
# plot timeseries and trend lines
ts1 = ax2.plot(year2,intensify, color = colors[1],linewidth = 1)
ts2 = ax2.plot(year2,decline, color = colors[2],linewidth = 1)
x = np.linspace(1,21,num=21)
y = slope_intensify*x+intercept_intensify
ts1 = ax2.plot(year1,y, color = colors[1],linewidth = 2,linestyle = 'dashed')
x = np.linspace(1,21,num=21)
y = slope_decline*x+intercept_decline
ts2 = ax2.plot(year1,y, color = colors[2],linewidth = 2,linestyle = 'dashed')

# plot settings
xticks = np.arange(2003, 2024, 4)
ax2.set_xticks(xticks)
ax2.set_ylabel('km$^2$',fontname = 'Arial', fontsize=8)
ax2.set_title(r"b  Intensify & Declining Frontal Area",fontname = 'Arial', fontsize=9,fontweight = 'bold', loc = 'left')
ax2.xaxis.set_major_locator(MultipleLocator(2))
ax2.xaxis.set_minor_locator(MultipleLocator(1))
# ax2.yaxis.set_major_locator(MultipleLocator(10000000))
# ax2.yaxis.set_minor_locator(MultipleLocator(5000000))
ax2.set_xlim(2002,2024)
ax2.set_ylim(1000000,9000000)
ax2.tick_params(axis='y', labelsize=7)
ax2.tick_params(axis='x', labelsize=7)
formatter = ticker.ScalarFormatter(useMathText=True)
formatter.set_scientific(True) 
formatter.set_powerlimits((-1,1)) 
ax2.yaxis.set_major_formatter(formatter)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position("right")
# ax2.set_yticks([30000000,40000000,50000000,60000000,70000000,80000000])
# ax2.set_yticklabels([3,4,5,6,7,8],fontname = 'Arial')
ax2.set_xticks([2002, 2004, 2006,2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024])
ax2.set_xticklabels([2002, 2004, 2006,2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024],fontname = 'Arial')

# labels and legend
font = font_manager.FontProperties(family='Arial',size = 7)
ax2.legend(["Intensifying Frontal Areas", "Declining Frontal Areas"], loc="upper left", ncol=1, prop=font)
ax2.text(2019.5,7200000,'+3.16 %/year',color = colors[1],fontname = 'Arial', fontsize = 7,fontweight = 'bold')
ax2.text(2019.5,8000000,'+1.05 %/year',color = colors[2],fontname = 'Arial', fontsize = 7,fontweight = 'bold')


plt.plot()


plt.savefig('../JPEG/FigS3_frontal_areas_size_timeseries.jpeg',dpi=400,bbox_inches='tight')

Supplementary Figure 3 Time series (2003–2023) and linear trends of frontal area size (in km² per year) for key frontal areas (a), intensifying frontal areas (b; red), and declining frontal areas (b; blue). The sizes of intensifying and declining frontal areas are calculated using a five-year moving window. None of the three trends shown are statistically significant.

:)

In [ ]: