-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_GMT_pdf.py
More file actions
34 lines (32 loc) · 1.17 KB
/
plot_GMT_pdf.py
File metadata and controls
34 lines (32 loc) · 1.17 KB
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
############################################################
# this program plots the PDF of the global mean temperature
############################################################
from netCDF4 import Dataset, date2index
import numpy as np
import netCDF4 as nc
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.stats import norm,gaussian_kde
# read gmt from SCM
file = 'IPCCAR5climsens_rcp85_DAT_SURFACE_TEMP_BO_15Nov2013_185227.OUT'
data = np.loadtxt(file, skiprows=24)
year0 = data[:,0]
gmt = data[(year0>=2080)&(year0<=2099),1:]
gmt_ref = data[(year0>=1986)&(year0<=2005),1:]
gmt_refm = np.mean(gmt_ref,0).reshape(1,600)
gmt_m = np.tile(gmt_refm,(20,1))
gmt_scm = gmt-gmt_m
gmtm = np.mean(gmt_scm,0)
# plot probability density function
pdf = norm.pdf(gmtm)
kde = gaussian_kde(gmtm,bw_method=0.45)
t_range = np.linspace(0,10,101)
fig = plt.figure(figsize=[8, 7])
plt.plot(t_range,kde(t_range), linewidth=3, color='steelblue')
plt.ylabel('Probability Density',fontsize=15)
plt.xlabel('2080-2099 Global Mean Temperature Anomaly ($^\circ$C)',fontsize=15)
plt.ylim(0, 0.45)
plt.xlim(0,10)
fig_name = 'PDF_golobal_mean_temp_2080-2099.pdf'
fig.savefig(fig_name, dpi=300)
plt.close(fig)