forked from subond/SSS_OHC_TCR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FIG1.py
75 lines (51 loc) · 2.69 KB
/
FIG1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
## load libraries
import numpy as np
import matplotlib.pyplot as plt
########################## running mean funtion ######################
def moving_average(a, n=20) :
ret = np.cumsum(a, dtype=float)
ret[n:] = ret[n:] - ret[:-n]
return ret[n - 1:] / n
################################################################################
#################### Read global mean surf temp time series ####################
################################################################################
yr_start = 101
yr_end = 219
yrs = np.arange(yr_start, yr_end+1, 1)
######################## read Surf Temp data ########################
surfT_ctl = np.loadtxt('t_surf_ctl_'+np.str(yr_start)+'_'+np.str(yr_end)+'_series_raw.txt', delimiter=' ')
surfT_ctlgl = np.loadtxt('t_surf_ctlgl_'+np.str(yr_start)+'_'+np.str(yr_end)+'_series_raw.txt', delimiter=' ')
surfT_2co2std = np.loadtxt('t_surf_2CO2std_'+np.str(yr_start)+'_'+np.str(yr_end)+'_series_raw.txt', delimiter=' ')
surfT_2co2gl = np.loadtxt('t_surf_2CO2gl_'+np.str(yr_start)+'_'+np.str(yr_end)+'_series_raw.txt', delimiter=' ')
surfT_ctl = moving_average(surfT_ctl, n=20)
surfT_ctlgl = moving_average(surfT_ctlgl, n=20)
surfT_2co2std = moving_average(surfT_2co2std, n=20)
surfT_2co2gl = moving_average(surfT_2co2gl, n=20)
#######################################################################################
######################################### plot ########################################
#######################################################################################
fig, axes = plt.subplots(1, 1, figsize = (5/1.5,4/1.5))
plt.rcParams.update({'font.family':'Arial'})
# ax 0
ax = axes
y = np.arange(0,2.9,0.1)
x = 170* np.ones((np.shape(y)[0],1))
ax.plot(x, y, marker=None,linestyle = '-', color='grey')
# plot surf temp
yr_start = 110
yr_end = 210
years = np.arange(yr_start, yr_end, 1)
ax.plot(years,(surfT_2co2std - surfT_ctl), marker=None,color='blue',linestyle = '-', label = 'STD')
ax.plot(years,(surfT_2co2gl - surfT_ctlgl), marker=None,color='blue',linestyle = '--', label = 'GL nudging')
ax.set_xlabel('Year', fontsize = 7)
ax.set_ylabel('K', fontsize = 7)
ax.tick_params(axis="x", labelsize=7)
ax.tick_params(axis="y", labelsize=7)
ax.set_ylim((0., 2.5))
ax.set_xlim((100., 200))
tcr_2co2std = np.str(np.round((surfT_2co2std - np.nanmean(surfT_ctl))[years == 170][0], 1))
tcr_2co2gl = np.str(np.round((surfT_2co2gl - np.nanmean(surfT_ctlgl))[years == 170][0], 1))
ax.text(105, 2.1, 'TCR (STD) = '+tcr_2co2std+' K', color = 'black')
ax.text(105, 1.8, 'TCR (fixed-SSS-GL) = '+tcr_2co2gl+' K', color = 'black')
ax.text(163.6, 0.3, 'CO$_{2}$ doubles', color = 'grey', rotation = 90)
plt.savefig('FIG1.pdf', bbox_inches='tight')