├── Africa_Moho_density_contrast.txt
├── README.md
├── code_AFR
├── AF2019_regionalization.ipynb
├── AFR_gravity_inversion_example.ipynb
├── Colormaps
│ ├── batlow.txt
│ ├── turku.txt
│ └── vik.txt
├── Data
│ ├── AF2019_prep_regionalization_1degree.txt
│ ├── ETOPO1_1degree_bed_global.txt
│ ├── ETOPO1_1degree_ice_global.txt
│ ├── Reg_AF2019_n6.txt
│ ├── Reg_AF2019_n6_cratons_floodfill.txt
│ ├── Seismic_stations_UGSS_Globig_binned_AS_binned_IDW_1degree.txt
│ ├── Seismic_stations_UGSS_Globig_binned_RF_binned_IDW_1degree.txt
│ └── gzz_1degree.txt
├── grad_inv_functions_AFR.py
└── topo_corr.py
├── code_SAM
├── Gradient_Inversion_SAM.ipynb
├── Gradient_Inversion_SAM_synthetic.ipynb
├── Gravity_Data
│ ├── Effect_IsoMoho_Amazonia_guu_1degree_225km.xyz
│ ├── Effect_IsoMoho_Amazonia_guu_1degree_225km_vardens.xyz
│ ├── IsoEffect_farfield_Amazonia_225km_1degree_guu.xyz
│ ├── SedEffect_Amazonia_CRUST_225km_1degree_guu.xyz
│ ├── guu_global_Topo_corrected_1degree.xyz
│ └── test.tst
├── IsoMoho_Airy_initial_1degree.txt
├── SL2013sv_Cluster_1d_interp.xyz
├── Seismic_Moho_USGS_global.txt
├── Tesseroids
│ └── tessgzz.exe
├── grad_inv_functions.py
└── grad_inv_functions_synthetic.py
├── code_user_defined
├── ETOPO1_1degree_bed_global.txt
├── ETOPO1_1degree_ice_global.txt
├── Gradient_Inversion_user_defined.ipynb
├── SL2013sv_Cluster_1d_interp.xyz
├── Seismic_Moho_USGS_global.txt
├── grad_inv_functions.py
├── gzz_1degree.txt
└── topo_corr.py
└── environment.yml
/README.md:
--------------------------------------------------------------------------------
1 | # Gradient_Inversion
2 |
3 | This collection contains data and code to invert satellite gravity gradient data for the Moho depth and density contrasts at the Moho depth.
4 |
5 | The data files are taken from the following sources: \
6 | Gravity gradient of GOCE - http://eo-virtual-archive1.esa.int/Index.html \
7 | Seismological Regionalization - https://schaeffer.ca/models/sl2013sv-tectonic-regionalization/ \
8 | Seismic Moho depth - USGS database as published by Chulick et al. 2013 (South America only)
9 |
10 | Africa: \
11 | A new regionalization map is calculated usign the AF2019 seismic tomography model of Celli et al: https://nlscelli.wixsite.com/ncseismology/models \
12 | Seismic Moho depths are taken from the USGS data base and from Globig et al. 2016: https://agupubs.onlinelibrary.wiley.com/doi/full/10.1002/2016JB012972
13 |
14 | The collection contains Jupyter notebook files that can be downloaded and run with Python 3. They are designed to run the inversion for various study areas: South America (i.e. Amazonian Craton), Africa and a more flexible version in a study area defined by the user.
15 |
16 | For official use, please cite the paper: Haas, P., Ebbing J., Szwillus W. - Sensitivity analysis of gravity gradient inversion of the Moho depth – A case example for the Amazonian Craton, Geophysical Journal International, 2020, doi: 10.1093/gji/ggaa122
17 |
18 | You need Python 3 to run this notebook. This notebok has been tested on a Windows machine.
19 |
20 | May 2020: An updated version, including a new notebook at user-defined study area has been added. The forward calculation of the gravitational effect now uses conversion of tesseroids to point masses, as written by Wolfgang Szwillus. This substitutes previous calculations of the executable tesseroids file of Leonardo Uieda (http://tesseroids.leouieda.com).
21 |
22 | April 2021: The repository has been revised and extended with the inversion for the African continent. This inversion is split in two steps and allows flexible density contrasts for individual cratons. For official use, please cite the following: Haas, P., Ebbing, J., Celli, N., Rey P. - Two-step gravity inversion reveals variable architecture of African cratons, submitted to Frontiers in Earth Science.
23 |
24 | July 2021: A textfile with the estimated Moho depth and density contrasts for the African continent has been uploaded.
25 |
26 |
--------------------------------------------------------------------------------
/code_AFR/Colormaps/batlow.txt:
--------------------------------------------------------------------------------
1 | 0.003596 0.099991 0.350104
2 | 0.005948 0.104123 0.350813
3 | 0.008241 0.108211 0.351502
4 | 0.010454 0.112354 0.352200
5 | 0.012856 0.116424 0.352908
6 | 0.014995 0.120438 0.353596
7 | 0.017080 0.124486 0.354297
8 | 0.019118 0.128536 0.355005
9 | 0.021113 0.132572 0.355694
10 | 0.023067 0.136563 0.356383
11 | 0.024983 0.140610 0.357079
12 | 0.026865 0.144618 0.357770
13 | 0.028714 0.148590 0.358445
14 | 0.030534 0.152599 0.359133
15 | 0.032329 0.156636 0.359828
16 | 0.034083 0.160615 0.360505
17 | 0.036051 0.164640 0.361199
18 | 0.037779 0.168656 0.361895
19 | 0.039498 0.172658 0.362576
20 | 0.041209 0.176675 0.363259
21 | 0.042752 0.180700 0.363944
22 | 0.044421 0.184755 0.364629
23 | 0.045902 0.188797 0.365314
24 | 0.047477 0.192838 0.366003
25 | 0.049077 0.196914 0.366684
26 | 0.050475 0.200942 0.367351
27 | 0.051912 0.205037 0.368032
28 | 0.053357 0.209120 0.368713
29 | 0.054819 0.213204 0.369376
30 | 0.056316 0.217328 0.370037
31 | 0.057649 0.221440 0.370696
32 | 0.059196 0.225565 0.371350
33 | 0.060593 0.229676 0.371998
34 | 0.062035 0.233826 0.372640
35 | 0.063527 0.237992 0.373274
36 | 0.064987 0.242150 0.373901
37 | 0.066494 0.246311 0.374510
38 | 0.068052 0.250486 0.375095
39 | 0.069648 0.254696 0.375674
40 | 0.071235 0.258881 0.376245
41 | 0.072855 0.263075 0.376786
42 | 0.074530 0.267253 0.377298
43 | 0.076235 0.271463 0.377788
44 | 0.078026 0.275693 0.378253
45 | 0.079917 0.279885 0.378688
46 | 0.081925 0.284081 0.379089
47 | 0.083913 0.288284 0.379453
48 | 0.085920 0.292481 0.379778
49 | 0.088158 0.296681 0.380059
50 | 0.090420 0.300848 0.380294
51 | 0.092737 0.305030 0.380477
52 | 0.095262 0.309199 0.380605
53 | 0.097825 0.313328 0.380673
54 | 0.100462 0.317448 0.380678
55 | 0.103292 0.321545 0.380615
56 | 0.106209 0.325618 0.380480
57 | 0.109231 0.329692 0.380270
58 | 0.112380 0.333710 0.379982
59 | 0.115640 0.337693 0.379612
60 | 0.119046 0.341651 0.379158
61 | 0.122527 0.345562 0.378614
62 | 0.126233 0.349446 0.377978
63 | 0.130032 0.353278 0.377251
64 | 0.133912 0.357075 0.376429
65 | 0.137954 0.360792 0.375486
66 | 0.142079 0.364487 0.374467
67 | 0.146330 0.368125 0.373325
68 | 0.150711 0.371696 0.372082
69 | 0.155200 0.375219 0.370739
70 | 0.159768 0.378685 0.369297
71 | 0.164499 0.382080 0.367737
72 | 0.169305 0.385417 0.366090
73 | 0.174164 0.388703 0.364318
74 | 0.179132 0.391909 0.362459
75 | 0.184176 0.395055 0.360484
76 | 0.189307 0.398139 0.358428
77 | 0.194527 0.401157 0.356281
78 | 0.199746 0.404100 0.354021
79 | 0.205088 0.406986 0.351681
80 | 0.210470 0.409814 0.349265
81 | 0.215918 0.412578 0.346762
82 | 0.221386 0.415267 0.344165
83 | 0.226908 0.417906 0.341521
84 | 0.232462 0.420485 0.338795
85 | 0.238054 0.423007 0.336000
86 | 0.243664 0.425486 0.333162
87 | 0.249328 0.427907 0.330248
88 | 0.255026 0.430272 0.327280
89 | 0.260712 0.432598 0.324274
90 | 0.266437 0.434872 0.321231
91 | 0.272158 0.437104 0.318144
92 | 0.277936 0.439287 0.315014
93 | 0.283702 0.441445 0.311851
94 | 0.289496 0.443565 0.308693
95 | 0.295283 0.445639 0.305488
96 | 0.301092 0.447691 0.302238
97 | 0.306926 0.449724 0.299011
98 | 0.312751 0.451724 0.295740
99 | 0.318604 0.453690 0.292469
100 | 0.324451 0.455642 0.289199
101 | 0.330325 0.457568 0.285888
102 | 0.336195 0.459485 0.282621
103 | 0.342093 0.461377 0.279322
104 | 0.347992 0.463244 0.276029
105 | 0.353894 0.465113 0.272709
106 | 0.359826 0.466973 0.269431
107 | 0.365767 0.468812 0.266135
108 | 0.371712 0.470643 0.262845
109 | 0.377691 0.472465 0.259574
110 | 0.383684 0.474281 0.256283
111 | 0.389685 0.476091 0.253037
112 | 0.395726 0.477893 0.249771
113 | 0.401766 0.479701 0.246545
114 | 0.407851 0.481493 0.243320
115 | 0.413958 0.483287 0.240121
116 | 0.420093 0.485081 0.236972
117 | 0.426256 0.486883 0.233782
118 | 0.432473 0.488679 0.230657
119 | 0.438701 0.490481 0.227564
120 | 0.444991 0.492275 0.224463
121 | 0.451315 0.494081 0.221451
122 | 0.457683 0.495880 0.218457
123 | 0.464119 0.497704 0.215499
124 | 0.470592 0.499503 0.212598
125 | 0.477124 0.501335 0.209750
126 | 0.483718 0.503148 0.206986
127 | 0.490390 0.504986 0.204279
128 | 0.497119 0.506822 0.201607
129 | 0.503925 0.508674 0.199059
130 | 0.510799 0.510514 0.196645
131 | 0.517765 0.512370 0.194302
132 | 0.524800 0.514240 0.192042
133 | 0.531925 0.516093 0.189943
134 | 0.539133 0.517977 0.188011
135 | 0.546437 0.519844 0.186186
136 | 0.553814 0.521722 0.184533
137 | 0.561289 0.523613 0.183052
138 | 0.568850 0.525495 0.181775
139 | 0.576513 0.527379 0.180711
140 | 0.584242 0.529266 0.179870
141 | 0.592071 0.531140 0.179261
142 | 0.599969 0.533016 0.178895
143 | 0.607953 0.534885 0.178781
144 | 0.616001 0.536753 0.178925
145 | 0.624125 0.538604 0.179340
146 | 0.632303 0.540439 0.180037
147 | 0.640539 0.542267 0.181021
148 | 0.648824 0.544078 0.182304
149 | 0.657150 0.545880 0.183894
150 | 0.665502 0.547652 0.185797
151 | 0.673883 0.549415 0.187967
152 | 0.682277 0.551153 0.190390
153 | 0.690681 0.552869 0.193140
154 | 0.699086 0.554570 0.196174
155 | 0.707484 0.556238 0.199438
156 | 0.715871 0.557897 0.203015
157 | 0.724221 0.559534 0.206856
158 | 0.732550 0.561143 0.210903
159 | 0.740830 0.562746 0.215195
160 | 0.749071 0.564317 0.219744
161 | 0.757264 0.565872 0.224464
162 | 0.765402 0.567423 0.229434
163 | 0.773466 0.568950 0.234622
164 | 0.781473 0.570473 0.239950
165 | 0.789403 0.571995 0.245479
166 | 0.797250 0.573509 0.251216
167 | 0.805019 0.575016 0.257092
168 | 0.812698 0.576542 0.263141
169 | 0.820286 0.578050 0.269350
170 | 0.827777 0.579591 0.275710
171 | 0.835167 0.581127 0.282209
172 | 0.842450 0.582684 0.288850
173 | 0.849615 0.584267 0.295626
174 | 0.856658 0.585875 0.302542
175 | 0.863584 0.587496 0.309618
176 | 0.870366 0.589154 0.316788
177 | 0.877016 0.590850 0.324081
178 | 0.883526 0.592587 0.331497
179 | 0.889875 0.594345 0.339046
180 | 0.896068 0.596152 0.346680
181 | 0.902091 0.597997 0.354425
182 | 0.907945 0.599894 0.362264
183 | 0.913611 0.601828 0.370186
184 | 0.919085 0.603817 0.378206
185 | 0.924372 0.605836 0.386292
186 | 0.929456 0.607922 0.394462
187 | 0.934335 0.610037 0.402689
188 | 0.939007 0.612203 0.410979
189 | 0.943463 0.614413 0.419312
190 | 0.947702 0.616678 0.427687
191 | 0.951721 0.618979 0.436090
192 | 0.955527 0.621309 0.444526
193 | 0.959108 0.623692 0.452973
194 | 0.962472 0.626098 0.461436
195 | 0.965622 0.628550 0.469910
196 | 0.968564 0.631029 0.478373
197 | 0.971295 0.633537 0.486842
198 | 0.973824 0.636073 0.495300
199 | 0.976156 0.638632 0.503743
200 | 0.978299 0.641212 0.512171
201 | 0.980263 0.643818 0.520581
202 | 0.982051 0.646446 0.528982
203 | 0.983667 0.649092 0.537350
204 | 0.985131 0.651749 0.545695
205 | 0.986442 0.654414 0.554015
206 | 0.987612 0.657104 0.562324
207 | 0.988649 0.659797 0.570592
208 | 0.989567 0.662506 0.578856
209 | 0.990365 0.665214 0.587093
210 | 0.991060 0.667944 0.595317
211 | 0.991656 0.670676 0.603529
212 | 0.992163 0.673411 0.611719
213 | 0.992587 0.676156 0.619906
214 | 0.992936 0.678906 0.628077
215 | 0.993215 0.681662 0.636244
216 | 0.993430 0.684427 0.644396
217 | 0.993589 0.687202 0.652555
218 | 0.993697 0.689980 0.660712
219 | 0.993759 0.692768 0.668876
220 | 0.993779 0.695553 0.677040
221 | 0.993762 0.698342 0.685205
222 | 0.993712 0.701146 0.693378
223 | 0.993633 0.703953 0.701556
224 | 0.993526 0.706770 0.709754
225 | 0.993395 0.709588 0.717957
226 | 0.993243 0.712407 0.726173
227 | 0.993070 0.715245 0.734403
228 | 0.992880 0.718081 0.742649
229 | 0.992673 0.720922 0.750909
230 | 0.992451 0.723775 0.759178
231 | 0.992216 0.726634 0.767469
232 | 0.991967 0.729500 0.775780
233 | 0.991707 0.732374 0.784113
234 | 0.991434 0.735249 0.792453
235 | 0.991150 0.738129 0.800816
236 | 0.990855 0.741019 0.809201
237 | 0.990547 0.743921 0.817596
238 | 0.990229 0.746826 0.826015
239 | 0.989899 0.749731 0.834456
240 | 0.989556 0.752649 0.842910
241 | 0.989198 0.755579 0.851379
242 | 0.988825 0.758510 0.859877
243 | 0.988437 0.761443 0.868391
244 | 0.988035 0.764387 0.876910
245 | 0.987618 0.767333 0.885461
246 | 0.987183 0.770290 0.894024
247 | 0.986726 0.773249 0.902604
248 | 0.986248 0.776219 0.911199
249 | 0.985748 0.779189 0.919810
250 | 0.985226 0.782170 0.928436
251 | 0.984680 0.785153 0.937084
252 | 0.984104 0.788138 0.945739
253 | 0.983498 0.791132 0.954413
254 | 0.982868 0.794135 0.963099
255 | 0.982206 0.797132 0.971799
256 | 0.981508 0.800145 0.980512
257 |
--------------------------------------------------------------------------------
/code_AFR/Colormaps/turku.txt:
--------------------------------------------------------------------------------
1 | 0.000063 0.000005 0.000036
2 | 0.007290 0.007204 0.006548
3 | 0.014710 0.014597 0.013245
4 | 0.021935 0.021794 0.019755
5 | 0.029159 0.028991 0.026252
6 | 0.036570 0.036375 0.032748
7 | 0.043586 0.043359 0.039417
8 | 0.050168 0.049959 0.045556
9 | 0.056203 0.055961 0.051274
10 | 0.061712 0.061463 0.056643
11 | 0.066992 0.066746 0.061506
12 | 0.071921 0.071694 0.066226
13 | 0.076552 0.076296 0.070642
14 | 0.081056 0.080777 0.074828
15 | 0.085276 0.085021 0.078791
16 | 0.089398 0.089110 0.082660
17 | 0.093274 0.092973 0.086288
18 | 0.097120 0.096859 0.089825
19 | 0.101038 0.100786 0.093141
20 | 0.104942 0.104672 0.096482
21 | 0.108926 0.108623 0.099864
22 | 0.112921 0.112617 0.103237
23 | 0.116855 0.116562 0.106586
24 | 0.120820 0.120496 0.109910
25 | 0.124835 0.124484 0.113213
26 | 0.128844 0.128498 0.116492
27 | 0.132892 0.132513 0.119746
28 | 0.136918 0.136502 0.122995
29 | 0.140991 0.140564 0.126296
30 | 0.145046 0.144601 0.129527
31 | 0.149082 0.148613 0.132748
32 | 0.153138 0.152668 0.135908
33 | 0.157222 0.156756 0.139098
34 | 0.161345 0.160812 0.142280
35 | 0.165385 0.164875 0.145443
36 | 0.169533 0.168986 0.148500
37 | 0.173607 0.173041 0.151594
38 | 0.177744 0.177142 0.154657
39 | 0.181809 0.181208 0.157690
40 | 0.185960 0.185342 0.160696
41 | 0.190051 0.189414 0.163707
42 | 0.194194 0.193519 0.166642
43 | 0.198278 0.197608 0.169573
44 | 0.202395 0.201692 0.172431
45 | 0.206547 0.205817 0.175300
46 | 0.210638 0.209903 0.178153
47 | 0.214745 0.214009 0.180907
48 | 0.218872 0.218103 0.183680
49 | 0.222990 0.222187 0.186423
50 | 0.227091 0.226298 0.189124
51 | 0.231200 0.230358 0.191783
52 | 0.235309 0.234470 0.194450
53 | 0.239393 0.238528 0.197043
54 | 0.243470 0.242609 0.199581
55 | 0.247581 0.246687 0.202127
56 | 0.251671 0.250761 0.204658
57 | 0.255736 0.254845 0.207134
58 | 0.259822 0.258900 0.209562
59 | 0.263900 0.262954 0.211994
60 | 0.267938 0.266992 0.214362
61 | 0.271997 0.271056 0.216724
62 | 0.276087 0.275096 0.219036
63 | 0.280118 0.279144 0.221330
64 | 0.284164 0.283175 0.223587
65 | 0.288207 0.287188 0.225833
66 | 0.292251 0.291232 0.228039
67 | 0.296286 0.295240 0.230190
68 | 0.300312 0.299273 0.232366
69 | 0.304341 0.303270 0.234504
70 | 0.308370 0.307283 0.236608
71 | 0.312378 0.311297 0.238663
72 | 0.316418 0.315302 0.240716
73 | 0.320441 0.319304 0.242756
74 | 0.324438 0.323304 0.244764
75 | 0.328462 0.327290 0.246769
76 | 0.332488 0.331280 0.248761
77 | 0.336486 0.335297 0.250701
78 | 0.340511 0.339286 0.252648
79 | 0.344521 0.343272 0.254580
80 | 0.348549 0.347265 0.256467
81 | 0.352572 0.351248 0.258360
82 | 0.356605 0.355248 0.260248
83 | 0.360620 0.359220 0.262115
84 | 0.364666 0.363212 0.263983
85 | 0.368721 0.367205 0.265824
86 | 0.372762 0.371195 0.267635
87 | 0.376835 0.375195 0.269496
88 | 0.380907 0.379198 0.271303
89 | 0.384975 0.383208 0.273127
90 | 0.389080 0.387201 0.274933
91 | 0.393179 0.391225 0.276752
92 | 0.397300 0.395235 0.278557
93 | 0.401442 0.399243 0.280346
94 | 0.405602 0.403280 0.282175
95 | 0.409774 0.407305 0.283967
96 | 0.413963 0.411339 0.285769
97 | 0.418173 0.415382 0.287587
98 | 0.422409 0.419437 0.289423
99 | 0.426680 0.423481 0.291250
100 | 0.430975 0.427557 0.293070
101 | 0.435297 0.431630 0.294913
102 | 0.439639 0.435704 0.296782
103 | 0.444025 0.439786 0.298639
104 | 0.448436 0.443882 0.300514
105 | 0.452890 0.447974 0.302404
106 | 0.457371 0.452098 0.304323
107 | 0.461904 0.456207 0.306269
108 | 0.466474 0.460328 0.308200
109 | 0.471093 0.464479 0.310185
110 | 0.475755 0.468613 0.312149
111 | 0.480458 0.472760 0.314179
112 | 0.485214 0.476920 0.316230
113 | 0.490030 0.481079 0.318289
114 | 0.494902 0.485249 0.320397
115 | 0.499813 0.489423 0.322518
116 | 0.504804 0.493606 0.324659
117 | 0.509839 0.497800 0.326847
118 | 0.514941 0.501978 0.329089
119 | 0.520096 0.506153 0.331326
120 | 0.525329 0.510340 0.333638
121 | 0.530619 0.514527 0.335961
122 | 0.535971 0.518703 0.338327
123 | 0.541388 0.522867 0.340746
124 | 0.546882 0.527027 0.343200
125 | 0.552434 0.531166 0.345677
126 | 0.558042 0.535291 0.348217
127 | 0.563732 0.539401 0.350797
128 | 0.569463 0.543493 0.353400
129 | 0.575270 0.547552 0.356064
130 | 0.581129 0.551588 0.358745
131 | 0.587044 0.555576 0.361493
132 | 0.593020 0.559543 0.364264
133 | 0.599036 0.563464 0.367083
134 | 0.605096 0.567331 0.369934
135 | 0.611203 0.571142 0.372824
136 | 0.617339 0.574902 0.375753
137 | 0.623515 0.578604 0.378712
138 | 0.629702 0.582236 0.381703
139 | 0.635919 0.585808 0.384716
140 | 0.642146 0.589285 0.387761
141 | 0.648375 0.592706 0.390839
142 | 0.654606 0.596023 0.393922
143 | 0.660832 0.599263 0.397028
144 | 0.667046 0.602403 0.400161
145 | 0.673242 0.605450 0.403304
146 | 0.679400 0.608411 0.406452
147 | 0.685537 0.611258 0.409610
148 | 0.691626 0.613996 0.412779
149 | 0.697668 0.616646 0.415935
150 | 0.703665 0.619184 0.419105
151 | 0.709603 0.621600 0.422261
152 | 0.715479 0.623928 0.425434
153 | 0.721279 0.626132 0.428588
154 | 0.727018 0.628240 0.431748
155 | 0.732685 0.630234 0.434886
156 | 0.738264 0.632122 0.438021
157 | 0.743772 0.633913 0.441135
158 | 0.749190 0.635592 0.444261
159 | 0.754538 0.637182 0.447354
160 | 0.759785 0.638671 0.450458
161 | 0.764961 0.640074 0.453543
162 | 0.770042 0.641377 0.456625
163 | 0.775042 0.642610 0.459703
164 | 0.779960 0.643752 0.462766
165 | 0.784800 0.644824 0.465838
166 | 0.789553 0.645828 0.468920
167 | 0.794231 0.646771 0.471996
168 | 0.798829 0.647646 0.475078
169 | 0.803353 0.648471 0.478158
170 | 0.807810 0.649254 0.481257
171 | 0.812197 0.649987 0.484375
172 | 0.816524 0.650686 0.487527
173 | 0.820782 0.651357 0.490694
174 | 0.824986 0.652004 0.493880
175 | 0.829142 0.652627 0.497108
176 | 0.833237 0.653245 0.500370
177 | 0.837292 0.653864 0.503681
178 | 0.841297 0.654478 0.507039
179 | 0.845261 0.655103 0.510449
180 | 0.849192 0.655752 0.513925
181 | 0.853082 0.656418 0.517457
182 | 0.856942 0.657111 0.521050
183 | 0.860774 0.657841 0.524721
184 | 0.864578 0.658606 0.528473
185 | 0.868361 0.659428 0.532304
186 | 0.872114 0.660303 0.536217
187 | 0.875845 0.661242 0.540221
188 | 0.879553 0.662254 0.544323
189 | 0.883246 0.663333 0.548526
190 | 0.886919 0.664485 0.552814
191 | 0.890568 0.665734 0.557222
192 | 0.894201 0.667068 0.561722
193 | 0.897809 0.668505 0.566329
194 | 0.901394 0.670040 0.571039
195 | 0.904958 0.671670 0.575872
196 | 0.908492 0.673419 0.580791
197 | 0.911997 0.675275 0.585829
198 | 0.915467 0.677253 0.590958
199 | 0.918906 0.679333 0.596195
200 | 0.922312 0.681539 0.601525
201 | 0.925669 0.683866 0.606956
202 | 0.928977 0.686316 0.612460
203 | 0.932238 0.688886 0.618058
204 | 0.935448 0.691564 0.623735
205 | 0.938597 0.694360 0.629468
206 | 0.941681 0.697278 0.635273
207 | 0.944702 0.700307 0.641130
208 | 0.947647 0.703444 0.647044
209 | 0.950518 0.706687 0.652983
210 | 0.953313 0.710026 0.658964
211 | 0.956025 0.713462 0.664967
212 | 0.958650 0.716995 0.670991
213 | 0.961187 0.720602 0.677020
214 | 0.963634 0.724299 0.683043
215 | 0.965991 0.728067 0.689068
216 | 0.968259 0.731909 0.695067
217 | 0.970426 0.735806 0.701054
218 | 0.972506 0.739776 0.707015
219 | 0.974483 0.743783 0.712936
220 | 0.976371 0.747846 0.718828
221 | 0.978164 0.751946 0.724680
222 | 0.979870 0.756084 0.730482
223 | 0.981480 0.760255 0.736231
224 | 0.983000 0.764455 0.741938
225 | 0.984437 0.768675 0.747593
226 | 0.985784 0.772921 0.753181
227 | 0.987052 0.777189 0.758725
228 | 0.988234 0.781462 0.764206
229 | 0.989346 0.785749 0.769631
230 | 0.990378 0.790041 0.775001
231 | 0.991341 0.794346 0.780317
232 | 0.992236 0.798651 0.785580
233 | 0.993066 0.802958 0.790784
234 | 0.993829 0.807273 0.795937
235 | 0.994533 0.811585 0.801043
236 | 0.995180 0.815897 0.806101
237 | 0.995775 0.820203 0.811110
238 | 0.996319 0.824512 0.816079
239 | 0.996814 0.828824 0.821000
240 | 0.997265 0.833124 0.825884
241 | 0.997672 0.837430 0.830736
242 | 0.998039 0.841727 0.835548
243 | 0.998368 0.846020 0.840333
244 | 0.998661 0.850316 0.845083
245 | 0.998919 0.854608 0.849810
246 | 0.999146 0.858895 0.854509
247 | 0.999342 0.863188 0.859187
248 | 0.999510 0.867470 0.863851
249 | 0.999652 0.871758 0.868494
250 | 0.999769 0.876039 0.873116
251 | 0.999864 0.880320 0.877730
252 | 0.999937 0.884606 0.882330
253 | 0.999989 0.888890 0.886927
254 | 1.000000 0.893169 0.891512
255 | 1.000000 0.897457 0.896094
256 | 1.000000 0.901739 0.900670
257 |
--------------------------------------------------------------------------------
/code_AFR/Colormaps/vik.txt:
--------------------------------------------------------------------------------
1 | 0.001328 0.069836 0.379529
2 | 0.002366 0.076475 0.383518
3 | 0.003304 0.083083 0.387487
4 | 0.004146 0.089590 0.391477
5 | 0.004897 0.095948 0.395453
6 | 0.005563 0.102274 0.399409
7 | 0.006151 0.108500 0.403388
8 | 0.006668 0.114686 0.407339
9 | 0.007119 0.120845 0.411288
10 | 0.007512 0.126958 0.415230
11 | 0.007850 0.133068 0.419166
12 | 0.008141 0.139092 0.423079
13 | 0.008391 0.145171 0.427006
14 | 0.008606 0.151144 0.430910
15 | 0.008790 0.157140 0.434809
16 | 0.008947 0.163152 0.438691
17 | 0.009080 0.169142 0.442587
18 | 0.009193 0.175103 0.446459
19 | 0.009290 0.181052 0.450337
20 | 0.009372 0.187051 0.454212
21 | 0.009443 0.193028 0.458077
22 | 0.009506 0.198999 0.461951
23 | 0.009564 0.205011 0.465816
24 | 0.009619 0.211021 0.469707
25 | 0.009675 0.217047 0.473571
26 | 0.009735 0.223084 0.477461
27 | 0.009802 0.229123 0.481352
28 | 0.009881 0.235206 0.485250
29 | 0.009977 0.241277 0.489161
30 | 0.010098 0.247386 0.493080
31 | 0.010254 0.253516 0.497020
32 | 0.010463 0.259675 0.500974
33 | 0.010755 0.265853 0.504938
34 | 0.011176 0.272037 0.508925
35 | 0.011716 0.278296 0.512923
36 | 0.012286 0.284554 0.516953
37 | 0.012934 0.290865 0.520998
38 | 0.013790 0.297214 0.525074
39 | 0.014838 0.303577 0.529184
40 | 0.016131 0.310015 0.533308
41 | 0.017711 0.316474 0.537485
42 | 0.019630 0.322986 0.541677
43 | 0.021948 0.329550 0.545931
44 | 0.024730 0.336144 0.550210
45 | 0.028047 0.342826 0.554538
46 | 0.031980 0.349543 0.558906
47 | 0.036812 0.356332 0.563341
48 | 0.042229 0.363171 0.567811
49 | 0.048008 0.370086 0.572345
50 | 0.054292 0.377080 0.576933
51 | 0.060963 0.384129 0.581571
52 | 0.068081 0.391265 0.586280
53 | 0.075457 0.398460 0.591042
54 | 0.083246 0.405740 0.595868
55 | 0.091425 0.413088 0.600754
56 | 0.099832 0.420499 0.605697
57 | 0.108595 0.428000 0.610711
58 | 0.117694 0.435566 0.615770
59 | 0.127042 0.443194 0.620895
60 | 0.136702 0.450888 0.626062
61 | 0.146607 0.458643 0.631289
62 | 0.156787 0.466457 0.636560
63 | 0.167187 0.474324 0.641866
64 | 0.177807 0.482238 0.647218
65 | 0.188606 0.490191 0.652599
66 | 0.199580 0.498193 0.658021
67 | 0.210783 0.506201 0.663465
68 | 0.222120 0.514263 0.668924
69 | 0.233602 0.522322 0.674403
70 | 0.245231 0.530414 0.679894
71 | 0.256999 0.538517 0.685405
72 | 0.268867 0.546617 0.690908
73 | 0.280797 0.554717 0.696428
74 | 0.292852 0.562822 0.701935
75 | 0.304985 0.570907 0.707448
76 | 0.317174 0.578997 0.712950
77 | 0.329438 0.587064 0.718447
78 | 0.341729 0.595123 0.723934
79 | 0.354067 0.603164 0.729412
80 | 0.366459 0.611186 0.734877
81 | 0.378862 0.619189 0.740325
82 | 0.391305 0.627159 0.745757
83 | 0.403760 0.635114 0.751183
84 | 0.416227 0.643046 0.756582
85 | 0.428711 0.650956 0.761968
86 | 0.441199 0.658836 0.767341
87 | 0.453697 0.666696 0.772699
88 | 0.466195 0.674537 0.778044
89 | 0.478697 0.682349 0.783369
90 | 0.491208 0.690143 0.788682
91 | 0.503691 0.697910 0.793980
92 | 0.516178 0.705661 0.799260
93 | 0.528677 0.713387 0.804525
94 | 0.541149 0.721090 0.809775
95 | 0.553624 0.728778 0.815010
96 | 0.566096 0.736441 0.820229
97 | 0.578557 0.744089 0.825435
98 | 0.591014 0.751718 0.830626
99 | 0.603468 0.759314 0.835793
100 | 0.615908 0.766896 0.840941
101 | 0.628351 0.774452 0.846058
102 | 0.640779 0.781988 0.851147
103 | 0.653203 0.789485 0.856206
104 | 0.665631 0.796945 0.861214
105 | 0.678051 0.804371 0.866172
106 | 0.690457 0.811742 0.871059
107 | 0.702868 0.819048 0.875866
108 | 0.715265 0.826290 0.880567
109 | 0.727646 0.833439 0.885146
110 | 0.740019 0.840479 0.889570
111 | 0.752354 0.847380 0.893807
112 | 0.764662 0.854125 0.897821
113 | 0.776918 0.860678 0.901565
114 | 0.789096 0.866991 0.904992
115 | 0.801170 0.873031 0.908043
116 | 0.813110 0.878738 0.910653
117 | 0.824870 0.884062 0.912761
118 | 0.836396 0.888934 0.914302
119 | 0.847617 0.893289 0.915195
120 | 0.858470 0.897074 0.915385
121 | 0.868874 0.900206 0.914812
122 | 0.878729 0.902636 0.913418
123 | 0.887965 0.904303 0.911164
124 | 0.896497 0.905178 0.908034
125 | 0.904242 0.905221 0.904013
126 | 0.911151 0.904422 0.899132
127 | 0.917175 0.902800 0.893409
128 | 0.922285 0.900367 0.886911
129 | 0.926482 0.897173 0.879687
130 | 0.929789 0.893256 0.871826
131 | 0.932236 0.888698 0.863396
132 | 0.933880 0.883552 0.854476
133 | 0.934782 0.877893 0.845152
134 | 0.935013 0.871795 0.835493
135 | 0.934644 0.865313 0.825561
136 | 0.933752 0.858522 0.815421
137 | 0.932408 0.851469 0.805112
138 | 0.930682 0.844208 0.794685
139 | 0.928622 0.836778 0.784169
140 | 0.926298 0.829215 0.773579
141 | 0.923752 0.821545 0.762958
142 | 0.921017 0.813795 0.752313
143 | 0.918147 0.805997 0.741659
144 | 0.915156 0.798157 0.731008
145 | 0.912080 0.790294 0.720370
146 | 0.908933 0.782421 0.709752
147 | 0.905741 0.774540 0.699150
148 | 0.902506 0.766670 0.688588
149 | 0.899249 0.758812 0.678051
150 | 0.895973 0.750973 0.667550
151 | 0.892690 0.743148 0.657086
152 | 0.889402 0.735345 0.646657
153 | 0.886118 0.727569 0.636274
154 | 0.882831 0.719826 0.625923
155 | 0.879556 0.712106 0.615618
156 | 0.876289 0.704419 0.605357
157 | 0.873033 0.696764 0.595141
158 | 0.869784 0.689144 0.584972
159 | 0.866551 0.681541 0.574832
160 | 0.863333 0.673985 0.564746
161 | 0.860121 0.666453 0.554708
162 | 0.856920 0.658957 0.544709
163 | 0.853732 0.651500 0.534753
164 | 0.850562 0.644061 0.524842
165 | 0.847402 0.636670 0.514974
166 | 0.844258 0.629296 0.505146
167 | 0.841125 0.621957 0.495369
168 | 0.838005 0.614653 0.485627
169 | 0.834895 0.607392 0.475941
170 | 0.831802 0.600144 0.466284
171 | 0.828715 0.592938 0.456675
172 | 0.825639 0.585758 0.447109
173 | 0.822582 0.578600 0.437595
174 | 0.819528 0.571478 0.428106
175 | 0.816496 0.564388 0.418657
176 | 0.813463 0.557328 0.409260
177 | 0.810446 0.550285 0.399892
178 | 0.807443 0.543274 0.390575
179 | 0.804446 0.536288 0.381299
180 | 0.801454 0.529329 0.372040
181 | 0.798475 0.522380 0.362835
182 | 0.795500 0.515460 0.353660
183 | 0.792535 0.508575 0.344523
184 | 0.789573 0.501692 0.335435
185 | 0.786617 0.494827 0.326343
186 | 0.783657 0.487977 0.317312
187 | 0.780695 0.481123 0.308300
188 | 0.777737 0.474295 0.299327
189 | 0.774763 0.467464 0.290352
190 | 0.771788 0.460620 0.281424
191 | 0.768787 0.453783 0.272508
192 | 0.765776 0.446929 0.263640
193 | 0.762724 0.440055 0.254764
194 | 0.759638 0.433147 0.245872
195 | 0.756510 0.426200 0.237047
196 | 0.753316 0.419216 0.228190
197 | 0.750051 0.412163 0.219330
198 | 0.746698 0.405028 0.210470
199 | 0.743239 0.397819 0.201593
200 | 0.739651 0.390493 0.192739
201 | 0.735899 0.383060 0.183852
202 | 0.731988 0.375473 0.174977
203 | 0.727865 0.367743 0.166045
204 | 0.723516 0.359852 0.157131
205 | 0.718915 0.351766 0.148211
206 | 0.714028 0.343503 0.139282
207 | 0.708841 0.335048 0.130458
208 | 0.703318 0.326354 0.121545
209 | 0.697448 0.317502 0.112841
210 | 0.691227 0.308462 0.104132
211 | 0.684653 0.299264 0.095633
212 | 0.677734 0.289916 0.087350
213 | 0.670476 0.280477 0.079197
214 | 0.662904 0.271015 0.071510
215 | 0.655048 0.261520 0.064079
216 | 0.646969 0.252081 0.057104
217 | 0.638686 0.242711 0.050618
218 | 0.630261 0.233488 0.044750
219 | 0.621722 0.224449 0.039414
220 | 0.613135 0.215657 0.034829
221 | 0.604539 0.207086 0.031072
222 | 0.595947 0.198741 0.028212
223 | 0.587403 0.190700 0.026019
224 | 0.578937 0.182918 0.024396
225 | 0.570545 0.175423 0.023257
226 | 0.562268 0.168171 0.022523
227 | 0.554076 0.161202 0.022110
228 | 0.546007 0.154400 0.021861
229 | 0.538043 0.147854 0.021737
230 | 0.530182 0.141491 0.021722
231 | 0.522424 0.135276 0.021800
232 | 0.514776 0.129209 0.021957
233 | 0.507213 0.123272 0.022179
234 | 0.499733 0.117487 0.022455
235 | 0.492348 0.111818 0.022775
236 | 0.485034 0.106209 0.023130
237 | 0.477801 0.100607 0.023513
238 | 0.470639 0.095156 0.023916
239 | 0.463530 0.089668 0.024336
240 | 0.456494 0.084258 0.024766
241 | 0.449521 0.078741 0.025203
242 | 0.442603 0.073404 0.025644
243 | 0.435737 0.067904 0.026084
244 | 0.428918 0.062415 0.026522
245 | 0.422146 0.056832 0.026954
246 | 0.415437 0.051116 0.027378
247 | 0.408768 0.045352 0.027790
248 | 0.402132 0.039448 0.028189
249 | 0.395562 0.033385 0.028570
250 | 0.389015 0.027844 0.028932
251 | 0.382496 0.022586 0.029271
252 | 0.376028 0.017608 0.029583
253 | 0.369578 0.012890 0.029866
254 | 0.363161 0.008243 0.030115
255 | 0.356785 0.004035 0.030327
256 | 0.350423 0.000061 0.030499
257 |
--------------------------------------------------------------------------------
/code_AFR/Data/Seismic_stations_UGSS_Globig_binned_AS_binned_IDW_1degree.txt:
--------------------------------------------------------------------------------
1 | 25.00 -40.00 -18300.00
2 | 23.00 -37.00 -13400.00
3 | 24.00 -37.00 -13300.00
4 | 21.00 -36.00 -31400.00
5 | 24.00 -36.00 -13300.00
6 | 28.00 -36.00 -11500.00
7 | 0.00 -35.00 -10100.00
8 | 21.00 -35.00 -32394.66
9 | 22.00 -34.00 -34246.92
10 | 23.00 -34.00 -31000.00
11 | 22.00 -33.00 -41680.51
12 | 25.00 -33.00 -40000.00
13 | 62.00 -33.00 -10632.59
14 | 63.00 -33.00 -10650.00
15 | 21.00 -32.00 -43234.07
16 | 22.00 -32.00 -41730.05
17 | 62.00 -32.00 -9900.00
18 | 45.00 -31.00 -22550.00
19 | 62.00 -31.00 -9900.00
20 | 18.00 -30.00 -41116.26
21 | 19.00 -30.00 -40100.00
22 | 37.00 -30.00 -14600.00
23 | 19.00 -29.00 -41000.00
24 | 20.00 -29.00 -40052.51
25 | 21.00 -29.00 -40193.69
26 | 37.00 -29.00 -14600.00
27 | 27.00 -28.00 -34630.00
28 | 25.00 -27.00 -41300.00
29 | 26.00 -27.00 -41300.00
30 | 30.00 -27.00 -34930.00
31 | 58.00 -27.00 -11000.00
32 | 28.00 -26.00 -36700.00
33 | 30.00 -26.00 -34930.00
34 | 12.00 -25.00 -11831.37
35 | 29.00 -25.00 -36920.00
36 | 57.00 -25.00 -9500.00
37 | 12.00 -24.00 -18651.42
38 | 13.00 -24.00 -27297.39
39 | 14.00 -24.00 -31324.96
40 | 17.00 -24.00 -41100.00
41 | 18.00 -24.00 -46900.00
42 | 21.00 -24.00 -43000.00
43 | 29.00 -24.00 -35507.75
44 | 30.00 -24.00 -34300.00
45 | 14.00 -23.00 -29509.53
46 | 15.00 -23.00 -30000.00
47 | 17.00 -23.00 -44300.00
48 | 19.00 -23.00 -46000.00
49 | 21.00 -23.00 -43000.00
50 | 14.00 -22.00 -34000.00
51 | 15.00 -22.00 -39200.00
52 | 16.00 -22.00 -41545.17
53 | 17.00 -22.00 -50800.00
54 | 18.00 -22.00 -44900.00
55 | 30.00 -22.00 -35814.28
56 | 31.00 -22.00 -35907.56
57 | 14.00 -21.00 -34000.00
58 | 17.00 -21.00 -47967.10
59 | 18.00 -21.00 -50690.55
60 | 31.00 -21.00 -40000.00
61 | 31.00 -20.00 -40000.00
62 | 3.00 -14.00 -8500.00
63 | 4.00 -14.00 -8500.00
64 | 7.00 -14.00 -5100.00
65 | 8.00 -14.00 -10000.00
66 | 9.00 -14.00 -6500.00
67 | 10.00 -14.00 -7000.00
68 | -4.00 -13.00 -7500.00
69 | 4.00 -13.00 -8500.00
70 | 7.00 -13.00 -5378.83
71 | 8.00 -13.00 -8033.98
72 | 9.00 -13.00 -6389.51
73 | 10.00 -13.00 -7048.69
74 | 11.00 -13.00 -9863.01
75 | 12.00 -13.00 -19025.48
76 | -25.00 -12.00 -6000.00
77 | -24.00 -12.00 -6500.00
78 | -23.00 -12.00 -7417.20
79 | -22.00 -12.00 -6826.87
80 | -21.00 -12.00 -15809.00
81 | -20.00 -12.00 -6983.44
82 | -19.00 -12.00 -7041.18
83 | -15.00 -12.00 -4690.85
84 | -14.00 -12.00 -4565.06
85 | -13.00 -12.00 -4500.00
86 | -12.00 -12.00 -4500.00
87 | -11.00 -12.00 -4512.76
88 | -10.00 -12.00 -4600.00
89 | -6.00 -12.00 -5500.00
90 | -5.00 -12.00 -5500.00
91 | -4.00 -12.00 -5500.00
92 | -3.00 -12.00 -5500.00
93 | -2.00 -12.00 -5500.00
94 | -1.00 -12.00 -5500.00
95 | 0.00 -12.00 -5500.00
96 | 1.00 -12.00 -5500.00
97 | 4.00 -12.00 -7584.08
98 | 4.00 -11.00 -6500.00
99 | 5.00 -11.00 -6500.00
100 | 56.00 -10.00 -11200.00
101 | 57.00 -10.00 -9209.03
102 | 58.00 -10.00 -16600.00
103 | 59.00 -10.00 -16600.00
104 | -14.00 -9.00 -10080.07
105 | -13.00 -9.00 -10667.32
106 | -15.00 -8.00 -11297.55
107 | -14.00 -8.00 -11859.36
108 | -13.00 -8.00 -8200.00
109 | 59.00 -6.00 -9400.00
110 | 60.00 -6.00 -11900.00
111 | 59.00 -5.00 -9400.00
112 | 60.00 -5.00 -11900.00
113 | 37.00 -4.00 -30900.00
114 | 38.00 -4.00 -34919.66
115 | 39.00 -4.00 -30600.00
116 | 40.00 -4.00 -22900.00
117 | 38.00 -3.00 -43370.58
118 | 39.00 -3.00 -30600.00
119 | 27.00 -2.00 -35000.00
120 | 28.00 -2.00 -35000.00
121 | 35.00 -2.00 -32774.92
122 | 36.00 -2.00 -34676.00
123 | 37.00 -2.00 -38516.98
124 | 38.00 -2.00 -40784.77
125 | 34.00 -1.00 -31760.82
126 | 35.00 -1.00 -31947.38
127 | 36.00 -1.00 -34400.00
128 | 37.00 -1.00 -40117.93
129 | -24.00 0.00 -8300.00
130 | 34.00 0.00 -36000.00
131 | 35.00 0.00 -40591.54
132 | 36.00 0.00 -33188.79
133 | 7.00 1.00 -13875.06
134 | 8.00 1.00 -13000.00
135 | 34.00 1.00 -32800.00
136 | 35.00 1.00 -35749.62
137 | 36.00 1.00 -30282.00
138 | 37.00 1.00 -38691.43
139 | 38.00 1.00 -33499.61
140 | -20.00 2.00 -9800.00
141 | 7.00 2.00 -11874.16
142 | 8.00 2.00 -14779.44
143 | 36.00 2.00 -22321.88
144 | 37.00 2.00 -34626.70
145 | 38.00 2.00 -36470.72
146 | -20.00 3.00 -9800.00
147 | 8.00 3.00 -14500.00
148 | 36.00 3.00 -21851.93
149 | 37.00 3.00 -27174.12
150 | 38.00 3.00 -44000.00
151 | -3.00 4.00 -24793.80
152 | -2.00 4.00 -24382.87
153 | 36.00 4.00 -20667.73
154 | 38.00 4.00 -33000.00
155 | 39.00 4.00 -33000.00
156 | 40.00 4.00 -23000.00
157 | 38.00 5.00 -46100.00
158 | 39.00 5.00 -46100.00
159 | 14.00 7.00 -32300.00
160 | 13.00 8.00 -22700.00
161 | 14.00 8.00 -22700.00
162 | 39.00 8.00 -36852.89
163 | 40.00 8.00 -34397.07
164 | 13.00 9.00 -23100.00
165 | 14.00 9.00 -23100.00
166 | 38.00 9.00 -37900.00
167 | 39.00 9.00 -43740.00
168 | 40.00 9.00 -25456.05
169 | -24.00 10.00 -7575.61
170 | -22.00 10.00 -7800.00
171 | -21.00 10.00 -7800.00
172 | 38.00 10.00 -45000.00
173 | 39.00 10.00 -44602.41
174 | 40.00 10.00 -25187.66
175 | 41.00 10.00 -25300.00
176 | -24.00 11.00 -9873.66
177 | -23.00 11.00 -8603.93
178 | 41.00 11.00 -25100.00
179 | 45.00 11.00 -9800.00
180 | -23.00 12.00 -10200.00
181 | 41.00 12.00 -24500.00
182 | 44.00 12.00 -9600.00
183 | 45.00 12.00 -5300.00
184 | 46.00 12.00 -5300.00
185 | 41.00 13.00 -23700.00
186 | 46.00 13.00 -10700.00
187 | 52.00 13.00 -7900.00
188 | 40.00 14.00 -16800.00
189 | 41.00 14.00 -16800.00
190 | 43.00 14.00 -27486.41
191 | 44.00 14.00 -27000.00
192 | 51.00 14.00 -11100.00
193 | 52.00 14.00 -9424.63
194 | 53.00 14.00 -9900.00
195 | -24.00 15.00 -17100.00
196 | 43.00 15.00 -29586.36
197 | -25.00 16.00 -17981.60
198 | -24.00 16.00 -18694.09
199 | -23.00 16.00 -19100.00
200 | -25.00 17.00 -15800.00
201 | -24.00 17.00 -18310.75
202 | 42.00 17.00 -17518.01
203 | 42.00 18.00 -38386.95
204 | 43.00 18.00 -37500.00
205 | 42.00 19.00 -40150.93
206 | 43.00 19.00 -40100.00
207 | 59.00 19.00 -15855.68
208 | 60.00 19.00 -11850.00
209 | 44.00 20.00 -40030.00
210 | 40.00 21.00 -38700.00
211 | 43.00 21.00 -37817.23
212 | -16.00 22.00 -27591.64
213 | -15.00 22.00 -29000.00
214 | 43.00 22.00 -34400.00
215 | 44.00 22.00 -35000.00
216 | -16.00 23.00 -27721.61
217 | 44.00 23.00 -38380.26
218 | 45.00 23.00 -39348.86
219 | 43.00 24.00 -38400.00
220 | 45.00 24.00 -42367.51
221 | 46.00 24.00 -42100.00
222 | 62.00 24.00 -14800.00
223 | 63.00 24.00 -14800.00
224 | 46.00 25.00 -41170.00
225 | 47.00 25.00 -43760.00
226 | 58.00 25.00 -20600.00
227 | 59.00 25.00 -20600.00
228 | 63.00 25.00 -19300.00
229 | 32.00 26.00 -29000.00
230 | 33.00 26.00 -29532.22
231 | 34.00 26.00 -31999.45
232 | 42.00 26.00 -33620.00
233 | 43.00 26.00 -33620.00
234 | -18.00 27.00 -10500.00
235 | -17.00 27.00 -11669.77
236 | 52.00 27.00 -39500.00
237 | -18.00 28.00 -12200.00
238 | -17.00 28.00 -13916.34
239 | 34.00 28.00 -26700.00
240 | 35.00 28.00 -26700.00
241 | -17.00 29.00 -13800.00
242 | -16.00 29.00 -11207.86
243 | -15.00 29.00 -15000.00
244 | -10.00 29.00 -29400.00
245 | -8.00 29.00 -31500.00
246 | 34.00 29.00 -29900.00
247 | 35.00 29.00 -30736.67
248 | 56.00 29.00 -64600.00
249 | -16.00 30.00 -11034.33
250 | -15.00 30.00 -11400.00
251 | -10.00 30.00 -21500.00
252 | -9.00 30.00 -21500.00
253 | -7.00 30.00 -30413.02
254 | -6.00 30.00 -30719.99
255 | 28.00 30.00 -33000.00
256 | 29.00 30.00 -33000.00
257 | 35.00 30.00 -35546.19
258 | 36.00 30.00 -36914.11
259 | 37.00 30.00 -33960.00
260 | 56.00 30.00 -33000.00
261 | -10.00 31.00 -31100.00
262 | -9.00 31.00 -30000.00
263 | -8.00 31.00 -29393.19
264 | -7.00 31.00 -31820.47
265 | -4.00 31.00 -35539.71
266 | 34.00 31.00 -20717.09
267 | 35.00 31.00 -30604.71
268 | 36.00 31.00 -31203.83
269 | 37.00 31.00 -33968.08
270 | -23.00 32.00 -10900.00
271 | -8.00 32.00 -31218.98
272 | -6.00 32.00 -29400.00
273 | -5.00 32.00 -38645.12
274 | -4.00 32.00 -37714.67
275 | 35.00 32.00 -31400.00
276 | 36.00 32.00 -32858.45
277 | -9.00 33.00 -34697.56
278 | -8.00 33.00 -34764.19
279 | -7.00 33.00 -36300.00
280 | -6.00 33.00 -33840.18
281 | 9.00 33.00 -34061.67
282 | 32.00 33.00 -28400.00
283 | -6.00 34.00 -42000.00
284 | -5.00 34.00 -35690.31
285 | 9.00 34.00 -35483.90
286 | 57.00 34.00 -42000.00
287 | 58.00 34.00 -42000.00
288 | -5.00 35.00 -45561.16
289 | -4.00 35.00 -36000.00
290 | -3.00 35.00 -29686.25
291 | -2.00 35.00 -29000.00
292 | 8.00 35.00 -35200.00
293 | 9.00 35.00 -37152.59
294 | 24.00 35.00 -31500.00
295 | 26.00 35.00 -32200.00
296 | -10.00 36.00 -15500.00
297 | -6.00 36.00 -32116.74
298 | -5.00 36.00 -26753.81
299 | 8.00 36.00 -37300.00
300 | 9.00 36.00 -37352.61
301 | 16.00 36.00 -17356.94
302 | 17.00 36.00 -17996.62
303 | 18.00 36.00 -15000.00
304 | -9.00 37.00 -30204.91
305 | -7.00 37.00 -31200.00
306 | -6.00 37.00 -30187.83
307 | -3.00 37.00 -36200.00
308 | 8.00 37.00 -24300.00
309 | 9.00 37.00 -28247.31
310 | 14.00 37.00 -46500.00
311 | 15.00 37.00 -46500.00
312 | 16.00 37.00 -23788.87
313 | 17.00 37.00 -19100.00
314 | 26.00 37.00 -23900.00
315 | 61.00 37.00 -48562.09
316 | 62.00 37.00 -53400.00
317 | -9.00 38.00 -28880.37
318 | -8.00 38.00 -27892.53
319 | -7.00 38.00 -29001.33
320 | 8.00 38.00 -23200.00
321 | 9.00 38.00 -23200.00
322 | 17.00 38.00 -19100.00
323 | 24.00 38.00 -29100.00
324 | 25.00 38.00 -26300.00
325 | 54.00 38.00 -30649.59
326 | 55.00 38.00 -30632.11
327 | 58.00 38.00 -45900.00
328 | 60.00 38.00 -40506.57
329 | 61.00 38.00 -37124.91
330 | 62.00 38.00 -47887.12
331 | 63.00 38.00 -47500.00
332 | -9.00 39.00 -30900.00
333 | -8.00 39.00 -27300.00
334 | -7.00 39.00 -27600.00
335 | -4.00 39.00 -34200.00
336 | 1.00 39.00 -20249.34
337 | 2.00 39.00 -20946.69
338 | 13.00 39.00 -9915.99
339 | 16.00 39.00 -27781.11
340 | 17.00 39.00 -45000.00
341 | 54.00 39.00 -40460.93
342 | 55.00 39.00 -41976.16
343 | 56.00 39.00 -45844.97
344 | 57.00 39.00 -43445.42
345 | 58.00 39.00 -41382.92
346 | 59.00 39.00 -39756.20
347 | 60.00 39.00 -41090.00
348 | 63.00 39.00 -49200.00
349 | -4.00 40.00 -30400.00
350 | -3.00 40.00 -30400.00
351 | 3.00 40.00 -24085.65
352 | 4.00 40.00 -23000.00
353 | 8.00 40.00 -30800.00
354 | 9.00 40.00 -30800.00
355 | 11.00 40.00 -11000.00
356 | 13.00 40.00 -9900.00
357 | 54.00 40.00 -27000.00
358 | 55.00 40.00 -27000.00
359 | 59.00 40.00 -37033.33
360 | 60.00 40.00 -40800.00
361 | 61.00 40.00 -42528.64
362 | 62.00 40.00 -40946.32
363 | 63.00 40.00 -48400.00
364 |
--------------------------------------------------------------------------------
/code_AFR/Data/Seismic_stations_UGSS_Globig_binned_RF_binned_IDW_1degree.txt:
--------------------------------------------------------------------------------
1 | 4.00 -36.00 -6800.00
2 | 19.00 -34.00 -33500.00
3 | 20.00 -34.00 -38500.00
4 | 21.00 -34.00 -48000.00
5 | 44.00 -34.00 -22900.00
6 | 45.00 -34.00 -22900.00
7 | 19.00 -33.00 -34000.00
8 | 20.00 -33.00 -34000.00
9 | 22.00 -33.00 -42000.00
10 | 26.00 -33.00 -35500.00
11 | 27.00 -33.00 -35500.00
12 | 18.00 -32.00 -1700.00
13 | 20.00 -32.00 -46200.00
14 | 21.00 -32.00 -46600.00
15 | 22.00 -32.00 -41500.00
16 | 44.00 -32.00 -22200.00
17 | 21.00 -31.00 -45000.00
18 | 22.00 -31.00 -48000.00
19 | 23.00 -31.00 -46000.00
20 | 24.00 -31.00 -44500.00
21 | 25.00 -31.00 -35500.00
22 | 26.00 -31.00 -35500.00
23 | 21.00 -30.00 -40500.00
24 | 22.00 -30.00 -43000.00
25 | 23.00 -30.00 -37086.62
26 | 24.00 -30.00 -35350.00
27 | 25.00 -30.00 -36500.00
28 | 22.00 -29.00 -40500.00
29 | 23.00 -29.00 -38500.00
30 | 24.00 -29.00 -36500.00
31 | 25.00 -29.00 -36256.09
32 | 26.00 -29.00 -38210.00
33 | 21.00 -28.00 -40500.00
34 | 22.00 -28.00 -48000.00
35 | 23.00 -28.00 -41500.00
36 | 24.00 -28.00 -38618.63
37 | 25.00 -28.00 -38012.51
38 | 26.00 -28.00 -38500.00
39 | 27.00 -28.00 -39000.00
40 | 28.00 -28.00 -40788.23
41 | 23.00 -27.00 -42210.00
42 | 24.00 -27.00 -39000.00
43 | 25.00 -27.00 -38498.67
44 | 26.00 -27.00 -38775.32
45 | 27.00 -27.00 -37500.00
46 | 28.00 -27.00 -38000.00
47 | 29.00 -27.00 -40353.75
48 | 30.00 -27.00 -38000.00
49 | 31.00 -27.00 -35500.00
50 | 32.00 -27.00 -35772.39
51 | 24.00 -26.00 -43000.00
52 | 25.00 -26.00 -39500.00
53 | 26.00 -26.00 -41371.46
54 | 27.00 -26.00 -43500.00
55 | 28.00 -26.00 -35500.00
56 | 29.00 -26.00 -39323.00
57 | 30.00 -26.00 -42500.00
58 | 31.00 -26.00 -44000.00
59 | 24.00 -25.00 -41500.00
60 | 25.00 -25.00 -41345.40
61 | 26.00 -25.00 -44363.68
62 | 27.00 -25.00 -42500.00
63 | 28.00 -25.00 -45000.00
64 | 29.00 -25.00 -45000.00
65 | 30.00 -25.00 -48500.00
66 | 31.00 -25.00 -48500.00
67 | 24.00 -24.00 -43500.00
68 | 25.00 -24.00 -41500.00
69 | 26.00 -24.00 -42500.00
70 | 27.00 -24.00 -40000.00
71 | 28.00 -24.00 -42500.00
72 | 30.00 -24.00 -43000.00
73 | 31.00 -24.00 -37000.00
74 | 26.00 -23.00 -41000.00
75 | 27.00 -23.00 -43000.00
76 | 28.00 -23.00 -43750.00
77 | 29.00 -23.00 -42525.06
78 | 30.00 -23.00 -41500.00
79 | 31.00 -23.00 -37000.00
80 | 26.00 -22.00 -46500.00
81 | 27.00 -22.00 -40728.66
82 | 28.00 -22.00 -41000.00
83 | 29.00 -22.00 -47591.82
84 | 30.00 -22.00 -46000.00
85 | 31.00 -22.00 -34500.00
86 | 26.00 -21.00 -40500.00
87 | 27.00 -21.00 -42865.75
88 | 29.00 -21.00 -39000.00
89 | 30.00 -21.00 -36500.00
90 | 31.00 -21.00 -36752.80
91 | 56.00 -21.00 -10700.00
92 | 27.00 -20.00 -29000.00
93 | 28.00 -20.00 -38000.00
94 | 29.00 -20.00 -38000.00
95 | 30.00 -20.00 -37142.29
96 | 31.00 -20.00 -37881.57
97 | 32.00 -20.00 -37000.00
98 | 17.00 -19.00 -42000.00
99 | 18.00 -19.00 -42000.00
100 | 31.00 -19.00 -37200.00
101 | 47.00 -19.00 -35048.61
102 | 48.00 -19.00 -31086.88
103 | 47.00 -18.00 -28800.00
104 | 31.00 -17.00 -29610.00
105 | 32.00 -17.00 -29610.00
106 | -6.00 -16.00 -10000.00
107 | 28.00 -15.00 -40000.00
108 | 36.00 -11.00 -37000.00
109 | 35.00 -10.00 -37790.30
110 | 32.00 -9.00 -46700.00
111 | 33.00 -9.00 -42008.76
112 | 34.00 -9.00 -38100.00
113 | 35.00 -9.00 -37604.69
114 | -15.00 -8.00 -6400.00
115 | -14.00 -8.00 -6400.00
116 | 31.00 -8.00 -46371.74
117 | 32.00 -8.00 -45240.47
118 | 33.00 -8.00 -38063.76
119 | 34.00 -8.00 -37000.00
120 | 35.00 -8.00 -38800.00
121 | 36.00 -8.00 -40270.50
122 | 37.00 -8.00 -37200.00
123 | 31.00 -7.00 -44988.75
124 | 33.00 -7.00 -42000.00
125 | 34.00 -7.00 -42000.00
126 | 37.00 -7.00 -36921.08
127 | 38.00 -7.00 -36100.00
128 | 31.00 -6.00 -40900.00
129 | 34.00 -6.00 -38000.00
130 | 29.00 -5.00 -40000.00
131 | 30.00 -5.00 -40663.50
132 | 31.00 -5.00 -40515.22
133 | 32.00 -5.00 -40300.00
134 | 33.00 -5.00 -37000.00
135 | 34.00 -5.00 -37000.00
136 | 35.00 -5.00 -37920.93
137 | 36.00 -5.00 -37001.02
138 | 37.00 -5.00 -36407.53
139 | 38.00 -5.00 -39000.00
140 | 39.00 -5.00 -39000.00
141 | 30.00 -4.00 -38231.91
142 | 31.00 -4.00 -39215.93
143 | 32.00 -4.00 -37000.00
144 | 33.00 -4.00 -37000.00
145 | 35.00 -4.00 -40192.71
146 | 36.00 -4.00 -37000.00
147 | 37.00 -4.00 -36000.00
148 | 31.00 -3.00 -39164.45
149 | 32.00 -3.00 -36600.00
150 | 37.00 -3.00 -38269.07
151 | 13.00 -2.00 -45600.00
152 | 14.00 -2.00 -45600.00
153 | 31.00 -2.00 -44400.00
154 | 32.00 -2.00 -43936.67
155 | 37.00 -2.00 -39000.00
156 | 38.00 -2.00 -40000.00
157 | 30.00 -1.00 -37000.00
158 | 31.00 -1.00 -36000.00
159 | 32.00 -1.00 -42400.00
160 | 37.00 -1.00 -40004.17
161 | 38.00 -1.00 -39049.56
162 | 30.00 0.00 -28170.67
163 | 31.00 0.00 -32437.37
164 | 32.00 0.00 -36840.93
165 | 33.00 0.00 -44400.00
166 | 35.00 0.00 -37000.00
167 | 36.00 0.00 -30000.00
168 | 30.00 1.00 -25876.82
169 | 31.00 1.00 -31549.32
170 | 33.00 1.00 -44400.00
171 | 34.00 1.00 -38000.00
172 | 35.00 1.00 -37996.59
173 | 10.00 2.00 -28000.00
174 | 11.00 2.00 -45500.00
175 | 33.00 2.00 -40200.00
176 | 34.00 2.00 -40200.00
177 | 10.00 3.00 -28000.00
178 | 11.00 3.00 -45500.00
179 | 12.00 3.00 -45500.00
180 | 13.00 3.00 -43000.00
181 | 15.00 3.00 -43000.00
182 | 36.00 3.00 -19600.00
183 | 9.00 4.00 -25500.00
184 | 10.00 4.00 -38000.00
185 | 11.00 4.00 -40288.80
186 | 12.00 4.00 -40720.52
187 | 13.00 4.00 -48000.00
188 | 15.00 4.00 -43000.00
189 | 18.00 4.00 -42700.00
190 | 19.00 4.00 -42700.00
191 | 9.00 5.00 -28000.00
192 | 10.00 5.00 -32937.83
193 | 11.00 5.00 -35500.00
194 | 12.00 5.00 -36736.67
195 | 18.00 5.00 -40000.00
196 | 19.00 5.00 -40000.00
197 | -5.00 6.00 -39700.00
198 | -1.00 6.00 -37560.00
199 | 0.00 6.00 -34303.56
200 | 9.00 6.00 -30500.00
201 | 10.00 6.00 -32762.10
202 | 11.00 6.00 -36544.04
203 | 12.00 6.00 -35500.00
204 | 13.00 6.00 -35500.00
205 | 14.00 6.00 -35500.00
206 | 37.00 6.00 -30000.00
207 | 38.00 6.00 -35175.83
208 | -5.00 7.00 -39700.00
209 | 0.00 7.00 -32760.00
210 | 1.00 7.00 -32760.00
211 | 7.00 7.00 -28500.00
212 | 8.00 7.00 -28500.00
213 | 11.00 7.00 -40500.00
214 | 12.00 7.00 -38000.00
215 | 13.00 7.00 -34941.23
216 | 14.00 7.00 -34150.15
217 | 37.00 7.00 -34199.58
218 | 38.00 7.00 -37925.44
219 | 39.00 7.00 -39076.44
220 | 40.00 7.00 -41952.79
221 | 13.00 8.00 -30500.00
222 | 36.00 8.00 -36000.00
223 | 37.00 8.00 -36000.00
224 | 38.00 8.00 -34328.46
225 | 39.00 8.00 -34506.63
226 | 40.00 8.00 -38237.82
227 | 13.00 9.00 -27692.11
228 | 36.00 9.00 -37163.12
229 | 37.00 9.00 -40916.80
230 | 38.00 9.00 -40580.38
231 | 39.00 9.00 -38307.96
232 | 40.00 9.00 -34850.09
233 | 41.00 9.00 -39906.50
234 | 14.00 10.00 -28000.00
235 | 15.00 10.00 -30500.00
236 | 38.00 10.00 -43314.87
237 | 39.00 10.00 -40974.47
238 | 40.00 10.00 -36665.27
239 | 41.00 10.00 -30000.00
240 | 8.00 11.00 -33250.00
241 | 14.00 11.00 -33000.00
242 | 37.00 11.00 -44000.00
243 | 40.00 11.00 -43900.00
244 | 43.00 11.00 -14650.00
245 | 37.00 12.00 -44000.00
246 | 39.00 12.00 -37000.00
247 | 40.00 12.00 -37000.00
248 | 41.00 12.00 -26415.79
249 | 42.00 12.00 -39220.00
250 | 43.00 12.00 -14650.00
251 | 2.00 13.00 -41000.00
252 | -17.00 14.00 -26300.00
253 | -4.00 14.00 -42600.00
254 | -17.00 15.00 -26300.00
255 | -4.00 15.00 -42600.00
256 | 47.00 16.00 -33000.00
257 | 42.00 18.00 -38400.00
258 | 43.00 18.00 -41221.30
259 | 44.00 18.00 -43500.00
260 | 42.00 19.00 -41600.00
261 | 41.00 20.00 -38000.00
262 | 42.00 20.00 -37759.42
263 | 43.00 20.00 -37622.30
264 | 40.00 21.00 -37400.00
265 | 43.00 21.00 -38100.00
266 | 42.00 22.00 -44030.00
267 | 43.00 22.00 -44030.00
268 | 44.00 22.00 -38200.00
269 | 5.00 23.00 -37800.00
270 | 6.00 23.00 -37800.00
271 | 44.00 23.00 -38057.93
272 | 45.00 23.00 -34600.00
273 | 5.00 24.00 -33000.00
274 | 38.00 24.00 -31600.00
275 | 43.00 24.00 -36400.00
276 | 44.00 24.00 -40100.00
277 | 5.00 25.00 -33000.00
278 | 46.00 25.00 -45400.00
279 | 47.00 25.00 -42950.20
280 | 48.00 25.00 -43332.18
281 | 50.00 25.00 -41200.00
282 | 39.00 26.00 -35200.00
283 | 42.00 26.00 -36500.00
284 | 43.00 26.00 -39085.07
285 | 49.00 26.00 -48960.00
286 | 50.00 26.00 -48960.00
287 | 40.00 27.00 -40900.00
288 | 42.00 27.00 -36900.00
289 | -10.00 28.00 -32500.00
290 | 36.00 28.00 -34400.00
291 | 37.00 28.00 -34400.00
292 | -18.00 29.00 -8800.00
293 | -14.00 29.00 -19000.00
294 | -13.00 29.00 -19000.00
295 | -10.00 29.00 -32500.00
296 | 36.00 29.00 -36600.00
297 | 48.00 29.00 -45000.00
298 | -9.00 30.00 -32831.59
299 | -8.00 30.00 -37436.64
300 | -7.00 30.00 -34150.00
301 | -6.00 30.00 -32902.07
302 | 31.00 30.00 -33800.00
303 | 32.00 30.00 -32401.14
304 | 35.00 30.00 -35500.00
305 | 36.00 30.00 -36400.00
306 | 53.00 30.00 -32200.00
307 | -10.00 31.00 -24650.00
308 | -9.00 31.00 -34886.24
309 | -8.00 31.00 -41736.17
310 | -7.00 31.00 -29693.08
311 | -6.00 31.00 -30444.69
312 | -4.00 31.00 -25331.01
313 | 35.00 31.00 -31500.00
314 | 37.00 31.00 -32900.00
315 | -8.00 32.00 -44700.00
316 | -5.00 32.00 -28729.70
317 | -4.00 32.00 -32171.56
318 | 13.00 32.00 -29650.00
319 | 21.00 32.00 -30650.00
320 | 35.00 32.00 -31206.11
321 | 38.00 32.00 -37200.00
322 | 42.00 32.00 -38700.00
323 | 43.00 32.00 -38700.00
324 | 57.00 32.00 -54400.00
325 | -7.00 33.00 -32200.00
326 | -5.00 33.00 -31328.91
327 | -4.00 33.00 -37262.12
328 | 21.00 33.00 -30650.00
329 | 40.00 33.00 -33400.00
330 | 41.00 33.00 -33400.00
331 | 44.00 33.00 -38000.00
332 | 45.00 33.00 -38000.00
333 | 56.00 33.00 -42100.00
334 | 57.00 33.00 -42200.00
335 | -7.00 34.00 -32800.00
336 | -6.00 34.00 -31855.13
337 | -5.00 34.00 -35992.83
338 | -4.00 34.00 -27747.20
339 | -3.00 34.00 -34400.00
340 | -2.00 34.00 -30198.12
341 | 49.00 34.00 -43800.00
342 | 50.00 34.00 -43800.00
343 | 57.00 34.00 -42200.00
344 | -6.00 35.00 -38821.92
345 | -5.00 35.00 -41377.90
346 | -4.00 35.00 -30609.24
347 | -3.00 35.00 -24767.65
348 | -2.00 35.00 -23238.55
349 | 27.00 35.00 -28700.00
350 | 51.00 35.00 -45284.56
351 | -5.00 36.00 -40100.00
352 | -3.00 36.00 -21800.00
353 | 3.00 36.00 -26200.00
354 | 7.00 36.00 -26493.76
355 | 8.00 36.00 -26494.71
356 | 26.00 36.00 -19800.00
357 | 27.00 36.00 -28700.00
358 | 41.00 36.00 -35700.00
359 | 42.00 36.00 -35700.00
360 | 43.00 36.00 -32300.00
361 | 45.00 36.00 -40900.00
362 | 46.00 36.00 -40900.00
363 | 51.00 36.00 -44136.39
364 | 52.00 36.00 -46992.54
365 | 55.00 36.00 -21400.00
366 | 22.00 37.00 -42600.00
367 | 27.00 38.00 -24700.00
368 | -8.00 39.00 -31800.00
369 | 29.00 39.00 -31510.16
370 | -8.00 40.00 -31800.00
371 | -4.00 40.00 -33514.40
372 | 4.00 40.00 -25000.00
373 | 33.00 40.00 -36819.87
374 |
--------------------------------------------------------------------------------
/code_AFR/grad_inv_functions_AFR.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | from scipy.interpolate import interp1d,RegularGridInterpolator
3 | import subprocess
4 | import tempfile
5 | from matplotlib import path
6 |
7 | def create_Jacobian(lon,lat,component,moho_top,moho_bottom, moho_top_shift, moho_bottom_shift, heights, density, point_mass_number):
8 | # Calculates the Jacobian Matrix of the inversion
9 | # The shape of the Matrix is n Stations (row) and m Tesseroids (column).
10 | # The function get_inversion_design_matrix calculates the gravitational effect of each tesseroid for each station.
11 | #
12 | # Input:
13 | # mode - forward calculation of single or all gravity components
14 | # lonGrid,latGrid - Grid of Longitude and Latitude values, n X m shape
15 | # component - component of which the gravitational effect is calculated
16 | # top, bottom - grids of top layer and bottom layer of discretized Moho depth
17 | # top_shift, bottom_shift - shifted layers of top and bottom
18 | # height_km - Measured height of the data (1D-scalar)
19 | # dens - 1D-vector of density contrast
20 | #
21 | # Output:
22 | # J,J_shift - Jacobian matrices
23 | # bigger_mat - 3D Jacobian matrix (only necessary for FTG-mode)
24 |
25 | stations = np.vstack((lon,lat,heights)).T
26 | dx=(np.amax(lon)-np.amin(lon))/(np.sqrt(len(lon))-1)
27 | dy=(np.amax(lat)-np.amin(lat))/(np.sqrt(len(lat))-1)
28 | density=np.abs(density)
29 | print("Calculate 1st Jacobian")
30 | lon0,lat0,depths,masses=tesses_to_pointmass(lon,lat,dx,dy,
31 | moho_top,moho_bottom,density,hsplit=point_mass_number,vsplit=point_mass_number)
32 | J=memory_save_masspoint_calc_FTG_2(lon0,lat0,depths,masses,lon,lat,heights,point_mass_number)
33 |
34 | print("Calculate 2nd Jacobian")
35 | lon0,lat0,depths,masses=tesses_to_pointmass(lon,lat,dx,dy,
36 | moho_top_shift,moho_bottom_shift,density,hsplit=point_mass_number,vsplit=point_mass_number)
37 | J_shift=memory_save_masspoint_calc_FTG_2(lon0,lat0,depths,masses,lon,lat,heights,point_mass_number)
38 |
39 | return J,J_shift
40 |
41 | def invert_and_calculate(prefix,moho,bouguer,J,J_shift,dmatrix,save_fields,mode,shape):
42 |
43 | # Inverts the Moho depth with the calcualted Jacobian Matrix and optionally calculates residual fields
44 | #
45 | # Input:
46 | # prefix - prefix of datafile
47 | # moho - Moho depth of starting model
48 | # bouguer - gravity data
49 | # J, J_shift - Jacobian matrices
50 | # dmatrix - Smoothing matrix
51 | # save_fields - "yes" or "no" option to save calculated fields
52 | # mode - forward calculation of single or all gravity components
53 | # shape - Size of the data
54 | #
55 | # Output:
56 | # moho final - inverted Moho depth
57 | # bouguer_fit - Fit to gravity data
58 |
59 | N_points=dmatrix.shape[0]
60 | big_G = J.reshape((1*N_points,N_points))
61 | big_delta_G = J_shift.reshape((1*N_points,N_points))
62 | bouguer_mod=np.sum(big_G, axis=1)
63 | big_d=bouguer.reshape((1*N_points)) - bouguer_mod
64 | bouguer_obs=bouguer.reshape((1*N_points))
65 |
66 | rhs = big_delta_G.T.dot(big_d)-dmatrix.T.dot(dmatrix).dot(moho/1000)
67 | lhs = big_delta_G.T.dot(big_delta_G)+dmatrix.T.dot(dmatrix)
68 | moho_shift = np.linalg.solve(lhs,rhs)
69 | predicted = big_delta_G.dot(moho_shift).reshape((1,shape[1],shape[0]))
70 | moho_final = moho_shift + moho/1000
71 | bouguer_res=bouguer_obs-bouguer_mod
72 | bouguer_fit=np.copy(bouguer_res)
73 |
74 | if save_fields=="yes":
75 | np.savetxt(prefix+"_inverted_Moho.txt",moho_final)
76 | np.savetxt(prefix+"_predicted_field.txt",bouguer_mod)
77 | np.savetxt(prefix+"_observed.txt",bouguer_obs)
78 | np.savetxt(prefix+"_deltay_it0.txt",bouguer_res)
79 |
80 | return moho_final,bouguer_fit
81 |
82 | def weight_Jacobian(J,J_shift,dens,dens_start):
83 | # Weights the Jacobian matrices with the respective density contrasts
84 | #
85 | # Input:
86 | # J, J_shift - Jacobian matrices of initial inversion
87 | # dens_start - initial density contrasts
88 | # dens - density contrast of each iteration
89 | #
90 | # Output:
91 | # J_new, J_new_shift - Weighted Jacobian matrices
92 | J_new=(np.abs(dens)/dens_start)*J
93 | J_shift_new=(np.abs(dens)/dens_start)*J_shift
94 |
95 | return J_new,J_shift_new
96 |
97 |
98 | def load_grav_data(farfield,sediments,area):
99 |
100 | # Load gravitational data for the inversion
101 | # If inversion is carried out for different component than gzz, gravity data have to be changed manually inside the function
102 | # Gravitational data is corrected for global topography
103 | # --> Farfield gravitational effect has to be replaced when changing the study area!
104 | # Resolution of the data must be identical with resolution of initial Moho depth! (1 degree)
105 | #
106 | # Farfield effect accounts for isostatic effect outside of study area and has to be calculated separately
107 | # If farfield effect is activated, gravity data with global topographic correction and farfield compensation is calculated
108 | # Gravitational effect of sediments is optional and has to be calcualted separately and must be in the same format
109 | #
110 | # Input:
111 | # farfield - "yes" or "no" statement
112 | # sediments - "yes" or "no" statement
113 | # area - boundaries of the study area
114 | #
115 | # Output:
116 | # arrays - 3-column Matrix of the gravity data (Lon,Lat, Gravity)
117 |
118 | data=np.loadtxt('Gravity_Data/guu_global_Topo_corrected_1degree.xyz')
119 | data=np.array((data[:,0],data[:,1],data[:,2])).T
120 | data=cut_data_to_study_area(data,area)
121 | data=data[np.lexsort((data[:,0],data[:,1]))]
122 | if farfield=="yes":
123 | iso_outside=np.loadtxt('Gravity_Data/Farfield_distant_effect_Africa_gzz_225km_1degree.xyz')
124 | iso_outside=iso_outside[np.lexsort((iso_outside[:,0],iso_outside[:,1]))]
125 | iso_outside=iso_outside[:,2]
126 | arrays = np.array((data[:,0], data[:,1], data[:,2]+iso_outside))
127 | if farfield=="yes" and sediments=="yes":
128 | sed=np.loadtxt('Gravity_Data/gzz_Congo_Basin_Sediments_Africa_225km_1degree_v2.txt')
129 | sed=sed[np.lexsort((sed[:,0],sed[:,1]))]
130 | sed=sed[:,2]
131 | arrays = np.array((data[:,0], data[:,1], data[:,2]+sed+iso_outside))
132 | if farfield!="yes" and sediments=="yes":
133 | sed=np.loadtxt('Gravity_Data/gzz_Congo_Basin_Sediments_Africa_225km_1degree_v2.txt')
134 | sed=sed[np.lexsort((sed[:,0],sed[:,1]))]
135 | sed=sed[:,2]
136 | arrays = np.array((data[:,0], data[:,1], data[:,2]-sed))
137 | if farfield!="yes" and sediments!="yes":
138 | arrays = np.array((data[:,0], data[:,1], data[:,2]))
139 | return np.transpose(arrays)
140 |
141 | def cut_data_to_study_area(data,area):
142 |
143 | # Cuts the data to the user-defined study area
144 |
145 | data=data[~(data[:,0]area[3])]
147 | data=data[~(data[:,1]area[1])]
149 | return data
150 |
151 | def create_density_combinations(k,number_of_units):
152 |
153 | # Creates and sorts all density combinations for k density contrasts of n number of units
154 | # The combinations are stored in a matrix
155 | # total number of combinations is n^k
156 | #
157 | # Input:
158 | # k - range of density contrasts
159 | # number_of_units - Number of tectonic units
160 | #
161 | # Output:
162 | # dens_mat - matrix containing all density combinations (row) of different tectonic units (column)
163 | dens_mat=np.transpose(np.tile(k,(number_of_units,len(k)**(number_of_units-1))))
164 |
165 | for i in range(1,number_of_units):
166 | dens_mat[:,number_of_units-1-i]=np.transpose(np.reshape(dens_mat[:,number_of_units-1-i],(len(k)**i,len(k)**(number_of_units-i)))).flatten()
167 | return dens_mat
168 |
169 | def interp_regular_grid_on_irregular_database(area,dx,moho,seismic_stations):
170 |
171 | # Interpolate regular grid values on irregular distributed points
172 | # points have to be inside the boundaries of the grid
173 | #
174 | # Input:
175 | # area - boundaries of the study area
176 | # dx - step size of the grid
177 | # moho - 1-column layer of Moho depth
178 | # seismic stations - 3-column layer of seismic stations (Lon,Lat,Station)
179 | #
180 | # Output:
181 | # interp_arr - Interpolated values of gridded data
182 | # moho_diff - Difference between point estimates and interpolated data
183 |
184 | lon=np.arange(area[2],area[3]+dx,dx)
185 | lat=np.arange(area[0],area[1]+dx,dx)
186 |
187 | moho_for_interp=moho.reshape((len(lat),len(lon)))
188 | moho_for_interp=np.transpose(moho_for_interp)
189 |
190 | interp_func=RegularGridInterpolator((lon,lat),moho_for_interp)
191 | interp_arr=interp_func(seismic_stations[:,0:2],method="linear")
192 | moho_diff=(seismic_stations[:,2]-interp_arr)/1000
193 | return moho_diff,interp_arr
194 |
195 |
196 | def create_rms_matrix(rms_matrix,data,moho_resid_points,moho_resid_grid,i,bouguer_fit):
197 |
198 | # Creates a matrix of RMS-values for residual Moho depth and residual gravity field
199 |
200 | bouguer_fit=bouguer_fit[~(data[:,2]==0)] # remove values outside of coastline
201 | bouguer_fit_rms=np.sqrt(np.sum(bouguer_fit**2)/(bouguer_fit.shape)) # compute RMS
202 |
203 | moho_resid_points_rms=np.sqrt(np.sum(moho_resid_points**2)/(moho_resid_points.shape)) # Compute RMS of points only
204 |
205 | moho_resid_grid=moho_resid_grid[~(data[:,2]==0)] # remove values outside of coastline
206 | moho_resid_grid_rms=np.sqrt(np.sum(moho_resid_grid**2)/(moho_resid_grid.shape)) # compute RMS of grid
207 |
208 | rms_matrix[i,0]=bouguer_fit_rms # construct columns of matrix, containing RMS values of residual field, residual Moho depth and residual binned only Moho depth
209 | rms_matrix[i,1]=moho_resid_points_rms
210 | rms_matrix[i,2]=moho_resid_grid_rms
211 | return rms_matrix
212 |
213 | def construct_layers_for_gradient_inversion(refmoho,moho):
214 |
215 | # constructs layers which are required for the inversion
216 | #
217 | # Input:
218 | # refmoho - Reference Moho depth, which is a single values
219 | # moho - Moho depth of starting model, is undulating around refmoho
220 | # area - boundaries of the study area
221 | # dx and dy - resolution of the layers
222 | #
223 | # Output:
224 | # individual layers of top and bottom of discretized Moho depth
225 | moho=np.copy(moho)/-1000
226 | refmoho=np.copy(refmoho)/-1000
227 | moho_top=moho.copy()
228 | moho_bottom=moho.copy()
229 | moho_shift_const=np.copy(moho) + 1 # shift of the Moho depth, essential for second tesseroid model
230 | moho_top[moho_top > refmoho] = refmoho # upper layer
231 | moho_bottom[moho_bottom < refmoho] = refmoho # lower layer
232 | moho_bottom_shift = np.copy(moho_shift_const) # shifted layer
233 | moho_top_shift = np.copy(moho) #initial Moho
234 |
235 | return moho_top,moho_bottom,moho_top_shift,moho_bottom_shift
236 |
237 | def construct_layers_of_model(data_layer,reference):
238 | """constructs layers which are required for the inversion
239 |
240 | Input:
241 | data_layer - Vector of initial Moho depth
242 | reference - Reference layer, where data_layer is discretized (Float)
243 |
244 | Output:
245 | layer_top,layer_bottom - Top and bottom layer of discretized model"""
246 |
247 | data_layer=np.copy(data_layer)/1000
248 | reference=reference/1000
249 | layer_top=data_layer.copy()
250 | layer_bottom=data_layer.copy()
251 | layer_top[layer_top < reference] = reference # upper layer
252 | layer_bottom[layer_bottom > reference] = reference # lower layer
253 |
254 |
255 | return layer_top,layer_bottom
256 |
257 | def Doperator(nfs,sul,suw):
258 | # composes the Dmatrix 'dmat' for roughness determination
259 | # nfs: (2x1) number of patches
260 | # sul: (1) patch length
261 | # suw: (1) patch width
262 | #
263 | k=0;
264 | # dmat is the pre-operator matrix
265 | # defines from location of patches the neighboring patches
266 | dmat=np.ones((nfs[0]*nfs[1],4))
267 | dmat[0:nfs[0],0]=0 # I 1/suw
268 | dmat[-2-nfs[0]+1:-1,1]=0 # II 1/suw
269 | dmat[-1,1]=0
270 | dmat[:len(dmat):nfs[0],2]=0 # III 1/sul
271 | dmat[nfs[0]-1:len(dmat)+2:nfs[0],3]=0 # IV 1/sul
272 |
273 | DD=np.zeros((nfs[0]*nfs[1],nfs[0]*nfs[1])) # square
274 |
275 | for i in range(0,nfs[0]*nfs[1]):
276 |
277 | flags=dmat[i,:];
278 |
279 | # diagonal
280 | DD[i,i]=(-1)*np.dot(flags,np.array([1/suw**2, 1/suw**2, 1/sul**2, 1/sul**2]).T);
281 |
282 | # neighboring patches if any
283 | if flags[0]==1:
284 | DD[i,i-nfs[k]]=1/suw**2
285 | if flags[1]==1:
286 | DD[i,i+nfs[k]]=1/suw**2
287 | if flags[2]==1:
288 | DD[i,i-1]=1/sul**2
289 | if flags[3]==1:
290 | DD[i,i+1]=1/sul**2
291 |
292 | return DD
293 |
294 | def masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,**kwargs):
295 | """Calculate gravity field from a collection of point masses
296 |
297 | lon, lat, depths, mass have arbitrary but identical shape
298 | lons, lats and heights are vectors
299 |
300 | Units
301 | ---
302 | depths are POSITIVE DOWN in km
303 | heights is POSITIVE UP in m
304 | mass is in kg
305 | returns gravity in SI units
306 |
307 | kwargs
308 | ---
309 | calc_mode can be grad, grav or potential
310 |
311 | Returns
312 | ---
313 | The sensitivity matrix -> effect of each mass on all of the stations
314 | """
315 |
316 | G=6.67428e-11
317 | lon = lon[...,None]
318 | lat = lat[...,None]
319 | depths =depths[...,None]
320 | mass = mass[...,None]
321 | dLon = lon - lons
322 | coslat1 = np.cos(lat/180.0*np.pi)
323 | cosPsi = (coslat1 * np.cos(lats/180.0*np.pi) * np.cos(dLon/180.0*np.pi) +
324 | np.sin(lat/180.0*np.pi) * np.sin(lats/180.0*np.pi))
325 | cosPsi[cosPsi>1] = 1
326 |
327 | KPhi = (np.cos(lats/180.0*np.pi) * np.sin(lat/180.0*np.pi) -
328 | np.sin(lats/180.0*np.pi) * coslat1 * np.cos(dLon/180.0*np.pi))
329 |
330 |
331 | rStat = (heights + 6371000.0)
332 | g = np.zeros((len(lons),len(lon)))
333 | rTess = (6371000.0 - 1000.0*depths)
334 | spherDist = np.sqrt(rTess**2 + rStat**2
335 | - 2 * rTess * rStat*cosPsi)
336 |
337 | dx = KPhi * rTess
338 | dy = rTess * coslat1 * np.sin(dLon/180.0*np.pi)
339 | dz = rTess * cosPsi - rStat
340 |
341 | T = np.zeros(spherDist.shape+(6,))
342 | T[...,0] = ((3.0*dz*dz/(spherDist**5)- 1.0/(spherDist**3))*mass*G)
343 | return T
344 |
345 | def memory_save_masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,point_mass_number,**kwargs):
346 | """Calculate gravity effect of a collection of point masses in chunks to save memory.
347 | max_size gives the maximum size in bytes used for the sensitivity matrix
348 | See docu for masspoint_calc_FTG_2
349 | """
350 | N = lon.size
351 | M = lons.size
352 | calc_mode = kwargs.get("calc_mode","grad")
353 | max_size = kwargs.get("max_size",4000000000) # in bytes
354 | verbose = kwargs.get("verbose",False)
355 |
356 | T = np.zeros(lons.shape+(1,))
357 |
358 | partitions = np.ceil(8 * N * M / max_size).astype(int)
359 | if verbose:
360 | print('Number of partitions ',partitions)
361 |
362 | ixs = np.array_split(np.arange(M,dtype=int),partitions)
363 | for ix in ixs:
364 | design_matrix = masspoint_calc_FTG_2(lon,lat,depths,mass,lons[ix],lats[ix],heights[ix],**kwargs)
365 | J=sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats)
366 |
367 | if verbose:
368 | print('Parition done')
369 | return J
370 |
371 | def sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats):
372 | J=np.zeros((len(lons),len(lons)))
373 | for i in range(point_mass_number):
374 | for j in range(point_mass_number):
375 | for k in range(point_mass_number):
376 | J_calc=np.copy(design_matrix)*-1
377 | J_calc=J_calc[i][j][k][:][:][:]
378 | J_calc=J_calc[:, :, 0]/10**-9
379 | J=J+J_calc
380 | return J
381 |
382 | def tesses_to_pointmass(lon,lat,dx,dy,tops,bottoms,dens,hsplit,vsplit):
383 | """Convert several tesseroids into a set of point masses
384 | """
385 |
386 | depths = np.zeros((vsplit,hsplit,hsplit)+lon.shape)
387 | lon0 = np.zeros(depths.shape)
388 | lat0 = np.zeros(depths.shape)
389 | masses = np.zeros(depths.shape)
390 | dlon = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dx
391 | dlat = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dy
392 | for k in range(vsplit):
393 | print('Calculation point mass No',k)
394 | if k==0:
395 | top = tops
396 | else:
397 | top = (bottoms-tops)/(1.0*vsplit)*k + tops
398 | if k==vsplit-1:
399 | bot = bottoms
400 | else:
401 | bot = (bottoms-tops)/(1.0*vsplit)*(k+1) + tops
402 | r_top = 6371-top
403 | r_bot = 6371-bot
404 | r_term = (r_top**3-r_bot**3)/3.0
405 |
406 | ind=0
407 | for i in range(hsplit):
408 | for j in range(hsplit):
409 | lon0[k,i,j] = lon + dlon[j]
410 | lat0[k,i,j] = lat + dlat[i]
411 | depths[k,i,j] = 0.5 * (top+bot)
412 | surface_Area = -dx*(np.pi/(180.0*hsplit)) *np.cos(
413 | lat0[k,i,j]/180.0*np.pi) * 2 * np.sin(dy/(360.0*hsplit)*np.pi)
414 | masses[k,i,j] = surface_Area*dens*r_term*1e9
415 | ind=ind+1
416 | return lon0,lat0,depths,masses
--------------------------------------------------------------------------------
/code_AFR/topo_corr.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | from grad_inv_functions_AFR import *
3 |
4 |
5 | def create_Jacobian_topo_corr(lon,lat,top_layer,bottom_layer, heights, density, point_mass_number):
6 | """Calculates the Jacobian Matrix of the inversion
7 | The shape of the Matrix is n Stations (row) and m Tesseroids (column).
8 | The function get_inversion_design_matrix calculates the gravitational effect of each tesseroid for each station.
9 |
10 | Input:
11 | lon, lat - Vectors of Longitude and Latitude for all stations
12 | top_layer, bottom_layer - Vectors of top and bottom layer of tesseroid model
13 | heights - Vector of heights of stations
14 | density - Vector of density contrast of the tesseroid model
15 | point_mass_number - Number of point masses the tesseroids are converted (Float)
16 |
17 | All vectors have the length of n stations!
18 |
19 | Output:
20 | J - Jacobian or Design matrix"""
21 |
22 | # resolution of grid (should be 1 degree)
23 | dx=(np.amax(lon)-np.amin(lon))/(np.sqrt(len(lon))-1)
24 | dy=(np.amax(lat)-np.amin(lat))/(np.sqrt(len(lat))-1)
25 |
26 | print("Calculate Jacobian")
27 |
28 | # Convert the tesseroids to point masses
29 | lon0,lat0,depths,masses=tesses_to_pointmass(lon,lat,dx,dy,
30 | top_layer,bottom_layer,density,hsplit=point_mass_number,vsplit=point_mass_number)
31 |
32 | #Calculate gravitational effect of point masses for each stations-point mass combination and store them in a matrix
33 | J=memory_save_masspoint_calc_FTG_2(lon0,lat0,depths,masses,lon,lat,heights,point_mass_number)
34 | return J
35 |
36 |
37 | def topo_corr(lon,lat,bed,ice,heights,point_mass_number):
38 |
39 | """Calculates the gravitational effect of topography, discretized into a tesseroid model, which is transformed into point masses
40 |
41 | Input:
42 | bed, ice - 2D arrays of ice and bedrock topography (Longitude, Latitude, Value)
43 | heights_km - Height, where gravitational effect is calculated (Float)
44 | point_mass_number - Number of point masses the tesseroids are converted (Float)
45 |
46 | Output:
47 | bouguer - Vector of gravitational effect of topography"""
48 |
49 | #Define densities for topo corr
50 | dens_rock=2670
51 | dens_water=1030
52 | dens_ice=917
53 | reference_topo=0.0
54 |
55 | (bed_top,bed_bottom)=construct_layers_of_model(bed[:,2],reference_topo)
56 | (ice_above_top,ice_above_bottom)=construct_layers_of_model(ice[:,2],reference_topo)
57 | (ice_below_top,ice_below_bottom)=construct_layers_of_model(bed[:,2]-ice_above_bottom,reference_topo)
58 | diff=ice_above_top-bed_top
59 | bed[np.where(diff <0),2]=ice[np.where(diff <0),2]
60 | #ice_below_top[np.where(diff <0)]=ice_below_bottom[np.where(diff <0)]
61 | ice_above_bottom=np.copy(bed_top)
62 | ice_above_bottom[ice_above_bottom<0]=0.0
63 | count=-1
64 | for i in range(0,len(ice)):
65 |
66 | if bed[i,2]<0 and ice[i,2]<0 and ice[i,2]!=bed[i,2] and np.abs(bed[i,2]-ice[i,2])<10:
67 | bed[i,2]=ice[i,2]
68 | # rock
69 | if ice[i,2]>0 and bed[i,2]>0 and ice[i,2]==bed[i,2]:
70 | ice_above_top[i]=0.0
71 | ice_above_bottom[i]=0.0
72 | ice_below_top[i]=0.0
73 | ice_below_bottom[i]=0.0
74 | count=count+1
75 | #water
76 | if ice[i,2]<0 and bed[i,2]<0 and ice[i,2]==bed[i,2]:
77 | ice_above_top[i]=0.0
78 | ice_above_bottom[i]=0.0
79 | ice_below_top[i]=0.0
80 | ice_below_bottom[i]=0.0
81 | count=count+1
82 | # ice above
83 | if ice[i,2]>0 and bed[i,2]>0 and ice[i,2]>bed[i,2]:
84 | ice_below_top[i]=0.0
85 | ice_below_bottom[i]=0.0
86 | count=count+1
87 | # ice below
88 | if ice[i,2]>0 and bed[i,2]<0 and ice[i,2]>bed[i,2]:
89 | bed_top[i]=0.0
90 | bed_bottom[i]=0.0
91 | count=count+1
92 |
93 | density_topo=np.ones(bed_top.shape[0])*dens_rock
94 | density_topo[np.where(bed_top == 0)]=(dens_rock-dens_water)*-1
95 | density_ice_above=np.ones(ice_above_top.shape[0])*dens_ice
96 | density_ice_below=np.ones(ice_below_top.shape[0])*(dens_rock-dens_ice)*-1
97 |
98 | print("Calculate topographic effect")
99 | J=create_Jacobian_topo_corr(lon,lat,bed_top*-1,bed_bottom*-1,heights, density_topo, point_mass_number)
100 | bouguer=np.sum(J.T, axis=1)
101 | print(np.amin(bouguer),np.amax(bouguer))
102 | if np.any(ice_above_top) or np.any(ice_above_bottom):
103 | print("Calculate Ice Effect -- Above sea level")
104 | J=create_Jacobian_topo_corr(lon,lat,ice_above_top*-1,ice_above_bottom*-1,heights, density_ice_above, point_mass_number)
105 | bouguer_ice_above=np.sum(J.T, axis=1)
106 | print(np.amin(bouguer_ice_above),np.amax(bouguer_ice_above))
107 | bouguer=np.copy(bouguer)+bouguer_ice_above
108 |
109 | if np.any(ice_below_top) or np.any(ice_below_bottom):
110 | print("Calculate Ice Effect -- Below sea level")
111 | J=create_Jacobian_topo_corr(lon,lat,ice_below_top*-1,ice_below_bottom*-1,heights, density_ice_below, point_mass_number)
112 | bouguer_ice_below=np.sum(J.T, axis=1)
113 | print(np.amin(bouguer_ice_below),np.amax(bouguer_ice_below))
114 | bouguer=np.copy(bouguer)-bouguer_ice_below
115 |
116 | return bouguer
--------------------------------------------------------------------------------
/code_SAM/Gradient_Inversion_SAM_synthetic.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "Inversion of the Moho depth using gravity gradient data\n",
8 | "----------------------------------------\n",
9 | "\n",
10 | "This Jupyter Notebook allows the inversion of gravity gradient data to estimate Moho depth and density contrast at the Moho depth. The script is designed to define a laterally variable density contrast. The extension of different density layers is based on seismological regionalization, which is a clustering product of the seismic tomographic model SL2013sv (Schaeffer & Lebedev, 2015). The regionalization defines different tectonic units in terms of their age. \n",
11 | "\n",
12 | "The script is designed to study the Moho depth with intially calculated synthetic data for the Amazonian Craton. A more flexible version, which allows inversion of the Moho depth at a user-defined study area can be found on Github: https://github.com/peterH105/Gradient_Inversion\n",
13 | "\n",
14 | "The most important computation steps of the following script are:\n",
15 | "1. Load the initial data files\n",
16 | "2. Calculate reference Jacobian Matrix of inversion\n",
17 | "3. Loop over different density contrasts and obtain final model\n",
18 | "4. Plot the results\n",
19 | "\n",
20 | "Step 2 calculates the gravitational effect of a discretized Moho depth, converted from tesseroids to point masses, based on a code written by Wolfgang Szwillus. We note this procedure has been changed from a previous version, which used executable tesseroid files of Leonardo Uieda (http://tesseroids.leouieda.com)\n",
21 | "\n",
22 | "For official use, please cite the paper: Haas, P., Ebbing J., Szwillus W. - Sensitivity analysis of gravity gradient inversion of the Moho depth – A case example for the Amazonian Craton, Geophysical Journal International, 2020, doi: 10.1093/gji/ggaa122\n",
23 | "\n",
24 | "You need Python 3 to run this notebook. This notebok has been tested on a Windows machine.\n",
25 | "\n",
26 | "\n",
27 | "\n"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "metadata": {},
33 | "source": [
34 | "#### Load the Python packages that are required for the inversion"
35 | ]
36 | },
37 | {
38 | "cell_type": "code",
39 | "execution_count": 1,
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%matplotlib inline\n",
44 | "\n",
45 | "import numpy as np\n",
46 | "from grad_inv_functions_synthetic import *\n",
47 | "import matplotlib.pyplot as plt\n",
48 | "import matplotlib.font_manager as font_manager\n",
49 | "from matplotlib import cm,path\n",
50 | "from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,\n",
51 | " AutoMinorLocator)\n",
52 | "import time\n",
53 | "import progressbar\n",
54 | "import os\n",
55 | "os.environ['PROJ_LIB'] = r'C:\\Users\\Peter\\Anaconda3\\pkgs\\proj4-5.2.0-h6538335_1006\\Library\\share'\n",
56 | "from mpl_toolkits.basemap import Basemap"
57 | ]
58 | },
59 | {
60 | "cell_type": "markdown",
61 | "metadata": {},
62 | "source": [
63 | "#### Set parameters for the inversion"
64 | ]
65 | },
66 | {
67 | "cell_type": "code",
68 | "execution_count": 2,
69 | "metadata": {},
70 | "outputs": [],
71 | "source": [
72 | "lon_min=-80 #Define coordinates of study area. \n",
73 | "lon_max=-30\n",
74 | "lat_min=-30\n",
75 | "lat_max=20\n",
76 | "\n",
77 | "dx=1.0 # define grid cell size (should be 1.0 degree)\n",
78 | "dy=1.0\n",
79 | "\n",
80 | "lateral_var=\"no\" # choose between \"yes\" and \"no\" to load initial gravity field from laterally constant or variable density contrast\n",
81 | "\n",
82 | "dens_min,dens_max,dens_inc=250.0,500.0,50\n",
83 | "reference_moho=30000.0 # select value for reference Moho depth \n",
84 | "\n",
85 | "k=np.arange(dens_min,dens_max+0.1,dens_inc) # select range and increment of density contrast\n",
86 | "beta=np.arange(1e-4,1.1e-4,1e-4) # select range and increment of smoothing parameter (should be constant)\n",
87 | "\n",
88 | "# Define number of point masses the tesseroids are converted to. Should not be higher than 2\n",
89 | "point_mass_number=1\n",
90 | "\n",
91 | "# Define some initial conditions\n",
92 | "dens_init=k[0]\n",
93 | "lon=np.arange(lon_min,lon_max+dx,dx)\n",
94 | "lat=np.arange(lat_min,lat_max+dy,dy)\n",
95 | "longr,latgr = np.meshgrid(lon,lat)\n",
96 | "\n",
97 | "# Prepare vectors and grids for tesseroid model\n",
98 | "lon=longr.flatten() \n",
99 | "lat=latgr.flatten()\n",
100 | "height_km=225 \n",
101 | "heights=np.ones(len(lon))*height_km*1000\n",
102 | "area = (lat.min(), lat.max(), lon.min(), lon.max())\n",
103 | "shape=np.array((abs(lat_max-lat_min)/dy+1,abs(lon_max-lon_min)/dx+1))\n",
104 | "shape=shape.astype(int)"
105 | ]
106 | },
107 | {
108 | "cell_type": "markdown",
109 | "metadata": {},
110 | "source": [
111 | "#### Load and prepare the data\n",
112 | "\n",
113 | "Seismic stations and tectonic units can be changed manually and are cut to the study area. The function \"Doperator\" calculates the smoothing matrix for the inversion using 2nd-order Tikhonov regularization.\n",
114 | "The tectonic units are used to create density combinations and have to be organized as clusters. \n"
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": 3,
120 | "metadata": {},
121 | "outputs": [],
122 | "source": [
123 | "# Load and prepare seismic data\n",
124 | "seismic_stations=np.loadtxt(\"Seismic_Moho_USGS_global.txt\")\n",
125 | "seismic_stations=cut_data_to_study_area(seismic_stations,area)\n",
126 | "seismic_stations=seismic_stations[np.lexsort((seismic_stations[:,0],seismic_stations[:,1]))]\n",
127 | "\n",
128 | "#Prepare Regularization\n",
129 | "dmatrix_init=Doperator(shape,dx,dy)\n",
130 | "smooth_matrix=np.eye(lon.size)*beta\n",
131 | "dmatrix=dmatrix_init*beta\n",
132 | "\n",
133 | "# Load and prepare seismological regionalization clustering analysis\n",
134 | "tec_units=np.loadtxt('SL2013sv_Cluster_1d_interp.xyz')\n",
135 | "tec_units=cut_data_to_study_area(tec_units,area)\n",
136 | "tec_units=tec_units[np.lexsort((tec_units[:,0],tec_units[:,1]))]\n",
137 | "\n",
138 | "# Counts the number of tectonic units of the regionalization (maximum 6 domains)\n",
139 | "number_of_units=len(np.unique(tec_units[:,2]))\n",
140 | "value_of_units=np.unique(tec_units[:,2])\n",
141 | "\n",
142 | "# Creates the density matrix of all combinations of domains and density contrasts\n",
143 | "dens_mat=create_density_combinations(k,number_of_units)\n",
144 | "\n",
145 | "# This line can be activated to define only constant density contrasts. \n",
146 | "# Saves a lot of computational time, as only k combinations of density contrasts remain.\n",
147 | "#dens_mat=(np.ones((len(k),number_of_units))*k).T \n",
148 | "\n",
149 | "# This line can be activated if only one SINGLE density combination is tested. The values have to be defined manually\n",
150 | "#dens_mat=np.ones((1,6))*np.array([250,300,350,400,450,500])\n",
151 | "\n",
152 | "rms_matrix=np.zeros((k.size**number_of_units,number_of_units+5))"
153 | ]
154 | },
155 | {
156 | "cell_type": "markdown",
157 | "metadata": {},
158 | "source": [
159 | "#### Inversion with single reference Moho depth and constant density contrast\n",
160 | "\n",
161 | "The inversion of the gravity data is now performed once to obtain the reference Jacobian Matrix. Optionally, the inverted Moho depth as well as the residual field can be stored. "
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 4,
167 | "metadata": {},
168 | "outputs": [
169 | {
170 | "name": "stderr",
171 | "output_type": "stream",
172 | "text": [
173 | "\r",
174 | "[ ] N/A%"
175 | ]
176 | },
177 | {
178 | "name": "stdout",
179 | "output_type": "stream",
180 | "text": [
181 | "Calculate Jacobian\n",
182 | "Calculation point mass No 1\n"
183 | ]
184 | }
185 | ],
186 | "source": [
187 | "# The \"save-fields\" function is intended to save the fields of a certain density contrast. \n",
188 | "# Should only be activated of a single density combination has been defined before.\n",
189 | "\n",
190 | "save_fields=\"no\" #select \"yes\" to save the computed fields as gridded data-files\n",
191 | "\n",
192 | "# Load initial Moho isostatic Moho depth.\n",
193 | "# If the starting models equals the reference layer, \n",
194 | "# the calculation of the first Jacobian can be skipped, as it contains only zero values!\n",
195 | "\n",
196 | "moho=np.loadtxt(\"IsoMoho_Airy_initial_1degree.txt\")\n",
197 | "moho=moho[np.lexsort((moho[:,0],moho[:,1]))]\n",
198 | "moho_input=np.copy(moho[:,2]*-1000)\n",
199 | "moho_start=np.copy(moho[:,2]*-1000)\n",
200 | "\n",
201 | "#interpolates initial Moho depth on seismic stations\n",
202 | "area = (lat.min(), lat.max(), lon.min(), lon.max())\n",
203 | "moho_resid_points,interp_arr=interp_regular_grid_on_irregular_database(area,dx,moho[:,2]*-1000,seismic_stations)\n",
204 | "seismic_stations[:,2]=np.copy(interp_arr)\n",
205 | "\n",
206 | "# Create flat starting model\n",
207 | "moho=moho[:,2]*0+reference_moho\n",
208 | "\n",
209 | "# Prefix for file name\n",
210 | "prefix = \"SAM_synthetic\" \n",
211 | "\n",
212 | "# Prepare layers of tesseroid model and define density contrast\n",
213 | "(moho_top,moho_bottom)=construct_layers_of_model(moho,reference_moho)\n",
214 | "moho_shift_const=np.copy(moho)/1000 + 1 # shift of the Moho depth, essential for second tesseroid model\n",
215 | "moho_bottom_shift = np.copy(moho_shift_const) # shifted layer\n",
216 | "moho_top_shift = np.copy(moho)/1000 \n",
217 | "\n",
218 | "# Load the gravitational data\n",
219 | "# IMPORTANT: To invert other components than gzz, the gravity data in the source code have to be \n",
220 | "# changed manually!\n",
221 | "data=load_grav_data(lateral_var,area)\n",
222 | "bouguer=data[:,2]\n",
223 | "\n",
224 | "# Define initial density contrast vector based on the first line of the density matrix\n",
225 | "density=np.ones(lon.shape[0])*dens_init\n",
226 | "for ii,jj in enumerate(value_of_units): # Transfer density combination to density contrasts of grid\n",
227 | " ind=np.where(tec_units[:,2]==jj)\n",
228 | " density[ind]=dens_mat[0,int(ii)-1]\n",
229 | "\n",
230 | "# Calculate Jacobian matrix\n",
231 | "J=np.zeros((len(lon),len(lon)))\n",
232 | "J_shift=create_Jacobian(lon,lat,moho_top_shift, moho_bottom_shift, heights, density, point_mass_number)\n",
233 | "\n",
234 | "# Invert the Moho depth and calculate residual fields \n",
235 | "# NOTE: To save the calculated fields and the Moho depth \"save_fields\" has to be activated!\n",
236 | "moho_final,bouguer_fit=invert_and_calculate(prefix,moho*-1,bouguer,J,J_shift,dmatrix,\n",
237 | " save_fields,shape)"
238 | ]
239 | },
240 | {
241 | "cell_type": "markdown",
242 | "metadata": {},
243 | "source": [
244 | "#### Set preconditions for lateral variable density contrast"
245 | ]
246 | },
247 | {
248 | "cell_type": "code",
249 | "execution_count": 5,
250 | "metadata": {},
251 | "outputs": [
252 | {
253 | "name": "stdout",
254 | "output_type": "stream",
255 | "text": [
256 | "Invert density contrasts\n",
257 | "Number of iterations: 6\n"
258 | ]
259 | }
260 | ],
261 | "source": [
262 | "# Reload the gravity data\n",
263 | "data=load_grav_data(lateral_var,area)\n",
264 | "bouguer=np.copy(data[:,2])\n",
265 | "\n",
266 | "# Define boundaries for calculation of RMS values\n",
267 | "inc=1.9\n",
268 | "bound=np.array(([lon_min+inc, lat_min+inc],[lon_min+inc, lat_max-inc],\n",
269 | " [lon_max-inc, lat_max-inc],[lon_max-inc, lat_min+inc]))\n",
270 | "bound=path.Path(bound)\n",
271 | "inside=bound.contains_points(data[:,0:2])*1\n",
272 | "data[:,2]=data[:,2]*inside\n",
273 | "save_fields=\"no\"\n",
274 | "\n",
275 | "# Define multiplicator of density contrasts for Jacobian Matrix\n",
276 | "mult=np.copy(density)\n",
277 | "mult=mult/dens_init\n",
278 | "\n",
279 | "# Create progress bar\n",
280 | "bar = progressbar.ProgressBar(maxval=len(dens_mat[:,0]), \\\n",
281 | "widgets=[progressbar.Bar('=', '[', ']'), ' ', progressbar.Percentage()])\n",
282 | "print(\"Invert density contrasts\")\n",
283 | "print(\"Number of iterations:\",len(dens_mat[:,0]))"
284 | ]
285 | },
286 | {
287 | "cell_type": "markdown",
288 | "metadata": {},
289 | "source": [
290 | "#### Inversion with a laterally variable density contrast"
291 | ]
292 | },
293 | {
294 | "cell_type": "code",
295 | "execution_count": 6,
296 | "metadata": {},
297 | "outputs": [
298 | {
299 | "name": "stderr",
300 | "output_type": "stream",
301 | "text": [
302 | "[======================== ] 33%"
303 | ]
304 | },
305 | {
306 | "name": "stdout",
307 | "output_type": "stream",
308 | "text": [
309 | "-64049.00000000001 1980.0 -75.78210586049065 31.4424924439192 -18.242324697093867 15.15895542929622\n",
310 | "[ 2.33436144 8.99703074 7.53855378 0. 0.\n",
311 | " 250. 250. 250. 250. 250.\n",
312 | " 250. ]\n"
313 | ]
314 | },
315 | {
316 | "name": "stderr",
317 | "output_type": "stream",
318 | "text": [
319 | "\r",
320 | "[==================================== ] 50%"
321 | ]
322 | },
323 | {
324 | "name": "stdout",
325 | "output_type": "stream",
326 | "text": [
327 | "-64049.00000000001 1980.0 -68.14633356933956 21.21003010584495 -11.672809892061565 8.314342764883921\n",
328 | "[ 2.33436144 5.05465373 4.31507564 0. 0.\n",
329 | " 300. 300. 300. 300. 300.\n",
330 | " 300. ]\n"
331 | ]
332 | },
333 | {
334 | "name": "stderr",
335 | "output_type": "stream",
336 | "text": [
337 | "\r",
338 | "[================================================ ] 66%"
339 | ]
340 | },
341 | {
342 | "name": "stdout",
343 | "output_type": "stream",
344 | "text": [
345 | "-64049.00000000001 1980.0 -62.714545838898594 13.894655848882522 -7.080310622894939 4.627051487767028\n",
346 | "[ 2.33436144 2.38662427 2.09820757 0. 0.\n",
347 | " 350. 350. 350. 350. 350.\n",
348 | " 350. ]\n"
349 | ]
350 | },
351 | {
352 | "name": "stderr",
353 | "output_type": "stream",
354 | "text": [
355 | "\r",
356 | "[============================================================ ] 83%"
357 | ]
358 | },
359 | {
360 | "name": "stdout",
361 | "output_type": "stream",
362 | "text": [
363 | "-64049.00000000001 1980.0 -58.629467294896216 8.405859368893012 -6.387614155266739 3.4111982919763757\n",
364 | "[ 2.33436144 1.26588406 0.94798806 0. 0.\n",
365 | " 400. 400. 400. 400. 400.\n",
366 | " 400. ]\n"
367 | ]
368 | },
369 | {
370 | "name": "stderr",
371 | "output_type": "stream",
372 | "text": [
373 | "\r",
374 | "[========================================================================] 100%"
375 | ]
376 | },
377 | {
378 | "name": "stdout",
379 | "output_type": "stream",
380 | "text": [
381 | "-64049.00000000001 1980.0 -55.44681728594864 4.136114922535448 -9.43589143604446 2.6572976252987717\n",
382 | "[ 2.33436144 2.19609213 1.55571812 0. 0.\n",
383 | " 450. 450. 450. 450. 450.\n",
384 | " 450. ]\n"
385 | ]
386 | },
387 | {
388 | "ename": "KeyboardInterrupt",
389 | "evalue": "",
390 | "output_type": "error",
391 | "traceback": [
392 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
393 | "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
394 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[1;31m# Invert the Moho depth\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 17\u001b[0m moho_final,bouguer_fit=invert_and_calculate(prefix,moho*-1,bouguer,J_new,J_shift_new,dmatrix,\n\u001b[1;32m---> 18\u001b[1;33m save_fields,shape)\n\u001b[0m\u001b[0;32m 19\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[0mmoho_int\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmoho_final\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;36m1000\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
395 | "\u001b[1;32m~\\Documents\\PhD\\Paper_Gradient_Inversion_SAM\\Revision\\code_new\\grad_inv_functions_synthetic.py\u001b[0m in \u001b[0;36minvert_and_calculate\u001b[1;34m(prefix, moho, bouguer, J, J_shift, dmatrix, save_fields, shape)\u001b[0m\n\u001b[0;32m 66\u001b[0m \u001b[1;31m# Solve linear equation system and calculate Moho depth and data fit\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[0mrhs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbig_delta_G\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbig_d\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdmatrix\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdmatrix\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmoho\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m1000\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 68\u001b[1;33m \u001b[0mlhs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbig_delta_G\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbig_delta_G\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mdmatrix\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdmatrix\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 69\u001b[0m \u001b[0mmoho_shift\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlinalg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msolve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlhs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mrhs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 70\u001b[0m \u001b[0mpredicted\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbig_delta_G\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmoho_shift\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
396 | "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
397 | ]
398 | }
399 | ],
400 | "source": [
401 | "bar.start()\n",
402 | "for i in range(0,len(dens_mat[:,0])): # Loop over all possible combinations of density contrasts\n",
403 | " bar.update(i+1)\n",
404 | "\n",
405 | " for ii,jj in enumerate(value_of_units): # Transfer density combination to density contrasts of grid\n",
406 | " ind=np.where(tec_units[:,2]==jj)\n",
407 | " density[ind]=dens_mat[i,int(ii)]\n",
408 | " \n",
409 | " # Update the density contrasts for Jacobian Matrix\n",
410 | " density=np.abs(density)\n",
411 | " density=density*mult\n",
412 | "\n",
413 | " # Weight the Jacobian Matrix\n",
414 | " J_new,J_shift_new=weight_Jacobian(J,J_shift,density,dens_init) \n",
415 | " \n",
416 | " # Invert the Moho depth\n",
417 | " moho_final,bouguer_fit=invert_and_calculate(prefix,moho*-1,bouguer,J_new,J_shift_new,dmatrix,\n",
418 | " save_fields,shape)\n",
419 | "\n",
420 | " moho_int=moho_final*1000\n",
421 | "\n",
422 | " # interpolate inverted Moho depth onto seismic stations\n",
423 | " moho_resid_points,interp_arr=interp_regular_grid_on_irregular_database(area,dx,moho_int,seismic_stations)\n",
424 | "\n",
425 | " # Compute residual Moho depth (grid)\n",
426 | " moho_resid_grid=moho_input/1000-moho_final # residual Moho depth\n",
427 | " \n",
428 | " # Create RMS values of residual field and residual Moho depths and store them in a matrix\n",
429 | " rms_matrix=create_rms_matrix(rms_matrix,data,moho_resid_points,moho_resid_grid,i,bouguer_fit)\n",
430 | " rms_matrix[i,5:5+number_of_units]=dens_mat[i,0:number_of_units]\n",
431 | " \n",
432 | " # Check fit to seismic stations and save the corresponding inverted Moho depth and density contrasts\n",
433 | " if i==0: \n",
434 | " moho_save=np.array((lon,lat,moho_final*-1)).T\n",
435 | " density_save=np.array((lon,lat,density)).T\n",
436 | " np.savetxt(prefix+\"_inverted_Moho_best_fit.txt\",moho_save,delimiter=' ',fmt='%1.2f')\n",
437 | " np.savetxt(prefix+\"_inverted_densities_best_fit.txt\",density_save,delimiter=' ',fmt='%1.1f')\n",
438 | " \n",
439 | " if i>=1 and rms_matrix[i,2]area[3])]
147 | data=data[~(data[:,1]area[1])]
149 | return data
150 |
151 | def create_density_combinations(k,number_of_units):
152 | """Creates and sorts all density combinations for k density contrasts of n number of units
153 | The combinations are stored in a matrix
154 | total number of combinations is n^k
155 |
156 | Input:
157 | k - range of density contrasts
158 | number_of_units - Number of tectonic units
159 |
160 | Output:
161 | dens_mat - matrix containing all density combinations (row) of different tectonic units (column)"""
162 |
163 | dens_mat=np.transpose(np.tile(k,(number_of_units,len(k)**(number_of_units-1))))
164 |
165 | for i in range(1,number_of_units):
166 | dens_mat[:,number_of_units-1-i]=np.transpose(np.reshape(dens_mat[:,number_of_units-1-i],(len(k)**i,len(k)**(number_of_units-i)))).flatten()
167 | return dens_mat
168 |
169 | def interp_regular_grid_on_irregular_database(area,dx,moho,seismic_stations):
170 |
171 | """Interpolate regular grid values on irregular distributed points
172 | points have to be inside the boundaries of the grid
173 |
174 | Input:
175 | area - boundaries of the study area
176 | dx - step size of the grid
177 | moho - 1-column layer of Moho depth
178 | seismic stations - 3-column layer of seismic stations (Lon,Lat,Station)
179 |
180 | Output:
181 | interp_arr - Interpolated values of gridded data
182 | moho_diff - Difference between point estimates and interpolated data"""
183 |
184 | lon=np.arange(area[2],area[3]+dx,dx)
185 | lat=np.arange(area[0],area[1]+dx,dx)
186 |
187 | moho_for_interp=moho.reshape((len(lat),len(lon)))
188 | moho_for_interp=np.transpose(moho_for_interp)
189 |
190 | interp_func=RegularGridInterpolator((lon,lat),moho_for_interp)
191 | interp_arr=interp_func(seismic_stations[:,0:2],method="linear")
192 | moho_diff=(seismic_stations[:,2]-interp_arr)/1000
193 | return moho_diff,interp_arr
194 |
195 |
196 | def create_rms_matrix(rms_matrix,data,moho_resid_points,moho_resid_grid,i,bouguer_fit):
197 |
198 | # Creates a matrix of RMS-values for residual Moho depth and residual gravity field
199 |
200 | bouguer_fit=bouguer_fit[~(data[:,2]==0)] # remove values outside of coastline
201 | bouguer_fit_rms=np.sqrt(np.sum(bouguer_fit**2)/(bouguer_fit.shape)) # compute RMS
202 |
203 | moho_resid_points_rms=np.sqrt(np.sum(moho_resid_points**2)/(moho_resid_points.shape)) # Compute RMS of points only
204 |
205 | moho_resid_grid=moho_resid_grid[~(data[:,2]==0)] # remove values outside of coastline
206 | moho_resid_grid_rms=np.sqrt(np.sum(moho_resid_grid**2)/(moho_resid_grid.shape)) # compute RMS of grid
207 |
208 | rms_matrix[i,0]=bouguer_fit_rms # construct columns of matrix, containing RMS values of residual field, residual Moho depth and residual binned only Moho depth
209 | rms_matrix[i,1]=moho_resid_points_rms
210 | rms_matrix[i,2]=moho_resid_grid_rms
211 | return rms_matrix
212 |
213 | def construct_layers_of_model(data_layer,reference):
214 | """constructs layers which are required for the inversion
215 |
216 | Input:
217 | data_layer - Vector of initial Moho depth
218 | reference - Reference layer, where data_layer is discretized (Float)
219 |
220 | Output:
221 | layer_top,layer_bottom - Top and bottom layer of discretized model"""
222 |
223 | data_layer=np.copy(data_layer)/1000
224 | reference=reference/1000
225 | layer_top=data_layer.copy()
226 | layer_bottom=data_layer.copy()
227 | layer_top[layer_top < reference] = reference # upper layer
228 | layer_bottom[layer_bottom > reference] = reference # lower layer
229 |
230 |
231 | return layer_top,layer_bottom
232 |
233 | def Doperator(nfs,sul,suw):
234 | """composes the Dmatrix 'dmat' for roughness determination
235 | nfs: (2x1) number of patches
236 | sul: (1) patch length
237 | suw: (1) patch width
238 |
239 | Output:
240 | DD - Smoothing matrix following 2nd order Tikhonov regularization"""
241 |
242 | k=0;
243 | # dmat is the pre-operator matrix
244 | # defines from location of patches the neighboring patches
245 | dmat=np.ones((nfs[0]*nfs[1],4))
246 | dmat[0:nfs[0],0]=0 # I 1/suw
247 | dmat[-2-nfs[0]+1:-1,1]=0 # II 1/suw
248 | dmat[-1,1]=0
249 | dmat[:len(dmat):nfs[0],2]=0 # III 1/sul
250 | dmat[nfs[0]-1:len(dmat)+2:nfs[0],3]=0 # IV 1/sul
251 |
252 | DD=np.zeros((nfs[0]*nfs[1],nfs[0]*nfs[1])) # square
253 |
254 | for i in range(0,nfs[0]*nfs[1]):
255 |
256 | flags=dmat[i,:];
257 |
258 | # diagonal
259 | DD[i,i]=(-1)*np.dot(flags,np.array([1/suw**2, 1/suw**2, 1/sul**2, 1/sul**2]).T);
260 |
261 | # neighboring patches if any
262 | if flags[0]==1:
263 | DD[i,i-nfs[k]]=1/suw**2
264 | if flags[1]==1:
265 | DD[i,i+nfs[k]]=1/suw**2
266 | if flags[2]==1:
267 | DD[i,i-1]=1/sul**2
268 | if flags[3]==1:
269 | DD[i,i+1]=1/sul**2
270 |
271 | return DD
272 |
273 |
274 | # The following functions are included to calculate the construct point masses from tesseroids and to calculate their gravitational effect.
275 | # In the original publication of Haas et al. the gravitational effect of tesseroids has been calculated with the executable tesseroid files.
276 | # However, the .exe do not allow calculation on the browser for safety reasons. Therefore, the forward calculation has been changed to point masses.
277 | # The accuracy is very similar to tesseroids.
278 | #
279 | # The following functions, as well as the annotations, are written by Wolfgang Szwillus and have to be treated confidentially.
280 |
281 |
282 | def masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,**kwargs):
283 | """Calculate gravity field from a collection of point masses
284 |
285 | lon, lat, depths, mass have arbitrary but identical shape
286 | lons, lats and heights are vectors
287 |
288 | Units
289 | ---
290 | depths are POSITIVE DOWN in km
291 | heights is POSITIVE UP in m
292 | mass is in kg
293 | returns gravity in SI units
294 |
295 | kwargs
296 | ---
297 | calc_mode can be grad, grav or potential
298 |
299 | Returns
300 | ---
301 | The sensitivity matrix -> effect of each mass on all of the stations
302 | """
303 |
304 | G=6.67428e-11
305 | lon = lon[...,None]
306 | lat = lat[...,None]
307 | depths =depths[...,None]
308 | mass = mass[...,None]
309 | dLon = lon - lons
310 | coslat1 = np.cos(lat/180.0*np.pi)
311 | cosPsi = (coslat1 * np.cos(lats/180.0*np.pi) * np.cos(dLon/180.0*np.pi) +
312 | np.sin(lat/180.0*np.pi) * np.sin(lats/180.0*np.pi))
313 | cosPsi[cosPsi>1] = 1
314 |
315 | KPhi = (np.cos(lats/180.0*np.pi) * np.sin(lat/180.0*np.pi) -
316 | np.sin(lats/180.0*np.pi) * coslat1 * np.cos(dLon/180.0*np.pi))
317 |
318 |
319 | rStat = (heights + 6371000.0)
320 | g = np.zeros((len(lons),len(lon)))
321 | rTess = (6371000.0 - 1000.0*depths)
322 | spherDist = np.sqrt(rTess**2 + rStat**2
323 | - 2 * rTess * rStat*cosPsi)
324 |
325 | dx = KPhi * rTess
326 | dy = rTess * coslat1 * np.sin(dLon/180.0*np.pi)
327 | dz = rTess * cosPsi - rStat
328 |
329 | T = np.zeros(spherDist.shape+(6,))
330 | T[...,0] = ((3.0*dz*dz/(spherDist**5)- 1.0/(spherDist**3))*mass*G)
331 | return T
332 |
333 | def memory_save_masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,point_mass_number,**kwargs):
334 | """Calculate gravity effect of a collection of point masses in chunks to save memory.
335 | max_size gives the maximum size in bytes used for the sensitivity matrix
336 | See docu for masspoint_calc_FTG_2
337 | """
338 | N = lon.size
339 | M = lons.size
340 | calc_mode = kwargs.get("calc_mode","grad")
341 | max_size = kwargs.get("max_size",1000000000) # in bytes
342 | verbose = kwargs.get("verbose",False)
343 |
344 | T = np.zeros(lons.shape+(1,))
345 | partitions = np.ceil(8 * N * M / max_size).astype(int)
346 | if verbose:
347 | print('Number of partitions ',partitions)
348 |
349 | ixs = np.array_split(np.arange(M,dtype=int),partitions)
350 | for ix in ixs:
351 | design_matrix = masspoint_calc_FTG_2(lon,lat,depths,mass,lons[ix],lats[ix],heights[ix],**kwargs)
352 | J=sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats)
353 |
354 | if verbose:
355 | print('Parition done')
356 | return J
357 |
358 | def sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats):
359 | J=np.zeros((len(lons),len(lats)))
360 | for i in range(point_mass_number):
361 | for j in range(point_mass_number):
362 | for k in range(point_mass_number):
363 | J_calc=np.copy(design_matrix)*-1
364 | J_calc=J_calc[i][j][k][:][:][:]
365 | J_calc=J_calc[:, :, 0]/10**-9
366 | J=J+J_calc
367 | return J
368 |
369 | def tesses_to_pointmass(lon,lat,dx,dy,tops,bottoms,dens,hsplit,vsplit):
370 | """Convert several tesseroids into a set of point masses
371 | """
372 |
373 | depths = np.zeros((vsplit,hsplit,hsplit)+lon.shape)
374 | lon0 = np.zeros(depths.shape)
375 | lat0 = np.zeros(depths.shape)
376 | masses = np.zeros(depths.shape)
377 | dlon = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dx
378 | dlat = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dy
379 | for k in range(vsplit):
380 | print('Calculation point mass No',k+1)
381 | if k==0:
382 | top = tops
383 | else:
384 | top = (bottoms-tops)/(1.0*vsplit)*k + tops
385 | if k==vsplit-1:
386 | bot = bottoms
387 | else:
388 | bot = (bottoms-tops)/(1.0*vsplit)*(k+1) + tops
389 | r_top = 6371-top
390 | r_bot = 6371-bot
391 | r_term = (r_top**3-r_bot**3)/3.0
392 |
393 | ind=0
394 | for i in range(hsplit):
395 | for j in range(hsplit):
396 | lon0[k,i,j] = lon + dlon[j]
397 | lat0[k,i,j] = lat + dlat[i]
398 | depths[k,i,j] = 0.5 * (top+bot)
399 | surface_Area = -dx*(np.pi/(180.0*hsplit)) *np.cos(
400 | lat0[k,i,j]/180.0*np.pi) * 2 * np.sin(dy/(360.0*hsplit)*np.pi)
401 | masses[k,i,j] = surface_Area*dens*r_term*1e9
402 | ind=ind+1
403 | return lon0,lat0,depths,masses
--------------------------------------------------------------------------------
/code_SAM/grad_inv_functions_synthetic.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | from scipy.interpolate import interp1d,RegularGridInterpolator
3 | import subprocess
4 | import tempfile
5 | from matplotlib import path
6 | import progressbar
7 |
8 | def create_Jacobian(lon,lat,top_layer,bottom_layer, heights, density, point_mass_number):
9 | """Calculates the Jacobian Matrix of the inversion
10 | The shape of the Matrix is n Stations (row) and m Tesseroids (column).
11 | The function get_inversion_design_matrix calculates the gravitational effect of each tesseroid for each station.
12 |
13 | Input:
14 | lon, lat - Vectors of Longitude and Latitude for all stations
15 | top_layer, bottom_layer - Vectors of top and bottom layer of tesseroid model
16 | heights - Vector of heights of stations
17 | density - Vector of density contrast of the tesseroid model
18 | point_mass_number - Number of point masses the tesseroids are converted (Float)
19 |
20 | All vectors have the length of n stations!
21 |
22 | Output:
23 | J - Jacobian or Design matrix"""
24 |
25 | # resolution of grid (should be 1 degree)
26 | dx=(np.amax(lon)-np.amin(lon))/(np.sqrt(len(lon))-1)
27 | dy=(np.amax(lat)-np.amin(lat))/(np.sqrt(len(lat))-1)
28 |
29 | print("Calculate Jacobian")
30 |
31 | # Convert the tesseroids to point masses
32 | lon0,lat0,depths,masses=tesses_to_pointmass(lon,lat,dx,dy,
33 | top_layer,bottom_layer,density,hsplit=point_mass_number,vsplit=point_mass_number)
34 |
35 | #Calculate gravitational effect of point masses for each stations-point mass combination and store them in a matrix
36 | J=memory_save_masspoint_calc_FTG_2(lon0,lat0,depths,masses,lon,lat,heights,point_mass_number)
37 | return J
38 |
39 | def invert_and_calculate(prefix,moho,bouguer,J,J_shift,dmatrix,save_fields,shape):
40 |
41 | """Inverts the Moho depth with the calcualted Jacobian Matrix and optionally calculates residual fields
42 |
43 | Input:
44 | prefix - prefix of datafile (String)
45 | moho - Vector of Moho depth of starting model
46 | bouguer - Vector of gravity data
47 | J, J_shift - Jacobian matrices
48 | dmatrix - Smoothing matrix, same shape as J
49 | save_fields - "yes" or "no" option to save calculated fields
50 | shape - Size of the data
51 |
52 | Output:
53 | moho final - estimated Moho depth
54 | bouguer_fit - Fit to gravity data"""
55 |
56 | # Restore Jacobian matrix
57 | N_points=dmatrix.shape[0]
58 | big_G = J.reshape((1*N_points,N_points))
59 | big_delta_G = J_shift.reshape((1*N_points,N_points))
60 |
61 | # modelled gravitational effect per station is the sum of each tesseroid
62 | bouguer_mod=np.sum(big_G, axis=1)
63 | big_d=bouguer.reshape((1*N_points)) - bouguer_mod
64 | bouguer_obs=bouguer.reshape((1*N_points))
65 |
66 | # Solve linear equation system and calculate Moho depth and data fit
67 | rhs = big_delta_G.T.dot(big_d)-dmatrix.T.dot(dmatrix).dot(moho/1000)
68 | lhs = big_delta_G.T.dot(big_delta_G)+dmatrix.T.dot(dmatrix)
69 | moho_shift = np.linalg.solve(lhs,rhs)
70 | predicted = big_delta_G.dot(moho_shift).reshape((1,shape[1],shape[0]))
71 | moho_final = moho_shift + moho/1000
72 | bouguer_res=bouguer_obs-bouguer_mod
73 | bouguer_fit=np.copy(bouguer_res)
74 |
75 | if save_fields=="yes":
76 | np.savetxt(prefix+"_inverted_Moho.txt",moho_final)
77 | np.savetxt(prefix+"_predicted_field.txt",bouguer_mod)
78 | np.savetxt(prefix+"_observed.txt",bouguer_obs)
79 | np.savetxt(prefix+"_deltay_it0.txt",bouguer_res)
80 |
81 | return moho_final,bouguer_fit
82 |
83 | def weight_Jacobian(J,J_shift,dens,dens_start):
84 | """Weights the Jacobian matrices with the respective density contrasts
85 |
86 | Input:
87 | J, J_shift - Jacobian matrices of initial inversion
88 | dens_start - initial density contrasts
89 | dens - density contrast of each iteration
90 |
91 | Output:
92 | J_new, J_new_shift - Weighted Jacobian matrices"""
93 |
94 | J_new=(np.abs(dens)/dens_start)*J
95 | J_shift_new=(np.abs(dens)/dens_start)*J_shift
96 |
97 | return J_new,J_shift_new
98 |
99 |
100 | def load_grav_data(lateral_var,area):
101 |
102 | """Load gravitational data for the inversion
103 | If inversion is carried out for different component than gzz, gravity data have to be changed manually inside the function
104 | Gravity data for synthetic example has been calculated from an isostatic Moho depth with two different assumptions:
105 | 1. Laterally constant density contrast (400 kg/m³)
106 | 2. Laterally variable density contrast (for values see in paper)
107 |
108 | Input:
109 | lateral_var - "yes" or "no" statement
110 | area - boundaries of the study area
111 |
112 | Output:
113 | arrays - 3-column Matrix of the gravity data (Lon,Lat, Gravity)"""
114 |
115 | if lateral_var=="no":
116 | data=np.loadtxt('Gravity_Data/Effect_IsoMoho_Amazonia_guu_1degree_225km.xyz')
117 |
118 | if lateral_var=="yes":
119 | data=np.loadtxt('Gravity_Data/Effect_IsoMoho_Amazonia_guu_1degree_225km_vardens.xyz')
120 |
121 | data=np.array((data[:,0],data[:,1],data[:,2])).T
122 | data=cut_data_to_study_area(data,area)
123 | data=data[np.lexsort((data[:,0],data[:,1]))]
124 |
125 | return data
126 |
127 | def cut_data_to_study_area(data,area):
128 |
129 | # Cuts the data to the user-defined study area
130 | data=data[~(data[:,0]area[3])]
132 | data=data[~(data[:,1]area[1])]
134 | return data
135 |
136 | def create_density_combinations(k,number_of_units):
137 |
138 | """Creates and sorts all density combinations for k density contrasts of n number of units
139 | The combinations are stored in a matrix
140 | total number of combinations is n^k
141 |
142 | Input:
143 | k - range of density contrasts
144 | number_of_units - Number of tectonic units
145 |
146 | Output:
147 | dens_mat - matrix containing all density combinations (row) of different tectonic units (column)"""
148 |
149 | dens_mat=np.transpose(np.tile(k,(number_of_units,len(k)**(number_of_units-1))))
150 |
151 | for i in range(1,number_of_units):
152 | dens_mat[:,number_of_units-1-i]=np.transpose(np.reshape(dens_mat[:,number_of_units-1-i],(len(k)**i,len(k)**(number_of_units-i)))).flatten()
153 | return dens_mat
154 |
155 | def interp_regular_grid_on_irregular_database(area,dx,moho,seismic_stations):
156 |
157 | """Interpolate regular grid values on irregular distributed points
158 | points have to be inside the boundaries of the grid
159 |
160 | Input:
161 | area - boundaries of the study area
162 | dx - step size of the grid
163 | moho - 1-column layer of Moho depth
164 | seismic stations - 3-column layer of seismic stations (Lon,Lat,Station)
165 |
166 | Output:
167 | interp_arr - Interpolated values of gridded data
168 | moho_diff - Difference between point estimates and interpolated data"""
169 |
170 | lon=np.arange(area[2],area[3]+dx,dx)
171 | lat=np.arange(area[0],area[1]+dx,dx)
172 |
173 | moho_for_interp=moho.reshape((len(lat),len(lon)))
174 | moho_for_interp=np.transpose(moho_for_interp)
175 |
176 | interp_func=RegularGridInterpolator((lon,lat),moho_for_interp)
177 | interp_arr=interp_func(seismic_stations[:,0:2],method="linear")
178 | moho_diff=(seismic_stations[:,2]-interp_arr)/1000
179 | return moho_diff,interp_arr
180 |
181 |
182 | def create_rms_matrix(rms_matrix,data,moho_resid_points,moho_resid_grid,i,bouguer_fit):
183 |
184 | """Creates a matrix of RMS-values for residual Moho depth and residual gravity field"""
185 |
186 | bouguer_fit=bouguer_fit[~(data[:,2]==0)] # remove values outside of coastline
187 | bouguer_fit_rms=np.sqrt(np.sum(bouguer_fit**2)/(bouguer_fit.shape)) # compute RMS
188 |
189 | moho_resid_points_rms=np.sqrt(np.sum(moho_resid_points**2)/(moho_resid_points.shape)) # Compute RMS of points only
190 |
191 | moho_resid_grid=moho_resid_grid[~(data[:,2]==0)] # remove values outside of coastline
192 | moho_resid_grid_rms=np.sqrt(np.sum(moho_resid_grid**2)/(moho_resid_grid.shape)) # compute RMS of grid
193 |
194 | rms_matrix[i,0]=bouguer_fit_rms # construct columns of matrix, containing RMS values of residual field, residual Moho depth and residual binned only Moho depth
195 | rms_matrix[i,1]=moho_resid_points_rms
196 | rms_matrix[i,2]=moho_resid_grid_rms
197 | return rms_matrix
198 |
199 | def construct_layers_of_model(data_layer,reference):
200 |
201 | """constructs layers which are required for the inversion
202 |
203 | Input:
204 | data_layer - Vector of initial Moho depth
205 | reference - Reference layer, where data_layer is discretized (Float)
206 |
207 | Output:
208 | layer_top,layer_bottom - Top and bottom layer of discretized model"""
209 |
210 | data_layer=np.copy(data_layer)/1000
211 | reference=reference/1000
212 | layer_top=data_layer.copy()
213 | layer_bottom=data_layer.copy()
214 | layer_top[layer_top < reference] = reference # upper layer
215 | layer_bottom[layer_bottom > reference] = reference # lower layer
216 |
217 |
218 | return layer_top,layer_bottom
219 |
220 | def Doperator(nfs,sul,suw):
221 | """composes the Dmatrix 'dmat' for roughness determination
222 | nfs: (2x1) number of patches
223 | sul: (1) patch length
224 | suw: (1) patch width
225 |
226 | Output:
227 | DD - Smoothing matrix following 2nd order Tikhonov regularization"""
228 |
229 | k=0;
230 | # dmat is the pre-operator matrix
231 | # defines from location of patches the neighboring patches
232 | dmat=np.ones((nfs[0]*nfs[1],4))
233 | dmat[0:nfs[0],0]=0 # I 1/suw
234 | dmat[-2-nfs[0]+1:-1,1]=0 # II 1/suw
235 | dmat[-1,1]=0
236 | dmat[:len(dmat):nfs[0],2]=0 # III 1/sul
237 | dmat[nfs[0]-1:len(dmat)+2:nfs[0],3]=0 # IV 1/sul
238 |
239 | DD=np.zeros((nfs[0]*nfs[1],nfs[0]*nfs[1])) # square
240 |
241 | for i in range(0,nfs[0]*nfs[1]):
242 |
243 | flags=dmat[i,:];
244 |
245 | # diagonal
246 | DD[i,i]=(-1)*np.dot(flags,np.array([1/suw**2, 1/suw**2, 1/sul**2, 1/sul**2]).T);
247 |
248 | # neighboring patches if any
249 | if flags[0]==1:
250 | DD[i,i-nfs[k]]=1/suw**2
251 | if flags[1]==1:
252 | DD[i,i+nfs[k]]=1/suw**2
253 | if flags[2]==1:
254 | DD[i,i-1]=1/sul**2
255 | if flags[3]==1:
256 | DD[i,i+1]=1/sul**2
257 |
258 | return DD
259 |
260 |
261 | # The following functions are included to calculate the construct point masses from tesseroids and to calculate their gravitational effect.
262 | # In the original publication of Haas et al. the gravitational effect of tesseroids has been calculated with the executable tesseroid files.
263 | # However, the .exe do not allow calculation on the browser for safety reasons. Therefore, the forward calculation has been changed to point masses.
264 | # The accuracy is very similar to tesseroids.
265 | # The following functions, as well as the annotations, are written by Wolfgang Szwillus and have to be treated confidentially.
266 |
267 |
268 | def masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,**kwargs):
269 | """Calculate gravity field from a collection of point masses
270 |
271 | lon, lat, depths, mass have arbitrary but identical shape
272 | lons, lats and heights are vectors
273 |
274 | Units
275 | ---
276 | depths are POSITIVE DOWN in km
277 | heights is POSITIVE UP in m
278 | mass is in kg
279 | returns gravity in SI units
280 |
281 | kwargs
282 | ---
283 | calc_mode can be grad, grav or potential
284 |
285 | Returns
286 | ---
287 | The sensitivity matrix -> effect of each mass on all of the stations
288 | """
289 |
290 | G=6.67428e-11
291 | lon = lon[...,None]
292 | lat = lat[...,None]
293 | depths =depths[...,None]
294 | mass = mass[...,None]
295 | dLon = lon - lons
296 | coslat1 = np.cos(lat/180.0*np.pi)
297 | cosPsi = (coslat1 * np.cos(lats/180.0*np.pi) * np.cos(dLon/180.0*np.pi) +
298 | np.sin(lat/180.0*np.pi) * np.sin(lats/180.0*np.pi))
299 | cosPsi[cosPsi>1] = 1
300 |
301 | KPhi = (np.cos(lats/180.0*np.pi) * np.sin(lat/180.0*np.pi) -
302 | np.sin(lats/180.0*np.pi) * coslat1 * np.cos(dLon/180.0*np.pi))
303 |
304 |
305 | rStat = (heights + 6371000.0)
306 | g = np.zeros((len(lons),len(lon)))
307 | rTess = (6371000.0 - 1000.0*depths)
308 | spherDist = np.sqrt(rTess**2 + rStat**2
309 | - 2 * rTess * rStat*cosPsi)
310 |
311 | dx = KPhi * rTess
312 | dy = rTess * coslat1 * np.sin(dLon/180.0*np.pi)
313 | dz = rTess * cosPsi - rStat
314 |
315 | T = np.zeros(spherDist.shape+(6,))
316 | T[...,0] = ((3.0*dz*dz/(spherDist**5)- 1.0/(spherDist**3))*mass*G)
317 | return T
318 |
319 | def memory_save_masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,point_mass_number,**kwargs):
320 | """Calculate gravity effect of a collection of point masses in chunks to save memory.
321 | max_size gives the maximum size in bytes used for the sensitivity matrix
322 | See docu for masspoint_calc_FTG_2
323 | """
324 | N = lon.size
325 | M = lons.size
326 | calc_mode = kwargs.get("calc_mode","grad")
327 | max_size = kwargs.get("max_size",1000000000) # in bytes
328 | verbose = kwargs.get("verbose",False)
329 |
330 | T = np.zeros(lons.shape+(1,))
331 | partitions = np.ceil(8 * N * M / max_size).astype(int)
332 | if verbose:
333 | print('Number of partitions ',partitions)
334 |
335 | ixs = np.array_split(np.arange(M,dtype=int),partitions)
336 | for ix in ixs:
337 | design_matrix = masspoint_calc_FTG_2(lon,lat,depths,mass,lons[ix],lats[ix],heights[ix],**kwargs)
338 | J=sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats)
339 |
340 | if verbose:
341 | print('Parition done')
342 | return J
343 |
344 | def sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats):
345 | J=np.zeros((len(lons),len(lats)))
346 | for i in range(point_mass_number):
347 | for j in range(point_mass_number):
348 | for k in range(point_mass_number):
349 | J_calc=np.copy(design_matrix)*-1
350 | J_calc=J_calc[i][j][k][:][:][:]
351 | J_calc=J_calc[:, :, 0]/10**-9
352 | J=J+J_calc
353 | return J
354 |
355 | def tesses_to_pointmass(lon,lat,dx,dy,tops,bottoms,dens,hsplit,vsplit):
356 | """Convert several tesseroids into a set of point masses
357 | """
358 |
359 | depths = np.zeros((vsplit,hsplit,hsplit)+lon.shape)
360 | lon0 = np.zeros(depths.shape)
361 | lat0 = np.zeros(depths.shape)
362 | masses = np.zeros(depths.shape)
363 | dlon = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dx
364 | dlat = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dy
365 | for k in range(vsplit):
366 | print('Calculation point mass No',k+1)
367 | if k==0:
368 | top = tops
369 | else:
370 | top = (bottoms-tops)/(1.0*vsplit)*k + tops
371 | if k==vsplit-1:
372 | bot = bottoms
373 | else:
374 | bot = (bottoms-tops)/(1.0*vsplit)*(k+1) + tops
375 | r_top = 6371-top
376 | r_bot = 6371-bot
377 | r_term = (r_top**3-r_bot**3)/3.0
378 |
379 | ind=0
380 | for i in range(hsplit):
381 | for j in range(hsplit):
382 | lon0[k,i,j] = lon + dlon[j]
383 | lat0[k,i,j] = lat + dlat[i]
384 | depths[k,i,j] = 0.5 * (top+bot)
385 | surface_Area = -dx*(np.pi/(180.0*hsplit)) *np.cos(
386 | lat0[k,i,j]/180.0*np.pi) * 2 * np.sin(dy/(360.0*hsplit)*np.pi)
387 | masses[k,i,j] = surface_Area*dens*r_term*1e9
388 | ind=ind+1
389 | return lon0,lat0,depths,masses
--------------------------------------------------------------------------------
/code_user_defined/grad_inv_functions.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | from scipy.interpolate import interp1d,RegularGridInterpolator
3 | import subprocess
4 | import tempfile
5 | from matplotlib import path
6 | import progressbar
7 |
8 | def create_Jacobian(lon,lat,top_layer,bottom_layer, heights, density, point_mass_number):
9 | """Calculates the Jacobian Matrix of the inversion
10 | The shape of the Matrix is n Stations (row) and m Tesseroids (column).
11 | The function get_inversion_design_matrix calculates the gravitational effect of each tesseroid for each station.
12 |
13 | Input:
14 | lon, lat - Vectors of Longitude and Latitude for all stations
15 | top_layer, bottom_layer - Vectors of top and bottom layer of tesseroid model
16 | heights - Vector of heights of stations
17 | density - Vector of density contrast of the tesseroid model
18 | point_mass_number - Number of point masses the tesseroids are converted (Float)
19 |
20 | All vectors have the length of n stations!
21 |
22 | Output:
23 | J - Jacobian or Design matrix"""
24 |
25 | # resolution of grid (should be 1 degree)
26 | dx=(np.amax(lon)-np.amin(lon))/(np.sqrt(len(lon))-1)
27 | dy=(np.amax(lat)-np.amin(lat))/(np.sqrt(len(lat))-1)
28 |
29 | print("Calculate Jacobian")
30 |
31 | # Convert the tesseroids to point masses
32 | lon0,lat0,depths,masses=tesses_to_pointmass(lon,lat,dx,dy,
33 | top_layer,bottom_layer,density,hsplit=point_mass_number,vsplit=point_mass_number)
34 |
35 | #Calculate gravitational effect of point masses for each stations-point mass combination and store them in a matrix
36 | J=memory_save_masspoint_calc_FTG_2(lon0,lat0,depths,masses,lon,lat,heights,point_mass_number)
37 | return J
38 |
39 | def invert_and_calculate(prefix,moho,bouguer,J,J_shift,dmatrix,save_fields,shape):
40 |
41 | """Inverts the Moho depth with the calcualted Jacobian Matrix and optionally calculates residual fields
42 |
43 | Input:
44 | prefix - prefix of datafile (String)
45 | moho - Vector of Moho depth of starting model
46 | bouguer - Vector of gravity data
47 | J, J_shift - Jacobian matrices
48 | dmatrix - Smoothing matrix, same shape as J
49 | save_fields - "yes" or "no" option to save calculated fields
50 | shape - Size of the data
51 |
52 | Output:
53 | moho final - estimated Moho depth
54 | bouguer_fit - Fit to gravity data"""
55 |
56 | # Restore Jacobian matrix
57 | N_points=dmatrix.shape[0]
58 | big_G = J.reshape((1*N_points,N_points))
59 | big_delta_G = J_shift.reshape((1*N_points,N_points))
60 |
61 | # modelled gravitational effect per station is the sum of each tesseroid
62 | bouguer_mod=np.sum(big_G, axis=1)
63 | big_d=bouguer.reshape((1*N_points)) - bouguer_mod
64 | bouguer_obs=bouguer.reshape((1*N_points))
65 |
66 | # Solve linear equation system and calculate Moho depth and data fit
67 | rhs = big_delta_G.T.dot(big_d)-dmatrix.T.dot(dmatrix).dot(moho/1000)
68 | lhs = big_delta_G.T.dot(big_delta_G)+dmatrix.T.dot(dmatrix)
69 | moho_shift = np.linalg.solve(lhs,rhs)
70 | predicted = big_delta_G.dot(moho_shift).reshape((1,shape[1],shape[0]))
71 | moho_final = moho_shift + moho/1000
72 | bouguer_res=bouguer_obs-bouguer_mod
73 | bouguer_fit=np.copy(bouguer_res)
74 |
75 | if save_fields=="yes":
76 | np.savetxt(prefix+"_inverted_Moho.txt",moho_final)
77 | np.savetxt(prefix+"_predicted_field.txt",bouguer_mod)
78 | np.savetxt(prefix+"_observed.txt",bouguer_obs)
79 | np.savetxt(prefix+"_deltay_it0.txt",bouguer_res)
80 |
81 | return moho_final,bouguer_fit
82 |
83 | def weight_Jacobian(J,J_shift,dens,dens_start):
84 | """Weights the Jacobian matrices with the respective density contrasts
85 |
86 | Input:
87 | J, J_shift - Jacobian matrices of initial inversion
88 | dens_start - initial density contrasts
89 | dens - density contrast of each iteration
90 |
91 | Output:
92 | J_new, J_new_shift - Weighted Jacobian matrices"""
93 |
94 | J_new=(np.abs(dens)/dens_start)*J
95 | J_shift_new=(np.abs(dens)/dens_start)*J_shift
96 |
97 | return J_new,J_shift_new
98 |
99 |
100 | def load_grav_data(farfield,sediments,area):
101 |
102 | """Load gravitational data for the inversion
103 | Gravitational data is corrected for global topography
104 | Gravitational effects of farfield and sediments have to be replaced when changing the study area!
105 | Resolution of the data must be identical with resolution of initial Moho depth! (1 degree)
106 |
107 | Farfield effect accounts for isostatic effect outside of study area and has to be calculated separately
108 | If farfield effect is activated, gravity data with global topographic correction and farfield compensation is calculated
109 | Gravitational effect of sediments is optional and has to be calcualted separately and must be in the same format
110 |
111 | Input:
112 | farfield - "yes" or "no" statement
113 | sediments - "yes" or "no" statement
114 | area - boundaries of the study area
115 |
116 | Output:
117 | arrays - 3-column Matrix of the gravity data (Lon,Lat, Gravity)"""
118 |
119 | data=np.loadtxt('Gravity_Data/guu_global_Topo_corrected_1degree.xyz')
120 | data=np.array((data[:,0],data[:,1],data[:,2])).T
121 | data=cut_data_to_study_area(data,area)
122 | data=data[np.lexsort((data[:,0],data[:,1]))]
123 | if farfield=="yes":
124 | iso_outside=np.loadtxt('Gravity_Data/IsoEffect_farfield_Amazonia_225km_1degree_guu.xyz')
125 | iso_outside=iso_outside[np.lexsort((iso_outside[:,0],iso_outside[:,1]))]
126 | iso_outside=iso_outside[:,2]
127 | arrays = np.array((data[:,0], data[:,1], data[:,2]+iso_outside))
128 | if farfield=="yes" and sediments=="yes":
129 | sed=np.loadtxt('Gravity_Data/SedEffect_Amazonia_CRUST_225km_1degree_guu.xyz')
130 | sed=sed[np.lexsort((sed[:,0],sed[:,1]))]
131 | sed=sed[:,2]
132 | arrays = np.array((data[:,0], data[:,1], data[:,2]-sed+iso_outside))
133 | if farfield!="yes" and sediments=="yes":
134 | sed=np.loadtxt('Gravity_Data/SedEffect_Amazonia_CRUST_225km_1degree_guu.xyz')
135 | sed=sed[np.lexsort((sed[:,0],sed[:,1]))]
136 | sed=sed[:,2]
137 | arrays = np.array((data[:,0], data[:,1], data[:,2]-sed))
138 | if farfield!="yes" and sediments!="yes":
139 | arrays = np.array((data[:,0], data[:,1], data[:,2]))
140 | return np.transpose(arrays)
141 |
142 | def cut_data_to_study_area(data,area):
143 |
144 | # Cuts the data to the user-defined study area
145 | data=data[~(data[:,0]area[3])]
147 | data=data[~(data[:,1]area[1])]
149 | return data
150 |
151 | def create_density_combinations(k,number_of_units):
152 | """Creates and sorts all density combinations for k density contrasts of n number of units
153 | The combinations are stored in a matrix
154 | total number of combinations is n^k
155 |
156 | Input:
157 | k - range of density contrasts
158 | number_of_units - Number of tectonic units
159 |
160 | Output:
161 | dens_mat - matrix containing all density combinations (row) of different tectonic units (column)"""
162 |
163 | dens_mat=np.transpose(np.tile(k,(number_of_units,len(k)**(number_of_units-1))))
164 |
165 | for i in range(1,number_of_units):
166 | dens_mat[:,number_of_units-1-i]=np.transpose(np.reshape(dens_mat[:,number_of_units-1-i],(len(k)**i,len(k)**(number_of_units-i)))).flatten()
167 | return dens_mat
168 |
169 | def interp_regular_grid_on_irregular_database(area,dx,moho,seismic_stations):
170 |
171 | """Interpolate regular grid values on irregular distributed points
172 | points have to be inside the boundaries of the grid
173 |
174 | Input:
175 | area - boundaries of the study area
176 | dx - step size of the grid
177 | moho - 1-column layer of Moho depth
178 | seismic stations - 3-column layer of seismic stations (Lon,Lat,Station)
179 |
180 | Output:
181 | interp_arr - Interpolated values of gridded data
182 | moho_diff - Difference between point estimates and interpolated data"""
183 |
184 | lon=np.arange(area[2],area[3]+dx,dx)
185 | lat=np.arange(area[0],area[1]+dx,dx)
186 |
187 | moho_for_interp=moho.reshape((len(lat),len(lon)))
188 | moho_for_interp=np.transpose(moho_for_interp)
189 |
190 | interp_func=RegularGridInterpolator((lon,lat),moho_for_interp)
191 | interp_arr=interp_func(seismic_stations[:,0:2],method="linear")
192 | moho_diff=(seismic_stations[:,2]-interp_arr)/1000
193 | return moho_diff,interp_arr
194 |
195 |
196 | def create_rms_matrix(rms_matrix,data,moho_resid_points,moho_resid_grid,i,bouguer_fit):
197 |
198 | # Creates a matrix of RMS-values for residual Moho depth and residual gravity field
199 |
200 | bouguer_fit=bouguer_fit[~(data[:,2]==0)] # remove values outside of coastline
201 | bouguer_fit_rms=np.sqrt(np.sum(bouguer_fit**2)/(bouguer_fit.shape)) # compute RMS
202 |
203 | moho_resid_points_rms=np.sqrt(np.sum(moho_resid_points**2)/(moho_resid_points.shape)) # Compute RMS of points only
204 |
205 | moho_resid_grid=moho_resid_grid[~(data[:,2]==0)] # remove values outside of coastline
206 | moho_resid_grid_rms=np.sqrt(np.sum(moho_resid_grid**2)/(moho_resid_grid.shape)) # compute RMS of grid
207 |
208 | rms_matrix[i,0]=bouguer_fit_rms # construct columns of matrix, containing RMS values of residual field, residual Moho depth and residual binned only Moho depth
209 | rms_matrix[i,1]=moho_resid_points_rms
210 | rms_matrix[i,2]=moho_resid_grid_rms
211 | return rms_matrix
212 |
213 | def construct_layers_of_model(data_layer,reference):
214 | """constructs layers which are required for the inversion
215 |
216 | Input:
217 | data_layer - Vector of initial Moho depth
218 | reference - Reference layer, where data_layer is discretized (Float)
219 |
220 | Output:
221 | layer_top,layer_bottom - Top and bottom layer of discretized model"""
222 |
223 | data_layer=np.copy(data_layer)/1000
224 | reference=reference/1000
225 | layer_top=data_layer.copy()
226 | layer_bottom=data_layer.copy()
227 | layer_top[layer_top < reference] = reference # upper layer
228 | layer_bottom[layer_bottom > reference] = reference # lower layer
229 |
230 |
231 | return layer_top,layer_bottom
232 |
233 | def Doperator(nfs,sul,suw):
234 | """composes the Dmatrix 'dmat' for roughness determination
235 | nfs: (2x1) number of patches
236 | sul: (1) patch length
237 | suw: (1) patch width
238 |
239 | Output:
240 | DD - Smoothing matrix following 2nd order Tikhonov regularization"""
241 |
242 | k=0;
243 | # dmat is the pre-operator matrix
244 | # defines from location of patches the neighboring patches
245 | dmat=np.ones((nfs[0]*nfs[1],4))
246 | dmat[0:nfs[0],0]=0 # I 1/suw
247 | dmat[-2-nfs[0]+1:-1,1]=0 # II 1/suw
248 | dmat[-1,1]=0
249 | dmat[:len(dmat):nfs[0],2]=0 # III 1/sul
250 | dmat[nfs[0]-1:len(dmat)+2:nfs[0],3]=0 # IV 1/sul
251 |
252 | DD=np.zeros((nfs[0]*nfs[1],nfs[0]*nfs[1])) # square
253 |
254 | for i in range(0,nfs[0]*nfs[1]):
255 |
256 | flags=dmat[i,:];
257 |
258 | # diagonal
259 | DD[i,i]=(-1)*np.dot(flags,np.array([1/suw**2, 1/suw**2, 1/sul**2, 1/sul**2]).T);
260 |
261 | # neighboring patches if any
262 | if flags[0]==1:
263 | DD[i,i-nfs[k]]=1/suw**2
264 | if flags[1]==1:
265 | DD[i,i+nfs[k]]=1/suw**2
266 | if flags[2]==1:
267 | DD[i,i-1]=1/sul**2
268 | if flags[3]==1:
269 | DD[i,i+1]=1/sul**2
270 |
271 | return DD
272 |
273 |
274 | # The following functions are included to calculate the construct point masses from tesseroids and to calculate their gravitational effect.
275 | # In the original publication of Haas et al. the gravitational effect of tesseroids has been calculated with the executable tesseroid files.
276 | # However, the .exe do not allow calculation on the browser for safety reasons. Therefore, the forward calculation has been changed to point masses.
277 | # The accuracy is very similar to tesseroids.
278 | #
279 | # The following functions, as well as the annotations, are written by Wolfgang Szwillus and have to be treated confidentially.
280 |
281 |
282 | def masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,**kwargs):
283 | """Calculate gravity field from a collection of point masses
284 |
285 | lon, lat, depths, mass have arbitrary but identical shape
286 | lons, lats and heights are vectors
287 |
288 | Units
289 | ---
290 | depths are POSITIVE DOWN in km
291 | heights is POSITIVE UP in m
292 | mass is in kg
293 | returns gravity in SI units
294 |
295 | kwargs
296 | ---
297 | calc_mode can be grad, grav or potential
298 |
299 | Returns
300 | ---
301 | The sensitivity matrix -> effect of each mass on all of the stations
302 | """
303 |
304 | G=6.67428e-11
305 | lon = lon[...,None]
306 | lat = lat[...,None]
307 | depths =depths[...,None]
308 | mass = mass[...,None]
309 | dLon = lon - lons
310 | coslat1 = np.cos(lat/180.0*np.pi)
311 | cosPsi = (coslat1 * np.cos(lats/180.0*np.pi) * np.cos(dLon/180.0*np.pi) +
312 | np.sin(lat/180.0*np.pi) * np.sin(lats/180.0*np.pi))
313 | cosPsi[cosPsi>1] = 1
314 |
315 | KPhi = (np.cos(lats/180.0*np.pi) * np.sin(lat/180.0*np.pi) -
316 | np.sin(lats/180.0*np.pi) * coslat1 * np.cos(dLon/180.0*np.pi))
317 |
318 |
319 | rStat = (heights + 6371000.0)
320 | g = np.zeros((len(lons),len(lon)))
321 | rTess = (6371000.0 - 1000.0*depths)
322 | spherDist = np.sqrt(rTess**2 + rStat**2
323 | - 2 * rTess * rStat*cosPsi)
324 |
325 | dx = KPhi * rTess
326 | dy = rTess * coslat1 * np.sin(dLon/180.0*np.pi)
327 | dz = rTess * cosPsi - rStat
328 |
329 | T = np.zeros(spherDist.shape+(6,))
330 | T[...,0] = ((3.0*dz*dz/(spherDist**5)- 1.0/(spherDist**3))*mass*G)
331 | return T
332 |
333 | def memory_save_masspoint_calc_FTG_2(lon,lat,depths,mass,lons,lats,heights,point_mass_number,**kwargs):
334 | """Calculate gravity effect of a collection of point masses in chunks to save memory.
335 | max_size gives the maximum size in bytes used for the sensitivity matrix
336 | See docu for masspoint_calc_FTG_2
337 | """
338 | N = lon.size
339 | M = lons.size
340 | calc_mode = kwargs.get("calc_mode","grad")
341 | max_size = kwargs.get("max_size",1000000000) # in bytes
342 | verbose = kwargs.get("verbose",False)
343 |
344 | T = np.zeros(lons.shape+(1,))
345 | partitions = np.ceil(8 * N * M / max_size).astype(int)
346 | if verbose:
347 | print('Number of partitions ',partitions)
348 |
349 | ixs = np.array_split(np.arange(M,dtype=int),partitions)
350 | for ix in ixs:
351 | design_matrix = masspoint_calc_FTG_2(lon,lat,depths,mass,lons[ix],lats[ix],heights[ix],**kwargs)
352 | J=sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats)
353 |
354 | if verbose:
355 | print('Parition done')
356 | return J
357 |
358 | def sum_over_multidimensional_matrix(design_matrix,point_mass_number,lons,lats):
359 | J=np.zeros((len(lons),len(lats)))
360 | for i in range(point_mass_number):
361 | for j in range(point_mass_number):
362 | for k in range(point_mass_number):
363 | J_calc=np.copy(design_matrix)*-1
364 | J_calc=J_calc[i][j][k][:][:][:]
365 | J_calc=J_calc[:, :, 0]/10**-9
366 | J=J+J_calc
367 | return J
368 |
369 | def tesses_to_pointmass(lon,lat,dx,dy,tops,bottoms,dens,hsplit,vsplit):
370 | """Convert several tesseroids into a set of point masses
371 | """
372 |
373 | depths = np.zeros((vsplit,hsplit,hsplit)+lon.shape)
374 | lon0 = np.zeros(depths.shape)
375 | lat0 = np.zeros(depths.shape)
376 | masses = np.zeros(depths.shape)
377 | dlon = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dx
378 | dlat = (2*np.arange(0,hsplit,1)-hsplit+1)/(2.0*hsplit)*dy
379 | for k in range(vsplit):
380 | print('Calculation point mass No',k+1)
381 | if k==0:
382 | top = tops
383 | else:
384 | top = (bottoms-tops)/(1.0*vsplit)*k + tops
385 | if k==vsplit-1:
386 | bot = bottoms
387 | else:
388 | bot = (bottoms-tops)/(1.0*vsplit)*(k+1) + tops
389 | r_top = 6371-top
390 | r_bot = 6371-bot
391 | r_term = (r_top**3-r_bot**3)/3.0
392 |
393 | ind=0
394 | for i in range(hsplit):
395 | for j in range(hsplit):
396 | lon0[k,i,j] = lon + dlon[j]
397 | lat0[k,i,j] = lat + dlat[i]
398 | depths[k,i,j] = 0.5 * (top+bot)
399 | surface_Area = -dx*(np.pi/(180.0*hsplit)) *np.cos(
400 | lat0[k,i,j]/180.0*np.pi) * 2 * np.sin(dy/(360.0*hsplit)*np.pi)
401 | masses[k,i,j] = surface_Area*dens*r_term*1e9
402 | ind=ind+1
403 | return lon0,lat0,depths,masses
--------------------------------------------------------------------------------
/code_user_defined/topo_corr.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | from grad_inv_functions import *
3 |
4 | def topo_corr(lon,lat,bed,ice,heights,point_mass_number):
5 |
6 | """Calculates the gravitational effect of topography, discretized into a tesseroid model, which is transformed into point masses
7 |
8 | Input:
9 | bed, ice - 2D arrays of ice and bedrock topography (Longitude, Latitude, Value)
10 | heights_km - Height, where gravitational effect is calculated (Float)
11 | point_mass_number - Number of point masses the tesseroids are converted (Float)
12 |
13 | Output:
14 | bouguer - Vector of gravitational effect of topography"""
15 |
16 | #Define densities for topo corr
17 | dens_rock=2670
18 | dens_water=1030
19 | dens_ice=917
20 | reference_topo=0.0
21 |
22 | (bed_top,bed_bottom)=construct_layers_of_model(bed[:,2],reference_topo)
23 | (ice_above_top,ice_above_bottom)=construct_layers_of_model(ice[:,2],reference_topo)
24 | (ice_below_top,ice_below_bottom)=construct_layers_of_model(bed[:,2]-ice_above_bottom,reference_topo)
25 | diff=ice_above_top-bed_top
26 | bed[np.where(diff <0),2]=ice[np.where(diff <0),2]
27 | #ice_below_top[np.where(diff <0)]=ice_below_bottom[np.where(diff <0)]
28 | ice_above_bottom=np.copy(bed_top)
29 | ice_above_bottom[ice_above_bottom<0]=0.0
30 | count=-1
31 | for i in range(0,len(ice)):
32 |
33 | if bed[i,2]<0 and ice[i,2]<0 and ice[i,2]!=bed[i,2] and np.abs(bed[i,2]-ice[i,2])<10:
34 | bed[i,2]=ice[i,2]
35 | # rock
36 | if ice[i,2]>0 and bed[i,2]>0 and ice[i,2]==bed[i,2]:
37 | ice_above_top[i]=0.0
38 | ice_above_bottom[i]=0.0
39 | ice_below_top[i]=0.0
40 | ice_below_bottom[i]=0.0
41 | count=count+1
42 | #water
43 | if ice[i,2]<0 and bed[i,2]<0 and ice[i,2]==bed[i,2]:
44 | ice_above_top[i]=0.0
45 | ice_above_bottom[i]=0.0
46 | ice_below_top[i]=0.0
47 | ice_below_bottom[i]=0.0
48 | count=count+1
49 | # ice above
50 | if ice[i,2]>0 and bed[i,2]>0 and ice[i,2]>bed[i,2]:
51 | ice_below_top[i]=0.0
52 | ice_below_bottom[i]=0.0
53 | count=count+1
54 | # ice below
55 | if ice[i,2]>0 and bed[i,2]<0 and ice[i,2]>bed[i,2]:
56 | bed_top[i]=0.0
57 | bed_bottom[i]=0.0
58 | count=count+1
59 |
60 | density_topo=np.ones(bed_top.shape[0])*dens_rock
61 | density_topo[np.where(bed_top == 0)]=(dens_rock-dens_water)*-1
62 | density_ice_above=np.ones(ice_above_top.shape[0])*dens_ice
63 | density_ice_below=np.ones(ice_below_top.shape[0])*(dens_rock-dens_ice)*-1
64 |
65 | print("Calculate topographic effect")
66 | J=create_Jacobian(lon,lat,bed_top*-1,bed_bottom*-1,heights, density_topo, point_mass_number)
67 | bouguer=np.sum(J.T, axis=1)
68 | print(np.amin(bouguer),np.amax(bouguer))
69 | if np.any(ice_above_top) or np.any(ice_above_bottom):
70 | print("Calculate Ice Effect -- Above sea level")
71 | J=create_Jacobian(lon,lat,ice_above_top*-1,ice_above_bottom*-1,heights, density_ice_above, point_mass_number)
72 | bouguer_ice_above=np.sum(J.T, axis=1)
73 | print(np.amin(bouguer_ice_above),np.amax(bouguer_ice_above))
74 | bouguer=np.copy(bouguer)+bouguer_ice_above
75 |
76 | if np.any(ice_below_top) or np.any(ice_below_bottom):
77 | print("Calculate Ice Effect -- Below sea level")
78 | J=create_Jacobian(lon,lat,ice_below_top*-1,ice_below_bottom*-1,heights, density_ice_below, point_mass_number)
79 | bouguer_ice_below=np.sum(J.T, axis=1)
80 | print(np.amin(bouguer_ice_below),np.amax(bouguer_ice_below))
81 | bouguer=np.copy(bouguer)-bouguer_ice_below
82 |
83 | return bouguer
--------------------------------------------------------------------------------
/environment.yml:
--------------------------------------------------------------------------------
1 | name: gradient inversion
2 | channels:
3 | - conda-forge
4 | dependencies:
5 | - python=3.6
6 | - numpy
7 | - matplotlib
8 | - progressbar
9 | - scipy
10 | - basemap
11 |
--------------------------------------------------------------------------------