forked from SeisComP/common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mb_VC.cpp
210 lines (182 loc) · 26.4 KB
/
mb_VC.cpp
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/* ################################################################################
* # Copyright (C) 2024 by IGN Spain #
* # #
* # author: J. Barco, E. Suarez #
* # email: [email protected] , [email protected] #
* # last modified: 2024-03-20 #
* # #
* # This program is free software; you can redistribute it and/or modify #
* # it under the terms of the GNU General Public License as published by #
* # the Free Software Foundation; either version 2 of the License, or #
* # (at your option) any later version. #
* # #
* # This program is distributed in the hope that it will be useful, #
* # but WITHOUT ANY WARRANTY; without even the implied warranty of #
* # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
* # GNU General Public License for more details. #
* # #
* # You should have received a copy of the GNU General Public License #
* # along with this program; if not, write to the #
* # Free Software Foundation, Inc., #
* # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
* ################################################################################ */
#include <math.h>
#include <seiscomp/seismology/magnitudes.h>
/* See http://jclahr.com/science/software/magnitude/mb/index.html
*
* These are the original Gutenberg and Richter (1956) calibration functions
* as they are still (2007) used at the NEIC
*
* The Q values for a distance of 5 degrees are in the 4th column, i.e.
* at __qmb[x][3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0, 7.1, 7.1, 7.2, 7.2, 7.3, 7.4, 7.4, 7.4, 7.5, 7.5 }
};
/* Q-factor of P waves according to Veith-Clawson (1972) */
static float depths[11] = {0., 15., 40., 100., 200., 300., 400., 500., 600., 700., 800.};
static float qmb[11][181] = {
{ // 0 km
0.301, 1.191, 2.371, 2.501, 2.851, 3.061, 3.201, 3.321, 3.401, 3.451, 3.491, 3.531, 3.551, 3.561, 3.561, 3.551, 3.511, 3.401, 3.281, 3.091, 3.071, 3.101, 3.151, 3.241, 3.341, 3.451, 3.551, 3.651, 3.721, 3.741, 3.721, 3.681, 3.661, 3.661, 3.651, 3.641, 3.641, 3.641, 3.631, 3.631, 3.621, 3.621, 3.621, 3.631, 3.631, 3.641, 3.641, 3.651, 3.661, 3.661, 3.671, 3.671, 3.681, 3.691, 3.691, 3.701, 3.701, 3.711, 3.721, 3.721, 3.731, 3.741, 3.741, 3.751, 3.751, 3.761, 3.761, 3.771, 3.781, 3.781, 3.791, 3.801, 3.801, 3.811, 3.811, 3.821, 3.831, 3.831, 3.841, 3.841, 3.851, 3.861, 3.871, 3.881, 3.891, 3.911, 3.941, 3.961, 3.981, 4.021, 4.061, 4.101, 4.151, 4.211, 4.281, 4.361, 4.441, 4.521, 4.601, 4.681, 4.761, 4.75, 4.74, 4.72, 4.71, 4.70, 4.70, 4.70, 4.70, 4.70, 4.70, 4.50, 4.50, 4.50, 4.30, 4.30, 4.30, 4.30, 4.30, 4.30, 4.25, 4.25, 4.25, 4.25, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 4.20, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.50, 3.60, 3.65, 3.80, 3.87, 3.93, 4.00, 4.02, 4.05, 4.07, 4.10, 4.13, 4.16, 4.19, 4.22, 4.25, 4.28, 4.31, 4.34, 4.37, 4.41, 4.45, 4.49, 4.52, 4.55, 4.58, 4.61, 4.64, 4.67, 4.70
},
{ // 15 km
-1.519, 3.221, 2.321, 2.531, 2.831, 3.031, 3.161, 3.271, 3.341, 3.391, 3.431, 3.461, 3.481, 3.491, 3.491, 3.471, 3.411, 3.301, 3.151, 3.011, 3.011, 3.051, 3.121, 3.191, 3.291, 3.391, 3.491, 3.571, 3.631, 3.651, 3.631, 3.611, 3.591, 3.581, 3.571, 3.561, 3.551, 3.551, 3.541, 3.541, 3.541, 3.541, 3.541, 3.541, 3.541, 3.551, 3.551, 3.561, 3.561, 3.571, 3.581, 3.581, 3.591, 3.601, 3.601, 3.611, 3.621, 3.621, 3.631, 3.641, 3.641, 3.651, 3.651, 3.661, 3.661, 3.671, 3.681, 3.681, 3.691, 3.691, 3.701, 3.701, 3.711, 3.721, 3.721, 3.731, 3.731, 3.741, 3.741, 3.751, 3.751, 3.761, 3.761, 3.771, 3.791, 3.811, 3.831, 3.851, 3.881, 3.921, 3.961, 4.001, 4.051, 4.111, 4.191, 4.271, 4.351, 4.431, 4.511, 4.591, 4.671, 4.66, 4.65, 4.63, 4.62, 4.61, 4.61, 4.61, 4.61, 4.61, 4.61, 4.41, 4.41, 4.41, 4.21, 4.21, 4.21, 4.21, 4.21, 4.21, 4.16, 4.16, 4.16, 4.16, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 4.11, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.51, 3.56, 3.71, 3.78, 3.84, 3.91, 3.93, 3.96, 3.98, 4.01, 4.04, 4.07, 4.10, 4.13, 4.16, 4.19, 4.22, 4.25, 4.28, 4.32, 4.36, 4.40, 4.43, 4.46, 4.49, 4.52, 4.55, 4.58, 4.61
},
{ // 40 km
-1.139, 2.461, 2.591, 2.831, 3.021, 3.171, 3.291, 3.381, 3.431, 3.471, 3.491, 3.501, 3.511, 3.511, 3.511, 3.471, 3.381, 3.241, 3.051, 2.931, 2.921, 2.951, 3.011, 3.091, 3.171, 3.271, 3.361, 3.431, 3.481, 3.491, 3.501, 3.501, 3.491, 3.481, 3.461, 3.451, 3.441, 3.431, 3.421, 3.421, 3.411, 3.411, 3.411, 3.411, 3.411, 3.411, 3.421, 3.421, 3.431, 3.441, 3.441, 3.451, 3.461, 3.461, 3.471, 3.481, 3.481, 3.491, 3.491, 3.501, 3.501, 3.511, 3.511, 3.521, 3.521, 3.531, 3.541, 3.541, 3.551, 3.551, 3.561, 3.561, 3.571, 3.571, 3.581, 3.581, 3.591, 3.591, 3.601, 3.601, 3.611, 3.611, 3.621, 3.631, 3.641, 3.661, 3.681, 3.701, 3.741, 3.781, 3.821, 3.861, 3.911, 3.971, 4.051, 4.131, 4.211, 4.291, 4.371, 4.451, 4.531, 4.52, 4.51, 4.49, 4.48, 4.47, 4.47, 4.47, 4.47, 4.47, 4.47, 4.27, 4.27, 4.27, 4.07, 4.07, 4.07, 4.07, 4.07, 4.07, 4.02, 4.02, 4.02, 4.02, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.27, 3.27, 3.27, 3.27, 3.27, 3.27, 3.27, 3.27, 3.27, 3.27, 3.37, 3.42, 3.57, 3.64, 3.70, 3.77, 3.79, 3.82, 3.84, 3.87, 3.90, 3.93, 3.96, 3.99, 4.02, 4.05, 4.08, 4.11, 4.14, 4.18, 4.22, 4.26, 4.29, 4.32, 4.35, 4.38, 4.41, 4.44, 4.47
},
{ // 100 km
-0.499, -0.009, 0.691, 1.241, 1.661, 1.981, 2.251, 2.481, 2.671, 2.821, 2.931, 3.021, 3.091, 3.141, 3.151, 3.091, 2.981, 2.841, 2.761, 2.751, 2.781, 2.841, 2.911, 2.991, 3.081, 3.181, 3.271, 3.341, 3.371, 3.381, 3.381, 3.371, 3.361, 3.351, 3.341, 3.331, 3.321, 3.311, 3.301, 3.301, 3.291, 3.291, 3.291, 3.291, 3.291, 3.301, 3.301, 3.311, 3.321, 3.321, 3.331, 3.341, 3.341, 3.351, 3.361, 3.361, 3.371, 3.381, 3.381, 3.391, 3.401, 3.401, 3.411, 3.421, 3.421, 3.431, 3.441, 3.441, 3.451, 3.461, 3.461, 3.461, 3.471, 3.471, 3.481, 3.481, 3.491, 3.491, 3.501, 3.501, 3.501, 3.501, 3.511, 3.531, 3.551, 3.571, 3.601, 3.621, 3.641, 3.681, 3.721, 3.761, 3.811, 3.871, 3.951, 4.031, 4.111, 4.191, 4.271, 4.351, 4.431, 4.42, 4.41, 4.39, 4.38, 4.37, 4.37, 4.37, 4.37, 4.37, 4.37, 4.17, 4.17, 4.17, 3.97, 3.97, 3.97, 3.97, 3.97, 3.97, 3.92, 3.92, 3.92, 3.92, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.87, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.27, 3.32, 3.47, 3.54, 3.60, 3.67, 3.69, 3.72, 3.74, 3.77, 3.80, 3.83, 3.86, 3.89, 3.92, 3.95, 3.98, 4.01, 4.04, 4.08, 4.12, 4.16, 4.19, 4.22, 4.25, 4.28, 4.31, 4.34, 4.37
},
{ // 200 km
-0.059, 0.111, 0.471, 0.851, 1.191, 1.491, 1.761, 1.991, 2.181, 2.331, 2.441, 2.511, 2.551, 2.561, 2.531, 2.481, 2.451, 2.461, 2.491, 2.541, 2.601, 2.681, 2.761, 2.861, 2.961, 3.041, 3.101, 3.131, 3.141, 3.151, 3.151, 3.141, 3.131, 3.121, 3.111, 3.101, 3.101, 3.091, 3.091, 3.091, 3.081, 3.081, 3.091, 3.091, 3.101, 3.111, 3.111, 3.121, 3.131, 3.131, 3.141, 3.151, 3.161, 3.161, 3.171, 3.181, 3.181, 3.191, 3.201, 3.211, 3.211, 3.221, 3.231, 3.231, 3.241, 3.251, 3.251, 3.261, 3.271, 3.281, 3.281, 3.291, 3.301, 3.301, 3.311, 3.311, 3.321, 3.321, 3.321, 3.331, 3.331, 3.331, 3.341, 3.351, 3.361, 3.381, 3.401, 3.441, 3.481, 3.521, 3.561, 3.611, 3.671, 3.741, 3.821, 3.901, 3.981, 4.061, 4.141, 4.221, 4.301, 4.29, 4.28, 4.26, 4.25, 4.24, 4.24, 4.24, 4.24, 4.24, 4.24, 4.04, 4.04, 4.04, 3.84, 3.84, 3.84, 3.84, 3.84, 3.84, 3.79, 3.79, 3.79, 3.79, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.04, 3.04, 3.04, 3.04, 3.04, 3.04, 3.04, 3.04, 3.04, 3.04, 3.14, 3.19, 3.34, 3.41, 3.47, 3.54, 3.56, 3.59, 3.61, 3.64, 3.67, 3.70, 3.73, 3.76, 3.79, 3.82, 3.85, 3.88, 3.91, 3.95, 3.99, 4.03, 4.06, 4.09, 4.12, 4.15, 4.18, 4.21, 4.24
},
{ // 300 km
0.201, 0.291, 0.491, 0.741, 0.991, 1.231, 1.441, 1.621, 1.771, 1.891, 1.991, 2.061, 2.091, 2.121, 2.161, 2.201, 2.251, 2.311, 2.371, 2.441, 2.521, 2.601, 2.691, 2.781, 2.861, 2.921, 2.961, 2.981, 2.991, 2.991, 2.981, 2.971, 2.961, 2.961, 2.951, 2.941, 2.941, 2.941, 2.931, 2.931, 2.931, 2.941, 2.941, 2.951, 2.951, 2.961, 2.971, 2.971, 2.981, 2.991, 3.001, 3.001, 3.011, 3.021, 3.031, 3.031, 3.041, 3.051, 3.061, 3.061, 3.071, 3.081, 3.091, 3.101, 3.101, 3.111, 3.121, 3.131, 3.141, 3.141, 3.151, 3.161, 3.161, 3.171, 3.181, 3.181, 3.191, 3.191, 3.201, 3.201, 3.201, 3.211, 3.221, 3.241, 3.261, 3.291, 3.311, 3.331, 3.371, 3.411, 3.451, 3.501, 3.561, 3.641, 3.721, 3.801, 3.881, 3.961, 4.041, 4.121, 4.201, 4.19, 4.18, 4.16, 4.15, 4.14, 4.14, 4.14, 4.14, 4.14, 4.14, 3.94, 3.94, 3.94, 3.74, 3.74, 3.74, 3.74, 3.74, 3.74, 3.69, 3.69, 3.69, 3.69, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 3.64, 2.94, 2.94, 2.94, 2.94, 2.94, 2.94, 2.94, 2.94, 2.94, 2.94, 3.04, 3.09, 3.24, 3.31, 3.37, 3.44, 3.46, 3.49, 3.51, 3.54, 3.57, 3.60, 3.63, 3.66, 3.69, 3.72, 3.75, 3.78, 3.81, 3.85, 3.89, 3.93, 3.96, 3.99, 4.02, 4.05, 4.08, 4.10, 4.14
},
{ // 400 km
0.381, 0.421, 0.551, 0.711, 0.901, 1.081, 1.251, 1.401, 1.531, 1.651, 1.751, 1.841, 1.921, 1.981, 2.041, 2.101, 2.171, 2.251, 2.321, 2.401, 2.481, 2.571, 2.651, 2.731, 2.801, 2.841, 2.861, 2.871, 2.861, 2.841, 2.831, 2.821, 2.811, 2.811, 2.811, 2.811, 2.811, 2.811, 2.811, 2.811, 2.821, 2.821, 2.831, 2.841, 2.841, 2.851, 2.861, 2.871, 2.871, 2.881, 2.891, 2.901, 2.911, 2.921, 2.931, 2.941, 2.941, 2.951, 2.961, 2.971, 2.981, 2.981, 2.991, 3.001, 3.011, 3.021, 3.031, 3.041, 3.041, 3.051, 3.061, 3.071, 3.071, 3.081, 3.091, 3.091, 3.101, 3.101, 3.111, 3.111, 3.111, 3.131, 3.151, 3.171, 3.191, 3.211, 3.231, 3.251, 3.291, 3.331, 3.381, 3.431, 3.501, 3.581, 3.661, 3.741, 3.821, 3.901, 3.981, 4.061, 4.141, 4.13, 4.12, 4.10, 4.09, 4.08, 4.08, 4.08, 4.08, 4.08, 4.08, 3.88, 3.88, 3.88, 3.68, 3.68, 3.68, 3.68, 3.68, 3.68, 3.63, 3.63, 3.63, 3.63, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 3.58, 2.88, 2.88, 2.88, 2.88, 2.88, 2.88, 2.88, 2.88, 2.88, 2.88, 2.98, 3.03, 3.18, 3.25, 3.31, 3.38, 3.40, 3.43, 3.45, 3.48, 3.51, 3.54, 3.57, 3.60, 3.63, 3.66, 3.69, 3.72, 3.75, 3.79, 3.83, 3.87, 3.90, 3.93, 3.96, 3.99, 4.02, 4.05, 4.08
},
{ // 500 km
0.521, 0.551, 0.631, 0.751, 0.881, 1.031, 1.171, 1.301, 1.421, 1.541, 1.641, 1.731, 1.821, 1.901, 1.981, 2.061, 2.141, 2.221, 2.301, 2.371, 2.451, 2.521, 2.581, 2.631, 2.671, 2.691, 2.691, 2.681, 2.681, 2.681, 2.671, 2.671, 2.671, 2.671, 2.671, 2.671, 2.671, 2.681, 2.681, 2.691, 2.701, 2.701, 2.711, 2.721, 2.731, 2.731, 2.741, 2.751, 2.761, 2.771, 2.781, 2.791, 2.801, 2.811, 2.821, 2.831, 2.841, 2.841, 2.851, 2.861, 2.871, 2.881, 2.891, 2.901, 2.911, 2.921, 2.921, 2.931, 2.941, 2.951, 2.961, 2.971, 2.981, 2.981, 2.991, 3.001, 3.001, 3.001, 3.011, 3.011, 3.021, 3.031, 3.041, 3.061, 3.081, 3.101, 3.131, 3.171, 3.211, 3.251, 3.301, 3.361, 3.431, 3.511, 3.591, 3.671, 3.751, 3.831, 3.911, 3.991, 4.071, 4.06, 4.05, 4.03, 4.02, 4.01, 4.01, 4.01, 4.01, 4.01, 4.01, 3.81, 3.81, 3.81, 3.61, 3.61, 3.61, 3.61, 3.61, 3.61, 3.56, 3.56, 3.56, 3.56, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 2.81, 2.81, 2.81, 2.81, 2.81, 2.81, 2.81, 2.81, 2.81, 2.81, 2.91, 2.96, 3.11, 3.18, 3.24, 3.31, 3.33, 3.36, 3.38, 3.41, 3.44, 3.47, 3.50, 3.53, 3.56, 3.59, 3.62, 3.65, 3.68, 3.72, 3.76, 3.80, 3.83, 3.86, 3.89, 3.92, 3.95, 3.98, 4.01
},
{ // 600 km
0.641, 0.661, 0.721, 0.801, 0.911, 1.031, 1.141, 1.251, 1.361, 1.471, 1.571, 1.671, 1.771, 1.861, 1.941, 2.021, 2.101, 2.171, 2.241, 2.311, 2.371, 2.431, 2.471, 2.491, 2.501, 2.501, 2.491, 2.491, 2.481, 2.481, 2.481, 2.491, 2.501, 2.511, 2.521, 2.531, 2.541, 2.541, 2.551, 2.561, 2.571, 2.581, 2.591, 2.601, 2.611, 2.621, 2.631, 2.641, 2.651, 2.661, 2.671, 2.681, 2.691, 2.701, 2.711, 2.721, 2.731, 2.741, 2.751, 2.761, 2.771, 2.781, 2.791, 2.801, 2.811, 2.821, 2.831, 2.841, 2.851, 2.861, 2.861, 2.871, 2.881, 2.891, 2.891, 2.901, 2.911, 2.911, 2.921, 2.921, 2.931, 2.941, 2.961, 2.981, 3.001, 3.031, 3.061, 3.101, 3.141, 3.181, 3.241, 3.301, 3.381, 3.461, 3.541, 3.621, 3.701, 3.781, 3.861, 3.941, 4.021, 4.01, 4.00, 3.98, 3.97, 3.96, 3.96, 3.96, 3.96, 3.96, 3.96, 3.76, 3.76, 3.76, 3.56, 3.56, 3.56, 3.56, 3.56, 3.56, 3.51, 3.51, 3.51, 3.51, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 3.46, 2.76, 2.76, 2.76, 2.76, 2.76, 2.76, 2.76, 2.76, 2.76, 2.76, 2.86, 2.91, 3.06, 3.13, 3.19, 3.26, 3.28, 3.31, 3.33, 3.36, 3.39, 3.42, 3.45, 3.48, 3.51, 3.54, 3.57, 3.60, 3.63, 3.67, 3.71, 3.75, 3.78, 3.81, 3.84, 3.87, 3.90, 3.93, 3.96
},
{ // 700 km
0.741, 0.761, 0.801, 0.871, 0.951, 1.051, 1.141, 1.241, 1.341, 1.441, 1.531, 1.621, 1.711, 1.791, 1.871, 1.941, 2.011, 2.081, 2.141, 2.181, 2.211, 2.231, 2.241, 2.241, 2.251, 2.261, 2.271, 2.281, 2.291, 2.301, 2.311, 2.331, 2.341, 2.351, 2.361, 2.371, 2.391, 2.401, 2.411, 2.421, 2.431, 2.451, 2.461, 2.471, 2.481, 2.491, 2.511, 2.521, 2.531, 2.541, 2.561, 2.571, 2.581, 2.591, 2.611, 2.621, 2.631, 2.641, 2.651, 2.671, 2.681, 2.691, 2.701, 2.711, 2.721, 2.731, 2.741, 2.751, 2.761, 2.771, 2.781, 2.791, 2.791, 2.801, 2.801, 2.811, 2.821, 2.821, 2.821, 2.831, 2.841, 2.861, 2.881, 2.901, 2.931, 2.961, 2.991, 3.031, 3.071, 3.121, 3.181, 3.251, 3.331, 3.411, 3.491, 3.571, 3.651, 3.731, 3.811, 3.891, 3.971, 3.96, 3.95, 3.93, 3.92, 3.91, 3.91, 3.91, 3.91, 3.91, 3.91, 3.71, 3.71, 3.71, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.46, 3.46, 3.46, 3.46, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.81, 2.86, 3.01, 3.08, 3.14, 3.21, 3.23, 3.26, 3.28, 3.31, 3.34, 3.37, 3.40, 3.43, 3.46, 3.49, 3.52, 3.55, 3.58, 3.62, 3.66, 3.70, 3.73, 3.76, 3.79, 3.82, 3.85, 3.88, 3.91
},
{ // 800 km
0.821, 0.831, 0.861, 0.921, 0.981, 1.061, 1.141, 1.221, 1.301, 1.391, 1.471, 1.551, 1.621, 1.691, 1.751, 1.801, 1.851, 1.901, 1.941, 1.981, 2.011, 2.041, 2.061, 2.081, 2.101, 2.121, 2.141, 2.161, 2.181, 2.201, 2.221, 2.241, 2.261, 2.271, 2.291, 2.301, 2.321, 2.341, 2.351, 2.371, 2.381, 2.391, 2.411, 2.421, 2.431, 2.451, 2.461, 2.471, 2.481, 2.491, 2.511, 2.521, 2.531, 2.541, 2.551, 2.561, 2.571, 2.591, 2.601, 2.611, 2.621, 2.631, 2.641, 2.651, 2.661, 2.671, 2.681, 2.691, 2.701, 2.711, 2.721, 2.731, 2.741, 2.751, 2.761, 2.771, 2.771, 2.781, 2.781, 2.791, 2.801, 2.821, 2.851, 2.881, 2.911, 2.951, 2.991, 3.031, 3.081, 3.141, 3.211, 3.271, 3.331, 3.411, 3.491, 3.571, 3.651, 3.731, 3.811, 3.891, 3.971, 3.96, 3.95, 3.93, 3.92, 3.91, 3.91, 3.91, 3.91, 3.91, 3.91, 3.71, 3.71, 3.71, 3.51, 3.51, 3.51, 3.51, 3.51, 3.51, 3.46, 3.46, 3.46, 3.46, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 3.41, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.71, 2.81, 2.86, 3.01, 3.08, 3.14, 3.21, 3.23, 3.26, 3.28, 3.31, 3.34, 3.37, 3.40, 3.43, 3.46, 3.49, 3.52, 3.55, 3.58, 3.62, 3.66, 3.70, 3.73, 3.76, 3.79, 3.82, 3.85, 3.88, 3.91
}
};
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
static double
bmagnz(double amplitude, double period, double delta, double depth, int *err)
{
int j, k;
double Q, Q1, Q2, mb;
*err = 0;
if (depth < 0. || depth > 800. || delta < 0.1 || delta > 180) {
*err = -1;
return 0.;
}
if (depth < 15)
k = 0;
else if (depth < 40)
k = 1;
else if (depth < 100)
k = 2;
else if (depth < 200)
k = 3;
else if (depth < 300)
k = 4;
else if (depth < 400)
k = 5;
else if (depth < 500)
k = 6;
else if (depth < 600)
k = 7;
else if (depth < 700)
k = 8;
else if (depth < 800)
k = 9;
else
k = 10;
j = min((int)(delta), 181);
// Get the attenuation factor. If the (depth, delta) value is not in the table
// we perform a linear interpolation
if (depths[k] == depth) {
if (j == delta)
Q = qmb[k][j];
else {
Q = qmb[k][j+1] - qmb[k][j];
Q *= (delta - j);
Q += qmb[k][j];
}
}
else {
Q1 = qmb[k][j+1] - qmb[k][j];
Q1 *= (delta - j);
Q1 += qmb[k][j];
Q2 = qmb[k+1][j+1] - qmb[k+1][j];
Q2 *= (delta - j);
Q2 += qmb[k+1][j];
Q = Q2 - Q1;
Q /= (depths[k+1] - depths[k]);
Q *= (depth - depths[k]);
Q += Q1;
}
amplitude /= 2; //p2p -> z2p
mb = log10(amplitude/period) + Q;
return mb;
}
namespace Seiscomp {
namespace Magnitudes {
bool
compute_mb_VC(
double amplitude, // in micrometers
double period, // in seconds
double delta, // in degrees
double depth, // in kilometers
double *mag)
{
int err;
double m = bmagnz(amplitude, period, delta, depth, &err);
if (err) return false;
*mag = m;
return true;
}
bool
compute_mb_VC_fromVelocity(
double amplitude, // in micrometers/second
double delta, // in degrees
double depth, // in kilometers
double *mag)
{
int err;
double m = bmagnz(amplitude, 2*M_PI, delta, depth, &err);
if (err) return false;
*mag = m;
return true;
}
} // namespace Magnitudes
} // namespace Seiscomp