-
Notifications
You must be signed in to change notification settings - Fork 0
/
CleanData_V7.m
153 lines (121 loc) · 4.29 KB
/
CleanData_V7.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
%% Cleans the ground motion database
% "A Bayesian Treatment of the Conditional Spectrum Approach for Ground
% Motion Selection". Report by Somayajulu Dhulipala, Jack Baker and
% Madeleine Flint.
%
% Created by Somayajulu Dhulipala, 20 May 2017
% Modified by Somayajulu Dhulipala, 23 December 2017
%% INPUTS
% IM_matrix = the intensity measure matrix (N X (Nt+Nn))
% N is the number of observations, Nt is the number of time periods
% Nn is the number of non-spectral IMs
% magnitude = the earthquake magnitude vector (N X 1)
% Rjb = the Joyner-Boore distance (Km) vector (N X 1)
% Vs = shear-wave velocity (m/s) vector (N X 1)
% mechanism = fault-mechanism vector (N X 1)
% req_per = the required time periods vector (Nt X 1)
% restr_vec = non-spectral IM level restriction matrix (Nn X 2)
% for example, if there are two non-spectral IMs PGA and PGV and their
% respective minimum and maximum values are (0.01 2g) and (1 200cm/s),
% then restr_vec is [0.01 2;1 200]
% PEER fault mechanism description
% 0 - Strike slip
% 1 - Normal slip
% 2 - Reverse slip
% 3 - Reverse oblique
% 4 - Normal oblique
%% OUTPUTS
% IM_matrix = the cleaned intensity measure matrix (N X (Nt+Nn))
% magnitude = the cleaned earthquake magnitude vector (N X 1)
% Rjb = cleaned Joyner-Boore distance (Km) vector (N X 1)
% Vs = cleaned shear-wave velocity (m/s) vector (N X 1)
% mechanism = cleaned fault-mechanism vector (N X 1)
% SS = Strike-Slip fault indicator vector (N X 1)
% N = Normal fault indicator vector (N X 1)
% R = Reverse fault indicator vector (N X 1)
% U = Unspecified fault indicator vector (N X 1)
% mechanism_BA = Boore-Atkinson type mechanism indicator (NA)
%% EXPLICITLY DEFINED FUNCTIONS/ROUTINES USED
% NONE
%% FUNCTION BEGINS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [IM_matrix, magnitude, Rjb, Vs, mechanism, SS, N, R, U, mechanism_BA] = CleanData_V7(IM_matrix, magnitude, Rjb, Vs, mechanism, req_per, restr_vec)
siz = size(IM_matrix);
% IM restrictions
index = find(IM_matrix(:,1) > 2);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
index = find(IM_matrix(:,17) < 0.01);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
if siz(2) > length(req_per)
for ii = (length(req_per)+1):siz(2)
temp_ind = length(req_per)+(ii-length(req_per));
index = find(IM_matrix(:, temp_ind) > restr_vec((ii-length(req_per)),2));
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
index = find(IM_matrix(:, temp_ind) < restr_vec((ii-length(req_per)),1));
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
end
end
% Magnitude restrictions
index = find(magnitude < 4);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
% Distance restrictions
index = find(Rjb > 200);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
index = find(Rjb < 1);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
% Vs30 restrictions
index = find(Vs < 0);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
% Mechanism restrictions
index = find(mechanism < 0);
IM_matrix(index,:) = [];
magnitude(index) = [];
Rjb(index,:) = [];
Vs(index,:) = [];
mechanism(index,:) = [];
SS = zeros(length(mechanism),1);
N = zeros(length(mechanism),1);
R = zeros(length(mechanism),1);
U = zeros(length(mechanism),1);
SS(mechanism == 0) = 1;
N(mechanism == 1) = 1;
R(mechanism == 2) = 1;
U(mechanism > 2) = 1;
mechanism_BA = zeros(length(mechanism),1);
mechanism_BA(mechanism > 2) = 1;
mechanism_BA(mechanism == 0) = 2;
mechanism_BA(mechanism == 1) = 3;
mechanism_BA(mechanism == 2) = 4;
end