-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeaLevelandTempRise.m
137 lines (132 loc) · 3.7 KB
/
SeaLevelandTempRise.m
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
%Jerad King, Toby Haight, Mitchtell Bonvillian, Brad Jennings
%Obsv Climate Data, 1880-2019
ncid1 = netcdf.open ("gistemp1200.nc");
ncdisp("gistemp1200.nc");
ncinfo("gistemp1200.nc");
filename = 'gistemp1200.nc';
variables_to_load = {'time', 'lat', 'lon', 'time_bnds', 'tempanomaly'};
j=1:numel(variables_to_load);
var = variables_to_load{j};
data_struct.(var) = ncread(filename,var);
isa(data_struct.(var),'single');
data_struct.(var) = double(data_struct.(var));
temp = ncread('gistemp1200.nc','tempanomaly');
TS = [1:140];
%Obsv data Permute
m = permute(temp, [3,1,2]);
n = nanmean(m, 3);
t = nanmean(n, 2);
xx=reshape(t(1:1680),12,[]);
tf = sum(xx)/12;
%%
%Projected climate data
ncid1 = netcdf.open ("TSamon.nc");
ncdisp("TSamon.nc");
ncinfo("TSamon.nc");
filename = 'TSamon.nc';
variables_to_load = {'time','time_bnds', 'lat','lat_bnds', 'lon','lon_bnds', 'ts'};
ncid1 = netcdf.open ("TSamon.nc");
ncdisp("TSamon.nc");
ncinfo("TSamon.nc");
filename = 'TSamon.nc';
variables_to_load = {'time','time_bnds', 'lat','lat_bnds', 'lon','lon_bnds', 'ts'};
% loop over the variables
for j=1:numel(variables_to_load);
% extract the jth variable (type = string)
var = variables_to_load{j};
% use dynamic field name to add this to the structure
data_struct.(var) = ncread(filename,var);
% convert from single to double, if that matters to you (it does to me)
if isa(data_struct.(var),'single');
data_struct.(var) = double(data_struct.(var));
end
end
temp = ncread(filename,'ts');
%Projected permute
m1 = permute(temp, [3,1,2]);
n1 = nanmean(m1, 3);
t1 = nanmean(n1, 2);
%%
%Obsv Fit
tfTemp = tf([21:126]);
TStemp = TS([21:126]);
%Projection Poly Fit
xx1=reshape(t1(1:1140),12,[]);
yy1 = (sum(xx1,1)./size(xx1,1)-277);
tt1 = [1:95];
TTemp = [tf(21:126), yy1(1:95)];
TempYear = [1:201];
TempProjPOLYFIT = polyfit(TempYear, TTemp,7);
p1 = -2.604e-14;
p2 = 2.002e-11;
p3 = -6.254e-09;
p4 = 9.904e-07;
p5 = -8.003e-05;
p6 = 0.003054;
p7 = -0.03766;
p8 = -0.2366;
TempProjFit = p1.*TempYear.^7 + p2.*TempYear.^6 + p3.*TempYear.^5 + p4.*TempYear.^4 + p5.*TempYear.^3 + p6.*TempYear.^2 + p7.*TempYear + p8;
%%
%Temp Projection Plot
figure(1)
plot(TempYear(1:106), TTemp(1:106), '-b', 'linewidth', 1.8)
hold on
plot(TempYear, TempProjFit, '-r', 'linewidth',1.25)
hold off
xticklabels({1900:50:2100})
xlim([0 200])
ylabel('Temperature (C)')
xlabel('Year')
legend('Obs', 'BAU','Location','northwest')
title('Observed and Simulated Global Mean Surface Temperature')
legend boxoff
%%
GMSL = importdata('GMSLyear.txt');
TwentyGMSL = (((GMSL(21:121, 2)))/10)+13.1;
ntf = tf(21:121);
years = [1:101];
figure(2)
plot(years, TwentyGMSL,'-b','linewidth',1.5)
xticklabels({1900:20:2000})
xlim([0 100])
xlabel('Year')
ylabel('GMSL (cm)')
title('20th Century Global Mean Sea Level')
%%
%Observed SLRR
Htdt1 = TwentyGMSL(:);
year = years(:);
Htdt2 = diff(Htdt1);
Htdt = Htdt2(:);
Gt1 = ntf(1:100);
Gt = Gt1(:);
Gto = .1390;
Gtdt1 = diff(Gt1)./diff(year);
Gtdt = Gtdt(:);
a1 = Htdt(:)./(Gt(:)-Gto);
a = mean(a1);
b = (Htdt - (a.*(Gt-Gto)))./Gtdt;
b = -mean(b);
%%
%SLRR Projection
SLRpYears = TempYear;
SLRpTemp = TempProjFit;
GtdtP = SLRpTemp./SLRpYears;
GtoP = ((SLRpTemp([1:201])-SLRpTemp(1)));
%SLRR to SLR Conversion
SLRRP = ((a.*(GtoP)+b.*(GtdtP)));
SLRP = movsum(SLRRP, [201 1]);
%%
%SLR Projection Plot
figure(3)
plot(TempYear, (SLRP-1.5), '-r','linewidth',1.7)
hold on
plot(TempYear(1:101), TwentyGMSL, '-b', 'LineWidth', 1.4)
ylabel('SLR (cm)')
xlabel('Year')
xticklabels({1900:50:2100})
xlim([0 200])
ylim([-5 160])
legend('BAU','Obs','location','northwest')
legend boxoff
title('Observed and Simulated Global Mean Sea Level Rise')