forked from groupeLIAMG/BhTomoPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inversion_ui.py
1357 lines (1111 loc) · 55.4 KB
/
inversion_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
Copyright 2017 Bernard Giroux, Elie Dumas-Lefebvre, Jerome Simon
email: [email protected]
This file is part of BhTomoPy.
BhTomoPy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from PyQt5 import QtGui, QtWidgets, QtCore
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
import numpy as np
import matplotlib as mpl
from model import Model
import scipy as spy
from scipy.sparse import linalg
from mpl_toolkits.axes_grid1 import make_axes_locatable
from scipy import interpolate
from inversion import invLSQR, InvLSQRParams
from utils import set_tick_arrangement
from mog import Mog, AirShots
# from utils_ui import chooseModel
import database
current_module = sys.modules[__name__]
database.create_data_management(current_module)
class InversionUI(QtWidgets.QFrame):
def __init__(self, parent=None):
super(InversionUI, self).__init__()
self.setWindowTitle("BhTomoPy/Inversion")
self.lsqrParams = InvLSQRParams()
self.tomo = None
self.prev_inv = []
self.model_ind = ''
self.initUI()
self.initinvUI()
def savefile(self):
if self.model_ind == '':
# If there's no selected model
return
if self.tomo is None:
current_module.session.commit()
return
if self.algo_combo.currentText() == 'LSQR Solver':
cov = '-LSQR'
if self.T_and_A_combo.currentText() == 'Traveltime':
dType = '-vel'
else:
dType = '-att'
inversion_name, ok = QtWidgets.QInputDialog.getText(self, 'Save inversion results',
'Name of Inversion:',
text='tomo (insert date) {} {}'.format(dType, cov))
if ok:
inv_res_info = (inversion_name, self.tomo, self.lsqrParams)
current_module.session.query(Model).all()[self.model_ind].inv_res.append(inv_res_info)
print(current_module.session.query(Model).all()[self.model_ind].inv_res)
current_module.session.commit()
QtWidgets.QMessageBox.information(self, 'Success', "Database was saved successfully",
buttons=QtWidgets.QMessageBox.Ok)
def openfile(self):
# models, model = chooseModel(self.filename) # TODO: Is this necessary?
# if model:
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open Database')[0]
database.load(current_module, filename)
self.model_ind = None
self.inv_frame.setHidden(True)
self.gv = Gridviewer(current_module.session.query(Model).all()[self.model_ind].grid, self)
self.global_grid.addWidget(self.gv, 1, 1, 7, 2)
self.update_data()
self.update_grid()
self.update_previous()
def update_previous(self):
self.prev_inversion_combo.clear()
self.prev_inv.clear()
if current_module.session.query(Model).count() != 0:
for result in current_module.session.query(Model).all()[self.model_ind].inv_res:
# result[0] == name
# result[1] == tomo
# result[2] == params
self.prev_inversion_combo.addItem(result[0])
self.prev_inv.append(result)
def update_data(self):
for mog in current_module.session.query(Model).all()[self.model_ind].mogs:
self.mog_list.addItem(mog.name)
self.mog_list.setCurrentRow(0)
def update_grid(self):
model = current_module.session.query(Model).all()[self.model_ind]
if np.all(model.grid.grx == 0) or np.all(model.grid.grx == 0):
QtWidgets.QMessageBox.warning(self, 'Warning', "Please create a Grid before Inversion",
buttons=QtWidgets.QMessageBox.Ok)
else:
self.X_min_label.setText(str(np.round(model.grid.grx[0], 3)))
self.X_max_label.setText(str(np.round(model.grid.grx[-1], 3)))
self.step_Xi_label.setText(str(model.grid.dx))
self.Z_min_label.setText(str(np.round(model.grid.grz[0], 3)))
self.Z_max_label.setText(str(np.round(model.grid.grz[-1], 3)))
self.step_Zi_label.setText(str(model.grid.dz))
if model.grid.type == '3D':
self.Y_min_label.setText(str(np.round(model.grid.gry[0], 3)))
self.Y_max_label.setText(str(np.round(model.grid.gry[-1], 3)))
self.step_Yi_label.setText(str(model.grid.dy))
self.num_cells_label.setText(str(model.grid.getNumberOfCells()))
def update_params(self):
self.lsqrParams.selectedMogs = self.mog_list.selectedIndexes()
self.lsqrParams.selectedMogs = [i.row() for i in self.lsqrParams.selectedMogs]
self.lsqrParams.numItStraight = int(self.straight_ray_edit.text())
self.lsqrParams.numItCurved = int(self.curv_ray_edit.text())
self.lsqrParams.useCont = self.use_const_checkbox.isChecked()
self.lsqrParams.tol = float(self.solver_tol_edit.text())
self.lsqrParams.wCont = float(self.constraints_weight_edit.text())
self.lsqrParams.alphax = float(self.smoothing_weight_x_edit.text())
self.lsqrParams.alphay = float(self.smoothing_weight_y_edit.text())
self.lsqrParams.alphaz = float(self.smoothing_weight_z_edit.text())
self.lsqrParams.order = int(self.smoothing_order_combo.currentText())
self.lsqrParams.nbreiter = float(self.max_iter_edit.text())
self.lsqrParams.dv_max = 0.01 * float(self.veloc_var_edit.text())
def update_input_params(self):
self.straight_ray_edit.setText(str(self.lsqrParams.numItStraight))
self.curv_ray_edit.setText(str(self.lsqrParams.numItCurved))
self.use_const_checkbox.setChecked(self.lsqrParams.useCont)
self.solver_tol_edit.setText(str(self.lsqrParams.tol))
self.constraints_weight_edit.setText(str(self.lsqrParams.wCont))
self.smoothing_weight_x_edit.setText(str(self.lsqrParams.alphax))
self.smoothing_weight_y_edit.setText(str(self.lsqrParams.alphay))
self.smoothing_weight_z_edit.setText(str(self.lsqrParams.alphaz))
self.smoothing_order_combo.setCurrentIndex(self.lsqrParams.order - 2)
self.max_iter_edit.setText(str(self.lsqrParams.nbreiter))
self.veloc_var_edit.setText(str(self.lsqrParams.dv_max))
self.update_params()
def doInv(self):
model = current_module.session.query(Model).all()[self.model_ind]
if self.model_ind == '':
QtWidgets.QMessageBox.warning(self, 'Warning', "First, load a model in order to do Inversion",
buttons=QtWidgets.QMessageBox.Ok)
if len(self.mog_list.selectedIndexes()) == 0:
QtWidgets.QMessageBox.warning(self, 'Warning', "Please select Mogs",
buttons=QtWidgets.QMessageBox.Ok)
elif self.T_and_A_combo.currentText() == 'Traveltime':
self.lsqrParams.tomoAtt = 0
data, idata = Model.getModelData(model, current_module.session.query(AirShots).all(), self.lsqrParams.selectedMogs, 'tt')
data = np.concatenate((model.grid.Tx[idata, :], model.grid.Rx[idata, :], data, model.grid.TxCosDir[idata, :], model.grid.RxCosDir[idata, :]), axis=1)
# TODO: Faire les autres cas du self.T_and_A_combo
L = np.array([])
rays = np.array([])
# TODO
if self.use_Rays_checkbox.isChecked():
# Change L and Rays
pass
if self.algo_combo.currentText() == 'LSQR Solver':
self.update_params()
self.tomo = invLSQR(self.lsqrParams, data, idata, model.grid, L, app, self)
if self.algo_combo.currentText() == 'Geostatistical':
# TODO: Faire l'inversion géostatistique
pass
def plot_inv(self):
s = self.tomo.s
self.gv.invFig.plot_lsqr_inv(s)
def plot_rays(self):
if self.tomo is None:
QtWidgets.QMessageBox.warning(self, 'Warning', "Inversion needed to access Results",
buttons=QtWidgets.QMessageBox.Ok)
return
self.raysFig.plot_rays()
self.update_Tx_elev()
self.rays_manager.show()
def plot_ray_density(self):
if self.tomo is None:
QtWidgets.QMessageBox.warning(self, 'Warning', "Inversion needed to access Results",
buttons=QtWidgets.QMessageBox.Ok)
return
self.raydensityFig.plot_ray_density()
self.ray_density_manager.show()
def plot_residuals(self):
if self.tomo is None:
QtWidgets.QMessageBox.warning(self, 'Warning', "Inversion needed to access Results",
buttons=QtWidgets.QMessageBox.Ok)
return
self.residualsFig.plot_residuals()
self.residuals_manager.showMaximized()
def plot_tomo(self):
if self.tomo is None:
QtWidgets.QMessageBox.warning(self, 'Warning', "Inversion needed to access Results",
buttons=QtWidgets.QMessageBox.Ok)
return
self.tomoFig.plot_tomo()
self.tomo_manager.show()
def load_prev(self):
n = self.prev_inversion_combo.currentIndex()
results = current_module.session.query(Model).all()[self.model_ind].inv_res[n]
name = results[0]
tomo = results[1]
params = results[2]
self.tomo = tomo
if '-LSQR' in name:
self.lsqrParams = params
# TODO: Faire une classe contenant les paramètres pour les inversions géostatistiques
self.algo_label.setText(results[0])
self.noIter_label.setText('| {} Iterations'.format(self.lsqrParams.numItCurved + self.lsqrParams.numItStraight))
self.plot_inv()
self.update_input_params()
def view_prev(self):
self.previnvFig.plot_tomo()
self.prev_inv_manager.show()
def delete_prev(self):
n = self.prev_inversion_combo.currentIndex()
del current_module.session.query(Model).all()[self.model_ind].inv_res[n]
self.update_previous()
def initinvUI(self):
# ------- Widget Creation ------- #
# --- Labels --- #
num_simulation_label = MyQLabel("Number of Simulations", ha='right')
slowness_label = MyQLabel("Slowness", ha='right')
islowness_label = MyQLabel("Slowness", ha='center')
separ_label = MyQLabel("|", ha='center')
traveltime_label = MyQLabel("Traveltime", ha='right')
solver_tol_label = MyQLabel('Solver Tolerance', ha='right')
max_iter_label = MyQLabel('Max number of solver iterations', ha='right')
constraints_weight_label = MyQLabel('Constraints weight', ha='right')
smoothing_weight_x_label = MyQLabel('Smoothing weight x', ha='right')
smoothing_weight_y_label = MyQLabel('Smoothing weight y', ha='right')
smoothing_weight_z_label = MyQLabel('Smoothing weight z', ha='right')
smoothing_order_label = MyQLabel('Smoothing operator order', ha='right')
veloc_var_label = MyQLabel('Max velocity varitation per iteration[%]', ha='right')
range_x_label = MyQLabel('Range X', ha='right')
range_z_label = MyQLabel('Range Z', ha='right')
theta_x_label = MyQLabel('theta X', ha='right')
sill_label = MyQLabel('Sill', ha='right')
# --- Edits --- #
self.num_simulation_edit = QtWidgets.QLineEdit('128')
self.slowness_edit = QtWidgets.QLineEdit('0')
self.traveltime_edit = QtWidgets.QLineEdit('0')
self.solver_tol_edit = QtWidgets.QLineEdit('1e-6')
self.max_iter_edit = QtWidgets.QLineEdit('100')
self.constraints_weight_edit = QtWidgets.QLineEdit('1')
self.smoothing_weight_x_edit = QtWidgets.QLineEdit('10')
self.smoothing_weight_y_edit = QtWidgets.QLineEdit('10')
self.smoothing_weight_z_edit = QtWidgets.QLineEdit('10')
self.veloc_var_edit = QtWidgets.QLineEdit('50')
self.range_x_edit = QtWidgets.QLineEdit()
self.range_z_edit = QtWidgets.QLineEdit()
self.theta_x_edit = QtWidgets.QLineEdit()
self.sill_edit = QtWidgets.QLineEdit()
# - Edits' Disposition - #
self.num_simulation_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.slowness_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.traveltime_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.solver_tol_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.max_iter_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.constraints_weight_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.smoothing_weight_x_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.smoothing_weight_y_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.smoothing_weight_z_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.veloc_var_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.range_x_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.range_z_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.theta_x_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.sill_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.num_simulation_edit.setFixedWidth(100)
self.slowness_edit.setFixedWidth(100)
self.traveltime_edit.setFixedWidth(100)
self.solver_tol_edit.setFixedWidth(100)
self.max_iter_edit.setFixedWidth(100)
self.constraints_weight_edit.setFixedWidth(100)
self.smoothing_weight_x_edit.setFixedWidth(100)
self.smoothing_weight_y_edit.setFixedWidth(100)
self.smoothing_weight_z_edit.setFixedWidth(100)
self.veloc_var_edit.setFixedWidth(100)
# - Edits Actions - #
self.num_simulation_edit.editingFinished.connect(self.update_params)
self.slowness_edit.editingFinished.connect(self.update_params)
self.traveltime_edit.editingFinished.connect(self.update_params)
self.solver_tol_edit.editingFinished.connect(self.update_params)
self.max_iter_edit.editingFinished.connect(self.update_params)
self.constraints_weight_edit.editingFinished.connect(self.update_params)
self.smoothing_weight_x_edit.editingFinished.connect(self.update_params)
self.smoothing_weight_y_edit.editingFinished.connect(self.update_params)
self.smoothing_weight_z_edit.editingFinished.connect(self.update_params)
self.veloc_var_edit.editingFinished.connect(self.update_params)
# --- CheckBoxes --- #
include_checkbox = QtWidgets.QCheckBox("Include Experimental Variance")
tilted_ellip_veloc_checkbox = QtWidgets.QCheckBox("Tilted Elliptical Velocity Anisotropy")
simulations_checkbox = QtWidgets.QCheckBox("Simulations")
ellip_veloc_checkbox = QtWidgets.QCheckBox("Elliptical Velocity Anisotropy")
# --- ComboBoxes --- #
self.geostat_struct_combo = QtWidgets.QComboBox()
self.smoothing_order_combo = QtWidgets.QComboBox()
self.param_combo = QtWidgets.QComboBox()
# - Comboboxes Actions - #
self.smoothing_order_combo.activated.connect(self.update_params)
# --- Combobox's Items --- #
params = ['Cubic', 'Sperical', 'Gaussian', 'Exponential', 'Linear', 'Thin Plate', 'Gravimetric', 'Magnetic', 'Hole Effect Sine', 'Hole Effect Cosine']
self.param_combo.addItems(params)
self.geostat_struct_combo.addItem("Structure no 1")
self.smoothing_order_combo.addItems(['2', '1'])
# --- Slowness Frame --- #
slownessFrame = QtWidgets.QFrame()
slownessGrid = QtWidgets.QGridLayout()
slownessGrid.addWidget(islowness_label)
slownessFrame.setLayout(slownessGrid)
# --- Param SubWidget --- #
sub_param_widget = QtWidgets.QWidget()
sub_param_grid = QtWidgets.QGridLayout()
sub_param_grid.addWidget(slownessFrame, 0, 1)
sub_param_grid.addWidget(self.param_combo, 1, 1)
sub_param_grid.addWidget(range_x_label, 2, 0)
sub_param_grid.addWidget(range_z_label, 3, 0)
sub_param_grid.addWidget(theta_x_label, 4, 0)
sub_param_grid.addWidget(sill_label, 5, 0)
sub_param_grid.addWidget(self.range_x_edit, 2, 1)
sub_param_grid.addWidget(self.range_z_edit, 3, 1)
sub_param_grid.addWidget(self.theta_x_edit, 4, 1)
sub_param_grid.addWidget(self.sill_edit, 5, 1)
sub_param_widget.setLayout(sub_param_grid)
# --- Scroll Area which contains the Geostatistical Parameters --- #
scrollArea = QtWidgets.QScrollArea()
scrollArea.setWidget(sub_param_widget)
# --- Parameters Groupbox --- #
Param_groupbox = QtWidgets.QGroupBox("Parameters")
Param_grid = QtWidgets.QGridLayout()
Param_grid.addWidget(scrollArea, 0, 0)
Param_grid.setVerticalSpacing(0)
Param_groupbox.setLayout(Param_grid)
# --- Nugget Effect Groupbox --- #
Nug_groupbox = QtWidgets.QGroupBox("Nugget Effect")
Nug_grid = QtWidgets.QGridLayout()
Nug_grid.addWidget(slowness_label, 0, 0)
Nug_grid.addWidget(self.slowness_edit, 0, 1)
Nug_grid.addWidget(separ_label, 0, 3)
Nug_grid.addWidget(traveltime_label, 0, 4)
Nug_grid.addWidget(self.traveltime_edit, 0, 5)
Nug_groupbox.setLayout(Nug_grid)
# --- Geostatistical inversion Groupbox --- #
Geostat_groupbox = QtWidgets.QGroupBox("Geostatistical inversion")
Geostat_grid = QtWidgets.QGridLayout()
Geostat_grid.addWidget(simulations_checkbox, 0, 0)
Geostat_grid.addWidget(ellip_veloc_checkbox, 1, 0)
Geostat_grid.addWidget(include_checkbox, 2, 0)
Geostat_grid.addWidget(num_simulation_label, 0, 1)
Geostat_grid.addWidget(self.num_simulation_edit, 0, 2)
Geostat_grid.addWidget(tilted_ellip_veloc_checkbox, 1, 1)
Geostat_grid.addWidget(self.geostat_struct_combo, 2, 1, 1, 2)
Geostat_grid.addWidget(Param_groupbox, 3, 0, 1, 3)
Geostat_grid.addWidget(Nug_groupbox, 4, 0, 1, 3)
Geostat_grid.setRowStretch(3, 100)
Geostat_groupbox.setLayout(Geostat_grid)
# --- LSQR Solver GroupBox --- #
LSQR_group = QtWidgets.QGroupBox('LSQR Solver')
LSQR_grid = QtWidgets.QGridLayout()
LSQR_grid.addWidget(solver_tol_label, 0, 0)
LSQR_grid.addWidget(max_iter_label, 1, 0)
LSQR_grid.addWidget(constraints_weight_label, 2, 0)
LSQR_grid.addWidget(smoothing_weight_x_label, 3, 0)
LSQR_grid.addWidget(smoothing_weight_y_label, 4, 0)
LSQR_grid.addWidget(smoothing_weight_z_label, 5, 0)
LSQR_grid.addWidget(smoothing_order_label, 6, 0)
LSQR_grid.addWidget(veloc_var_label, 7, 0)
LSQR_grid.addWidget(self.solver_tol_edit, 0, 1)
LSQR_grid.addWidget(self.max_iter_edit, 1, 1)
LSQR_grid.addWidget(self.constraints_weight_edit, 2, 1)
LSQR_grid.addWidget(self.smoothing_weight_x_edit, 3, 1)
LSQR_grid.addWidget(self.smoothing_weight_y_edit, 4, 1)
LSQR_grid.addWidget(self.smoothing_weight_z_edit, 5, 1)
LSQR_grid.addWidget(self.smoothing_order_combo, 6, 1)
LSQR_grid.addWidget(self.veloc_var_edit, 7, 1)
LSQR_group.setLayout(LSQR_grid)
if self.algo_combo.currentText() == 'LSQR Solver':
current = self.Inv_Param_grid.layout()
widget = current.itemAtPosition(2, 0).widget()
widget.setHidden(True)
self.Inv_Param_grid.removeWidget(widget)
self.Inv_Param_grid.addWidget(LSQR_group, 2, 0, 1, 3)
self.repaint()
else:
current = self.Inv_Param_grid.layout()
widget = current.itemAtPosition(2, 0).widget()
widget.setHidden(True)
self.Inv_Param_grid.removeWidget(widget)
self.Inv_Param_grid.addWidget(Geostat_groupbox, 2, 0, 1, 3)
self.repaint()
def update_Tx_elev(self):
mog = current_module.session.query(Mog).all()[self.mog_list.selectedIndexes()[0].row()]
n = int(self.trace_num_edit.text()) - 1
elev = np.unique(mog.data.Tx_z)[n]
if not self.entire_coverage_check.isChecked():
self.value_elev_label.setText(str(elev))
else:
self.value_elev_label.setText('-')
def next_trace(self):
n = int(self.trace_num_edit.text())
n += 1
self.trace_num_edit.setText(str(n))
self.plot_rays()
def prev_trace(self):
n = int(self.trace_num_edit.text())
n -= 1
self.trace_num_edit.setText(str(n))
self.plot_rays()
def initUI(self):
# -------- Widgets in RaysFig -------- #
# --- Edit --- #
self.trace_num_edit = QtWidgets.QLineEdit('1')
# - Edit's Actions - #
self.trace_num_edit.editingFinished.connect(self.plot_rays)
# - Edit's Disposition - #
self.trace_num_edit.setAlignment(QtCore.Qt.AlignHCenter)
# --- Buttons --- #
next_trace_btn = QtWidgets.QPushButton('Next Tx')
prev_trace_btn = QtWidgets.QPushButton('Prev Tx')
# - Buttons' Actions - #
next_trace_btn.clicked.connect(self.next_trace)
prev_trace_btn.clicked.connect(self.prev_trace)
# --- Labels --- #
coverage_elev_label = MyQLabel('Tx elevation:', ha='right')
self.value_elev_label = MyQLabel('', ha='left')
trace_label = MyQLabel('Tx Number: ', ha='right')
# --- CheckBox --- #
self.entire_coverage_check = QtWidgets.QCheckBox('Show entire coverage')
self.entire_coverage_check.stateChanged.connect(self.plot_rays)
# --- Elevation SubWidget --- #
sub_coverage_elev_widget = QtWidgets.QWidget()
sub_coverage_elev_grid = QtWidgets.QGridLayout()
sub_coverage_elev_grid.addWidget(coverage_elev_label, 0, 0)
sub_coverage_elev_grid.addWidget(self.value_elev_label, 0, 1)
sub_coverage_elev_widget.setLayout(sub_coverage_elev_grid)
# --- Trace SubWidget --- #
sub_trace_widget = QtWidgets.QWidget()
sub_trace_grid = QtWidgets.QGridLayout()
sub_trace_grid.addWidget(trace_label, 0, 0)
sub_trace_grid.addWidget(self.trace_num_edit, 0, 1)
sub_trace_grid.setContentsMargins(0, 0, 0, 0)
sub_trace_widget.setLayout(sub_trace_grid)
# --- Buttons SubWidget --- #
sub_buttons_widget = QtWidgets.QWidget()
sub_buttons_grid = QtWidgets.QGridLayout()
sub_buttons_grid.addWidget(next_trace_btn, 0, 1)
sub_buttons_grid.addWidget(prev_trace_btn, 0, 0)
sub_buttons_grid.setContentsMargins(0, 0, 0, 0)
sub_buttons_widget.setLayout(sub_buttons_grid)
sub_coverage_widget = QtWidgets.QWidget()
sub_coverage_grid = QtWidgets.QGridLayout()
sub_coverage_grid.addWidget(sub_trace_widget, 0, 0)
sub_coverage_grid.addWidget(sub_buttons_widget, 1, 0)
sub_coverage_grid.addWidget(sub_coverage_elev_widget, 2, 0)
sub_coverage_grid.addWidget(self.entire_coverage_check, 3, 0)
sub_coverage_grid.setRowStretch(5, 100)
sub_coverage_widget.setLayout(sub_coverage_grid)
# ------- Frame to fill invFig's place before loading model ------- #
self.inv_frame = QtWidgets.QFrame()
self.inv_frame.setStyleSheet('background: white')
# -------Manager for RaysFig ------ #
self.raysFig = RaysFig(self)
self.raystool = NavigationToolbar2QT(self.raysFig, self)
self.rays_manager = QtWidgets.QWidget()
rays_grid = QtWidgets.QGridLayout()
rays_grid.addWidget(self.raystool, 0, 0, 1, 2)
rays_grid.addWidget(self.raysFig, 1, 0)
rays_grid.addWidget(sub_coverage_widget, 1, 1)
self.rays_manager.setLayout(rays_grid)
# -------Manager for RayDensityFig ------ #
self.raydensityFig = RayDensityFig(self)
self.raydensitytool = NavigationToolbar2QT(self.raydensityFig, self)
self.ray_density_manager = QtWidgets.QWidget()
ray_density_grid = QtWidgets.QGridLayout()
ray_density_grid.addWidget(self.raydensitytool, 0, 0)
ray_density_grid.addWidget(self.raydensityFig, 1, 0)
self.ray_density_manager.setLayout(ray_density_grid)
# -------Manager for ResidualsFig ------ #
self.residualsFig = ResidualsFig(self)
self.residualstool = NavigationToolbar2QT(self.residualsFig, self)
self.residuals_manager = QtWidgets.QWidget()
residuals_grid = QtWidgets.QGridLayout()
residuals_grid.addWidget(self.residualstool, 0, 0)
residuals_grid.addWidget(self.residualsFig, 1, 0)
self.residuals_manager.setLayout(residuals_grid)
# -------Manager for TomoFig ------ #
self.tomoFig = TomoFig(self)
self.tomotool = NavigationToolbar2QT(self.tomoFig, self)
self.tomo_manager = QtWidgets.QWidget()
tomo_grid = QtWidgets.QGridLayout()
tomo_grid.addWidget(self.tomotool, 0, 0)
tomo_grid.addWidget(self.tomoFig, 1, 0)
self.tomo_manager.setLayout(tomo_grid)
# -------Manager for TomoFig ------ #
self.previnvFig = PrevInvFig(self)
self.previnvtool = NavigationToolbar2QT(self.previnvFig, self)
self.prev_inv_manager = QtWidgets.QWidget()
prev_inv_grid = QtWidgets.QGridLayout()
prev_inv_grid.addWidget(self.previnvtool, 0, 0)
prev_inv_grid.addWidget(self.previnvFig, 1, 0)
self.prev_inv_manager.setLayout(prev_inv_grid)
# --- Color for the labels --- #
palette = QtGui.QPalette()
palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red)
# ------- Widgets Creation ------- #
# --- Buttons Set --- #
btn_View = QtWidgets.QPushButton("View")
btn_Delete = QtWidgets.QPushButton("Delete")
btn_Load = QtWidgets.QPushButton("Load")
btn_GO = QtWidgets.QPushButton("GO")
# - Buttons Action - #
btn_GO.clicked.connect(self.doInv)
btn_View.clicked.connect(self.view_prev)
btn_Delete.clicked.connect(self.delete_prev)
btn_Load.clicked.connect(self.load_prev)
# --- Label --- #
model_label = MyQLabel("Model :", ha='center')
cells_label = MyQLabel("Cells", ha='center')
mog_label = MyQLabel("Select Mog", ha='center')
Min_label = MyQLabel("Min", ha='right')
Max_label = MyQLabel("Max", ha='right')
Min_labeli = MyQLabel("Min :", ha='right')
Max_labeli = MyQLabel("Max :", ha='right')
X_label = MyQLabel("X", ha='center')
Y_label = MyQLabel("Y", ha='center')
Z_label = MyQLabel("Z", ha='center')
algo_label = MyQLabel("Algorithm", ha='right')
straight_ray_label = MyQLabel("Straight Rays", ha='right')
curv_ray_label = MyQLabel("Curved Rays", ha='right')
step_label = MyQLabel("Step :", ha='center')
Xi_label = MyQLabel("X", ha='center')
Yi_label = MyQLabel("Y", ha='center')
Zi_label = MyQLabel("Z", ha='center')
# These Labels are being set as attributes of the InversionUI class because they need to be modified
# depending on the model's informations
self.X_min_label = MyQLabel("0", ha='center')
self.Y_min_label = MyQLabel("0", ha='center')
self.Z_min_label = MyQLabel("0", ha='center')
self.X_max_label = MyQLabel("0", ha='center')
self.Y_max_label = MyQLabel("0", ha='center')
self.Z_max_label = MyQLabel("0", ha='center')
self.step_Xi_label = MyQLabel("0", ha='center')
self.step_Yi_label = MyQLabel("0", ha='center')
self.step_Zi_label = MyQLabel("0", ha='center')
self.num_cells_label = MyQLabel("0", ha='center')
self.algo_label = MyQLabel('', ha='right')
self.noIter_label = MyQLabel('', ha='left')
# --- Setting Label's color --- #
self.num_cells_label.setPalette(palette)
self.X_min_label.setPalette(palette)
self.Y_min_label.setPalette(palette)
self.Z_min_label.setPalette(palette)
self.X_max_label.setPalette(palette)
self.Y_max_label.setPalette(palette)
self.Z_max_label.setPalette(palette)
self.step_Xi_label.setPalette(palette)
self.step_Yi_label.setPalette(palette)
self.step_Zi_label.setPalette(palette)
cells_label.setPalette(palette)
model_label.setPalette(palette)
self.algo_label.setPalette(palette)
self.noIter_label.setPalette(palette)
# --- Edits --- #
self.straight_ray_edit = QtWidgets.QLineEdit("1") # Putting a string as the argument of the QLineEdit initializes
self.curv_ray_edit = QtWidgets.QLineEdit("1") # it to the argument
self.Min_editi = QtWidgets.QLineEdit('0.06')
self.Max_editi = QtWidgets.QLineEdit('0.12')
# - Edits' Disposition - #
self.straight_ray_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.curv_ray_edit.setAlignment(QtCore.Qt.AlignHCenter)
self.Min_editi.setAlignment(QtCore.Qt.AlignHCenter)
self.Max_editi.setAlignment(QtCore.Qt.AlignHCenter)
# - Edits' Actions - #
self.Min_editi.editingFinished.connect(self.plot_inv)
self.Max_editi.editingFinished.connect(self.plot_inv)
# --- Checkboxes --- #
self.use_const_checkbox = QtWidgets.QCheckBox("Use Constraints") # The argument of the QCheckBox is the title
self.use_Rays_checkbox = QtWidgets.QCheckBox("Use Rays") # of it
self.set_color_checkbox = QtWidgets.QCheckBox("Set Color Limits")
# - Checboxes Actions - #
self.use_const_checkbox.stateChanged.connect(self.update_params)
self.set_color_checkbox.stateChanged.connect(self.plot_inv)
# --- Actions --- #
openAction = QtWidgets.QAction('Open main data file', self)
openAction.setShortcut('Ctrl+O')
openAction.triggered.connect(self.openfile)
saveAction = QtWidgets.QAction('Save', self)
saveAction.setShortcut('Ctrl-S')
saveAction.triggered.connect(self.savefile)
exportAction = QtWidgets.QAction('Export', self)
tomoAction = QtWidgets.QAction('Tomogram', self)
tomoAction.triggered.connect(self.plot_tomo)
simulAction = QtWidgets.QAction('Simulations', self)
raysAction = QtWidgets.QAction('Rays', self)
raysAction.triggered.connect(self.plot_rays)
densityAction = QtWidgets.QAction('Ray Density', self)
densityAction.triggered.connect(self.plot_ray_density)
residAction = QtWidgets.QAction('Residuals', self)
residAction.triggered.connect(self.plot_residuals)
# --- ToolBar --- #
self.tool = QtWidgets.QMenuBar()
fileMenu = self.tool.addMenu('&File')
resultsMenu = self.tool.addMenu('&Results')
resultsMenu.addActions([exportAction, tomoAction, simulAction, raysAction, densityAction, residAction])
fileMenu.addAction(openAction)
fileMenu.addAction(saveAction)
# --- List --- #
self.mog_list = QtWidgets.QListWidget()
# - List disposition - #
self.mog_list.setFixedHeight(50)
self.mog_list.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
# - List Actions - #
self.mog_list.itemSelectionChanged.connect(self.update_params)
# --- combobox --- #
self.T_and_A_combo = QtWidgets.QComboBox()
self.prev_inversion_combo = QtWidgets.QComboBox()
self.algo_combo = QtWidgets.QComboBox()
self.fig_combo = QtWidgets.QComboBox()
# ------- Items in the comboboxes -------- #
# --- Time and Amplitude Combobox's Items --- #
self.T_and_A_combo.addItem("Traveltime")
self.T_and_A_combo.addItem("Amplitude - Peak-to-Peak")
self.T_and_A_combo.addItem("Amplitude - Centroid Frequency")
# --- Algorithm Combobox's Items --- #
self.algo_combo.addItem("LSQR Solver")
self.algo_combo.addItem("Geostatistic")
# - ComboBoxes Action - #
self.algo_combo.activated.connect(self.initinvUI)
self.fig_combo.activated.connect(self.plot_inv)
# --- Figure's ComboBox's Items --- #
list1 = ['inferno', 'seismic', 'jet', 'hsv', 'hot',
'cool', 'autumn', 'winter', 'spring', 'summer',
'gray', 'bone', 'copper', 'pink', 'prism', 'flag']
self.fig_combo.addItems(list1)
# ------- Frame for number of Iterations ------- #
iterFrame = QtWidgets.QFrame()
iterGrid = QtWidgets.QGridLayout()
iterGrid.addWidget(self.noIter_label, 0, 1)
iterGrid.addWidget(self.algo_label, 0, 0)
iterFrame.setLayout(iterGrid)
iterFrame.setStyleSheet('background: white')
# ------- SubWidgets ------- #
# --- Algo SubWidget --- #
Sub_algo_Widget = QtWidgets.QWidget()
Sub_algo_Grid = QtWidgets.QGridLayout()
Sub_algo_Grid.addWidget(algo_label, 0, 0)
Sub_algo_Grid.addWidget(self.algo_combo, 0, 1)
Sub_algo_Grid.setContentsMargins(0, 0, 0, 0)
Sub_algo_Widget.setLayout(Sub_algo_Grid)
# --- Grid Coordinates SubWidget --- #
Sub_Grid_Coord_Widget = QtWidgets.QWidget()
Sub_Grid_Coord_grid = QtWidgets.QGridLayout()
Sub_Grid_Coord_grid.addWidget(X_label, 0, 1)
Sub_Grid_Coord_grid.addWidget(Y_label, 0, 2)
Sub_Grid_Coord_grid.addWidget(Z_label, 0, 3)
Sub_Grid_Coord_grid.addWidget(Min_label, 1, 0)
Sub_Grid_Coord_grid.addWidget(Max_label, 2, 0)
Sub_Grid_Coord_grid.addWidget(self.X_min_label, 1, 1)
Sub_Grid_Coord_grid.addWidget(self.Y_min_label, 1, 2)
Sub_Grid_Coord_grid.addWidget(self.Z_min_label, 1, 3)
Sub_Grid_Coord_grid.addWidget(self.X_max_label, 2, 1)
Sub_Grid_Coord_grid.addWidget(self.Y_max_label, 2, 2)
Sub_Grid_Coord_grid.addWidget(self.Z_max_label, 2, 3)
Sub_Grid_Coord_grid.setContentsMargins(0, 0, 0, 0)
Sub_Grid_Coord_grid.setVerticalSpacing(3)
Sub_Grid_Coord_Widget.setLayout(Sub_Grid_Coord_grid)
# --- Cells SubWidget --- #
sub_cells_widget = QtWidgets.QWidget()
sub_cells_grid = QtWidgets.QGridLayout()
sub_cells_grid.addWidget(self.num_cells_label, 0, 0)
sub_cells_grid.addWidget(cells_label, 0, 1)
sub_cells_widget.setLayout(sub_cells_grid)
# --- Step SubWidget --- #
Sub_Step_Widget = QtWidgets.QWidget()
Sub_Step_Grid = QtWidgets.QGridLayout()
Sub_Step_Grid.addWidget(step_label, 1, 0)
Sub_Step_Grid.addWidget(self.step_Xi_label, 1, 1)
Sub_Step_Grid.addWidget(self.step_Yi_label, 1, 2)
Sub_Step_Grid.addWidget(self.step_Zi_label, 1, 3)
Sub_Step_Grid.addWidget(Xi_label, 0, 1)
Sub_Step_Grid.addWidget(Yi_label, 0, 2)
Sub_Step_Grid.addWidget(Zi_label, 0, 3)
Sub_Step_Grid.addWidget(sub_cells_widget, 2, 2)
Sub_Step_Grid.setContentsMargins(0, 0, 0, 0)
Sub_Step_Grid.setVerticalSpacing(3)
Sub_Step_Widget.setLayout(Sub_Step_Grid)
# --- Straight Rays SubWidget --- #
sub_straight_widget = QtWidgets.QWidget()
sub_straight_grid = QtWidgets.QGridLayout()
sub_straight_grid.addWidget(straight_ray_label, 0, 0)
sub_straight_grid.addWidget(self.straight_ray_edit, 0, 1)
sub_straight_grid.setContentsMargins(0, 0, 0, 0)
sub_straight_widget.setLayout(sub_straight_grid)
# --- Curved Rays SubWidget --- #
sub_curved_widget = QtWidgets.QWidget()
sub_curved_grid = QtWidgets.QGridLayout()
sub_curved_grid.addWidget(curv_ray_label, 0, 0)
sub_curved_grid.addWidget(self.curv_ray_edit, 0, 1)
sub_curved_grid.setContentsMargins(0, 0, 0, 0)
sub_curved_widget.setLayout(sub_curved_grid)
# ------- SubGroupboxes ------- #
# --- Data Groupbox --- #
data_groupbox = QtWidgets.QGroupBox("Data")
data_grid = QtWidgets.QGridLayout()
data_grid.addWidget(model_label, 0, 0)
data_grid.addWidget(self.T_and_A_combo, 1, 0)
data_grid.addWidget(self.use_const_checkbox, 2, 0)
data_grid.addWidget(mog_label, 0, 2)
data_grid.addWidget(self.mog_list, 1, 2, 2, 1)
data_groupbox.setLayout(data_grid)
# --- Grid Groupbox --- #
Grid_groupbox = QtWidgets.QGroupBox("Grid")
Grid_grid = QtWidgets.QGridLayout()
Grid_grid.addWidget(Sub_Grid_Coord_Widget, 0, 0)
Grid_grid.addWidget(Sub_Step_Widget, 0, 1)
Grid_groupbox.setLayout(Grid_grid)
# --- Previous Inversion Groupbox --- #
prev_inv_groupbox = QtWidgets.QGroupBox("Previous Inversions")
prev_inv_grid = QtWidgets.QGridLayout()
prev_inv_grid.addWidget(self.prev_inversion_combo, 0, 0, 1, 2)
prev_inv_grid.addWidget(btn_View, 1, 0)
prev_inv_grid.addWidget(btn_Delete, 1, 1)
prev_inv_grid.addWidget(btn_Load, 1, 2)
prev_inv_grid.addWidget(self.use_Rays_checkbox, 0, 2)
prev_inv_groupbox.setLayout(prev_inv_grid)
# --- Number of Iteration Groupbox --- #
Iter_num_groupbox = QtWidgets.QGroupBox("Number of Iterations")
Iter_num_grid = QtWidgets.QGridLayout()
Iter_num_grid.addWidget(sub_straight_widget, 0, 0)
Iter_num_grid.addWidget(sub_curved_widget, 0, 1)
Iter_num_groupbox.setLayout(Iter_num_grid)
# --- Inversion Parameters Groupbox --- #
Inv_Param_groupbox = QtWidgets.QGroupBox(" Inversion Parameters")
self.Inv_Param_grid = QtWidgets.QGridLayout()
self.Inv_Param_grid.addWidget(Sub_algo_Widget, 0, 0)
self.Inv_Param_grid.addWidget(Iter_num_groupbox, 1, 0, 1, 3)
self.Inv_Param_grid.addWidget(QtWidgets.QLabel('Place Algo Group'), 2, 0, 1, 3)
self.Inv_Param_grid.addWidget(btn_GO, 3, 1)
Inv_Param_groupbox.setLayout(self.Inv_Param_grid)
# --- Figures Groupbox --- #
fig_groupbox = QtWidgets.QGroupBox("Figures")
self.fig_grid = QtWidgets.QGridLayout()
self.fig_grid.addWidget(self.set_color_checkbox, 0, 0)
self.fig_grid.addWidget(Min_labeli, 0, 1)
self.fig_grid.addWidget(self.Min_editi, 0, 2)
self.fig_grid.addWidget(Max_labeli, 0, 3)
self.fig_grid.addWidget(self.Max_editi, 0, 4)
self.fig_grid.addWidget(self.fig_combo, 0, 5)
fig_groupbox.setLayout(self.fig_grid)
# --- Figure Groupbox dependent SubWidget --- #
Sub_right_Widget = QtWidgets.QWidget()
Sub_right_Grid = QtWidgets.QGridLayout()
Sub_right_Grid.addWidget(fig_groupbox, 0, 0)
Sub_right_Grid.setContentsMargins(0, 0, 0, 0)
Sub_right_Widget.setLayout(Sub_right_Grid)
# ------- Global Widget Disposition ------- #
global_widget = QtWidgets.QWidget()
self.global_grid = QtWidgets.QGridLayout()
self.global_grid.addWidget(data_groupbox, 0, 0, 3, 1)
self.global_grid.addWidget(Grid_groupbox, 3, 0)
self.global_grid.addWidget(prev_inv_groupbox, 5, 0)
self.global_grid.addWidget(Inv_Param_groupbox, 6, 0)
self.global_grid.addWidget(Sub_right_Widget, 0, 1)
self.global_grid.addWidget(iterFrame, 0, 2)
self.global_grid.addWidget(self.inv_frame, 1, 1, 7, 2)
self.global_grid.setColumnStretch(2, 300)
self.global_grid.setVerticalSpacing(1)
self.global_grid.setRowStretch(7, 100)
global_widget.setLayout(self.global_grid)
# ------- Master Grid Disposition ------- #
master_grid = QtWidgets.QGridLayout()
master_grid.addWidget(self.tool, 0, 0)
master_grid.addWidget(global_widget, 1, 0)
master_grid.setContentsMargins(0, 0, 0, 0)
self.setLayout(master_grid)
class InvFig(FigureCanvasQTAgg):
def __init__(self, gv, ui):
fig_width, fig_height = 4, 4
fig = mpl.figure.Figure(figsize=(fig_width, fig_height), facecolor='white')
super(InvFig, self).__init__(fig)
self.gv = gv
self.ui = ui
self.initFig()
def initFig(self):
self.ax = self.figure.add_axes([0.05, 0.06, 0.25, 0.9])
self.ax3 = self.figure.add_axes([0.375, 0.06, 0.25, 0.9])
self.ax5 = self.figure.add_axes([0.7, 0.06, 0.25, 0.9])
divider = make_axes_locatable(self.ax)
divider.append_axes('right', size=0.5, pad=0.1)
divider = make_axes_locatable(self.ax3)
divider.append_axes('right', size=0.5, pad=0.1)
divider = make_axes_locatable(self.ax5)
divider.append_axes('right', size=0.5, pad=0.1)
self.ax2 = self.figure.axes[3]
self.ax4 = self.figure.axes[4]
self.ax6 = self.figure.axes[5]
self.ax.set_visible(False)
self.ax2.set_visible(False)
self.ax3.set_visible(False)
self.ax4.set_visible(False)
self.ax5.set_visible(False)
self.ax6.set_visible(False)
def plot_lsqr_inv(self, s):
self.ax3.set_visible(True)
self.ax4.set_visible(True)
self.ax3.cla()
self.ax4.cla()
self.ax3.set_title('LSQR')
self.ax3.set_xlabel('Distance [m]')
self.ax3.set_ylabel('Elevation [m]')
self.ax4.set_title('m/ns')
grid = self.gv.grid
slowness = s.reshape((grid.grx.size - 1, grid.grz.size - 1)).T
noIter = self.gv.noIter
cmax = max(np.abs(1 / s))
cmin = min(np.abs(1 / s))
color_limits_state = self.ui.set_color_checkbox.isChecked()
cmap = self.ui.fig_combo.currentText()
if color_limits_state:
cmax = float(self.ui.Max_editi.text())
cmin = float(self.ui.Min_editi.text())
h = self.ax3.imshow(np.abs(1 / slowness), interpolation='none', cmap=cmap, vmax=cmax, vmin=cmin,
extent=[grid.grx[0], grid.grx[-1], grid.grz[-1], grid.grz[0]])
mpl.colorbar.Colorbar(self.ax4, h)
for tick in self.ax3.xaxis.get_major_ticks():
tick.label.set_fontsize(8)
tick_arrangement = set_tick_arrangement(grid)
self.ax3.set_xticks(tick_arrangement)
self.ax3.invert_yaxis()
self.draw()
class RaysFig(FigureCanvasQTAgg):
def __init__(self, ui):
fig_width, fig_height = 4, 10
fig = mpl.figure.Figure(figsize=(fig_width, fig_height), dpi=80, facecolor='white')
super(RaysFig, self).__init__(fig)
self.ui = ui
self.initFig()
def initFig(self):
self.ax = self.figure.add_axes([0.25, 0.1, 0.5, 0.85])
def plot_rays(self):
self.ax.cla()
grid = self.ui.models[self.ui.model_ind].grid