-
Notifications
You must be signed in to change notification settings - Fork 42
/
plot_results.m
119 lines (104 loc) · 4.8 KB
/
plot_results.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
function [ ] = plot_results( selectionParams, targetSa, IMs, simulatedSpectra, SaKnown, knownPer )
%% Produce a number of plots of target and selected response spectra
% Variables used here
% SaKnown : As before, it contains the response spectra of all the
% available ground motions (N*P matrix) - N ground motions,
% P periods
% simulatedSpectra : a matrix of simulated response spectra defined
% only at PerTgt
% sampleBig : Same as SaKnown, but is only defined at PerTgt, the
% periods at which the target response spectrum properties
% are computed
% sampleSmall: The response spectra of the selected ground motions,
% defined at TgtPer
% meanReq : Target mean for the (log) response spectrum
% covReq : Target covariance for the (log) response spectrum
figureFontSize = 18; % font size for figure text
% Plot simulated response spectra
figure
loglog(selectionParams.TgtPer, exp(targetSa.meanReq), '-r', 'linewidth', 3)
hold on
loglog(selectionParams.TgtPer, exp(targetSa.meanReq + 1.96*sqrt(diag(targetSa.covReq))'), '--r', 'linewidth', 3)
loglog(selectionParams.TgtPer, simulatedSpectra', 'k');
loglog(selectionParams.TgtPer, exp(targetSa.meanReq - 1.96*sqrt(diag(targetSa.covReq))'), '--r', 'linewidth', 3)
axis([min(selectionParams.TgtPer) max(selectionParams.TgtPer) 1e-2 5])
xlabel('T (s)')
ylabel('S_a (g)')
legend('Median','2.5 and 97.5 percentile', 'Simulated spectra')
title('Response spectra of simulated ground motion spectra')
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Plot selected response spectra
figure
loglog(selectionParams.TgtPer, exp(targetSa.meanReq), 'b', 'linewidth', 3)
hold on
loglog(selectionParams.TgtPer, exp(targetSa.meanReq + 1.96*sqrt(diag(targetSa.covReq))'), '--b', 'linewidth', 3)
loglog(knownPer,SaKnown(IMs.recID,:).*repmat(IMs.scaleFac,1,size(SaKnown,2)),'k');
loglog(selectionParams.TgtPer, exp(targetSa.meanReq - 1.96*sqrt(diag(targetSa.covReq))'), '--b', 'linewidth', 3)
axis([min(selectionParams.TgtPer) max(selectionParams.TgtPer) 1e-2 5])
xlabel('T (s)');
ylabel('S_a (g)');
legend('Median','2.5 and 97.5 percentile','Selected ground motions');
title ('Response spectra of selected ground motions');
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Target, initial, and finally selected medians
figure
loglog(selectionParams.TgtPer, exp(targetSa.meanReq),'k','linewidth',1)
hold on
loglog(knownPer, exp(IMs.stageOneMeans),'r*--', 'linewidth',1)
loglog(knownPer,exp(mean(log(SaKnown(IMs.recID,:).*repmat(IMs.scaleFac,1,size(SaKnown,2))))),'b--','linewidth',1)
axis([min(selectionParams.TgtPer) max(selectionParams.TgtPer) 1e-2 5])
xlabel('T (s)');
ylabel('Median S_a (g)');
legend('Target', 'Stage 1 selection', 'Final selection');
title('Median Sa (i.e., exp(log mean Sa))')
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Target, initial, and finally selected standard deviations
figure
semilogx(selectionParams.TgtPer,targetSa.stdevs,'k','linewidth',1)
hold on
semilogx(knownPer, IMs.stageOneStdevs,'r*--','linewidth',1)
semilogx(knownPer,std(log(SaKnown(IMs.recID,:).*repmat(IMs.scaleFac,1,size(SaKnown,2)))),'b--','linewidth',1)
axis([min(selectionParams.TgtPer) max(selectionParams.TgtPer) 0 1])
xlabel('T (s)');
ylabel('Standard deviation of lnS_a');
legend('Target', 'Stage 1 selection','Final selection');
title('Logarithmic Sa standard deviations')
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Compute sample correlations from selected spectra
selectedSa = log(SaKnown(IMs.recID,:).*repmat(IMs.scaleFac,1,size(SaKnown,2)));
selectedCorr = corrcoef(selectedSa);
% Calculate target correlations using the target covariance matrix
knownStdevs = sqrt(diag(targetSa.covAllT));
corrReq = targetSa.covAllT./(knownStdevs*knownStdevs');
% Contours of correlations from selected spectra
figure
contour(knownPer, knownPer, selectedCorr);
set(gca,'yscale','log','xscale','log');
axis square;
title('Sample correlation coefficients contour');
xlabel('T_1 (s)')
ylabel('T_2 (s)')
colorbar('YLim',[0 1]);
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Contours of target correlations
figure
contour(knownPer, knownPer, corrReq);
set(gca,'yscale','log','xscale','log');
axis square;
xlabel('T_1 (s)');
ylabel('T_2 (s)');
title('Target correlation coefficients contour');
colorbar('YLim',[0 1]);
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)
% Difference between target and sample correlations
diffCorr = abs(selectedCorr-corrReq);
figure
contour(knownPer, knownPer,diffCorr);
set(gca, 'yscale', 'log','xscale','log');
axis square;
title('abs(sample correlation - target correlation)');
xlabel('T_1 (s)');
ylabel('T_2 (s)');
colorbar('YLim',[0 1]);
caxis([0 1]);
set(findall(gcf,'-property','FontSize'),'FontSize', figureFontSize)