pygmi 2.2.7__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. pygmi-2.2.7/LICENSE.txt +623 -0
  2. pygmi-2.2.7/MANIFEST.in +7 -0
  3. pygmi-2.2.7/PKG-INFO +47 -0
  4. pygmi-2.2.7/README.md +55 -0
  5. pygmi-2.2.7/README.rst +20 -0
  6. pygmi-2.2.7/log.txt +242 -0
  7. pygmi-2.2.7/pygmi/__init__.py +22 -0
  8. pygmi-2.2.7/pygmi/clust/__init__.py +4 -0
  9. pygmi-2.2.7/pygmi/clust/crisp_clust.py +708 -0
  10. pygmi-2.2.7/pygmi/clust/datatypes.py +65 -0
  11. pygmi-2.2.7/pygmi/clust/fuzzy_clust.py +906 -0
  12. pygmi-2.2.7/pygmi/clust/graphs.py +421 -0
  13. pygmi-2.2.7/pygmi/clust/graphtool.py +667 -0
  14. pygmi-2.2.7/pygmi/clust/menu.py +139 -0
  15. pygmi-2.2.7/pygmi/clust/var_ratio.py +92 -0
  16. pygmi-2.2.7/pygmi/clust/xie_beni.py +93 -0
  17. pygmi-2.2.7/pygmi/helpdocs/linepointer.png +0 -0
  18. pygmi-2.2.7/pygmi/helpdocs/pygmi.main.html +31 -0
  19. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.ddisp.html +15 -0
  20. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.exportkmz.html +13 -0
  21. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.importpicture.html +16 -0
  22. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.layer.html +17 -0
  23. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.mext.html +44 -0
  24. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.misc.rangedcopy.html +16 -0
  25. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.param.html +37 -0
  26. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.prof.html +32 -0
  27. pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.pview.html +26 -0
  28. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.gradients.html +14 -0
  29. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.tilt.html +14 -0
  30. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.visibility.html +14 -0
  31. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datagrid.html +13 -0
  32. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datamerge.html +11 -0
  33. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datareproj.html +11 -0
  34. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.rtp.html +14 -0
  35. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.ginterp.html +31 -0
  36. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.igrf.html +20 -0
  37. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.normalisation.html +14 -0
  38. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.smooth.html +22 -0
  39. pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.tiltdepth.html +20 -0
  40. pygmi-2.2.7/pygmi/images/Help.png +0 -0
  41. pygmi-2.2.7/pygmi/images/bringtofront.png +0 -0
  42. pygmi-2.2.7/pygmi/images/cgs2.emf +0 -0
  43. pygmi-2.2.7/pygmi/images/delete.png +0 -0
  44. pygmi-2.2.7/pygmi/images/linepointer.png +0 -0
  45. pygmi-2.2.7/pygmi/images/logo256.ico +0 -0
  46. pygmi-2.2.7/pygmi/images/logo256.png +0 -0
  47. pygmi-2.2.7/pygmi/images/pointer.png +0 -0
  48. pygmi-2.2.7/pygmi/images/pygmi.png +0 -0
  49. pygmi-2.2.7/pygmi/images/sendtoback.png +0 -0
  50. pygmi-2.2.7/pygmi/main.py +1037 -0
  51. pygmi-2.2.7/pygmi/menu_default.py +327 -0
  52. pygmi-2.2.7/pygmi/misc.py +147 -0
  53. pygmi-2.2.7/pygmi/pfmod/__init__.py +6 -0
  54. pygmi-2.2.7/pygmi/pfmod/cubes.py +1488 -0
  55. pygmi-2.2.7/pygmi/pfmod/datatypes.py +292 -0
  56. pygmi-2.2.7/pygmi/pfmod/grvmag3d.py +1265 -0
  57. pygmi-2.2.7/pygmi/pfmod/iodefs.py +1001 -0
  58. pygmi-2.2.7/pygmi/pfmod/menu.py +107 -0
  59. pygmi-2.2.7/pygmi/pfmod/misc.py +301 -0
  60. pygmi-2.2.7/pygmi/pfmod/pfmod.py +248 -0
  61. pygmi-2.2.7/pygmi/pfmod/tab_ddisp.py +425 -0
  62. pygmi-2.2.7/pygmi/pfmod/tab_layer.py +490 -0
  63. pygmi-2.2.7/pygmi/pfmod/tab_mext.py +544 -0
  64. pygmi-2.2.7/pygmi/pfmod/tab_param.py +548 -0
  65. pygmi-2.2.7/pygmi/pfmod/tab_prof.py +946 -0
  66. pygmi-2.2.7/pygmi/pfmod/tab_pview.py +740 -0
  67. pygmi-2.2.7/pygmi/raster/IGRF11.COF +1635 -0
  68. pygmi-2.2.7/pygmi/raster/__init__.py +14 -0
  69. pygmi-2.2.7/pygmi/raster/cooper.py +718 -0
  70. pygmi-2.2.7/pygmi/raster/dataprep.py +1640 -0
  71. pygmi-2.2.7/pygmi/raster/datatypes.py +123 -0
  72. pygmi-2.2.7/pygmi/raster/equation_editor.py +256 -0
  73. pygmi-2.2.7/pygmi/raster/ginterp.py +1901 -0
  74. pygmi-2.2.7/pygmi/raster/graphs.py +531 -0
  75. pygmi-2.2.7/pygmi/raster/igrf.py +860 -0
  76. pygmi-2.2.7/pygmi/raster/iodefs.py +813 -0
  77. pygmi-2.2.7/pygmi/raster/menu.py +307 -0
  78. pygmi-2.2.7/pygmi/raster/normalisation.py +187 -0
  79. pygmi-2.2.7/pygmi/raster/show_table.py +245 -0
  80. pygmi-2.2.7/pygmi/raster/smooth.py +406 -0
  81. pygmi-2.2.7/pygmi/raster/tiltdepth.py +590 -0
  82. pygmi-2.2.7/pygmi/seis/__init__.py +0 -0
  83. pygmi-2.2.7/pygmi/seis/beachball.py +751 -0
  84. pygmi-2.2.7/pygmi/seis/datatypes.py +605 -0
  85. pygmi-2.2.7/pygmi/seis/del_rec.py +410 -0
  86. pygmi-2.2.7/pygmi/seis/iodefs.py +1261 -0
  87. pygmi-2.2.7/pygmi/seis/menu.py +136 -0
  88. pygmi-2.2.7/pygmi/seis/scan_imp.py +795 -0
  89. pygmi-2.2.7/pygmi/test/__init__.py +6 -0
  90. pygmi-2.2.7/pygmi/test/pfmod.py +212 -0
  91. pygmi-2.2.7/pygmi/test/tests.py +39 -0
  92. pygmi-2.2.7/pygmi/vector/__init__.py +7 -0
  93. pygmi-2.2.7/pygmi/vector/datatypes.py +74 -0
  94. pygmi-2.2.7/pygmi/vector/graphs.py +443 -0
  95. pygmi-2.2.7/pygmi/vector/iodefs.py +345 -0
  96. pygmi-2.2.7/pygmi/vector/menu.py +127 -0
  97. pygmi-2.2.7/pygmi.egg-info/PKG-INFO +47 -0
  98. pygmi-2.2.7/pygmi.egg-info/SOURCES.txt +105 -0
  99. pygmi-2.2.7/pygmi.egg-info/dependency_links.txt +1 -0
  100. pygmi-2.2.7/pygmi.egg-info/entry_points.txt +3 -0
  101. pygmi-2.2.7/pygmi.egg-info/not-zip-safe +1 -0
  102. pygmi-2.2.7/pygmi.egg-info/requires.txt +7 -0
  103. pygmi-2.2.7/pygmi.egg-info/top_level.txt +1 -0
  104. pygmi-2.2.7/quickstart.py +35 -0
  105. pygmi-2.2.7/setup.cfg +8 -0
  106. pygmi-2.2.7/setup.py +80 -0
@@ -0,0 +1,548 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: tab_param.py (part of PyGMI)
3
+ #
4
+ # Author: Patrick Cole
5
+ # E-Mail: pcole@geoscience.org.za
6
+ #
7
+ # Copyright: (c) 2013 Council for Geoscience
8
+ # Licence: GPL-3.0
9
+ #
10
+ # This file is part of PyGMI
11
+ #
12
+ # PyGMI is free software: you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation, either version 3 of the License, or
15
+ # (at your option) any later version.
16
+ #
17
+ # PyGMI is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ # GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License
23
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
24
+ # -----------------------------------------------------------------------------
25
+ """ Parameter Display Tab Routines """
26
+
27
+ from PyQt4 import QtGui
28
+ import numpy as np
29
+ from . import grvmag3d
30
+ from . import misc
31
+
32
+
33
+ class ParamDisplay(object):
34
+ """ Widget class to call the main interface """
35
+ def __init__(self, parent):
36
+ self.parent = parent
37
+ self.lmod1 = parent.lmod1
38
+ self.lmod2 = parent.lmod2
39
+ self.max_lith_index = -1
40
+ self.grid_stretch = 'linear'
41
+ self.showtext = parent.showtext
42
+ self.islmod1 = True
43
+
44
+ self.userint = QtGui.QWidget()
45
+
46
+ self.dsb_mht = QtGui.QDoubleSpinBox()
47
+ self.dsb_hdec = QtGui.QDoubleSpinBox()
48
+ self.dsb_hint = QtGui.QDoubleSpinBox()
49
+ self.dsb_hinc = QtGui.QDoubleSpinBox()
50
+ self.pb_autoregional = QtGui.QPushButton()
51
+ self.dsb_ght = QtGui.QDoubleSpinBox()
52
+ self.pb_apply_prop_changes = QtGui.QPushButton()
53
+ self.dsb_gregional = QtGui.QDoubleSpinBox()
54
+
55
+ self.pb_rename_def = QtGui.QPushButton()
56
+ self.pb_rem_def = QtGui.QPushButton()
57
+ self.lw_param_defs = QtGui.QListWidget()
58
+ self.pb_add_def = QtGui.QPushButton()
59
+
60
+ self.gbox_lithprops = QtGui.QGroupBox()
61
+ self.dsb_mdec = QtGui.QDoubleSpinBox()
62
+ self.dsb_density = QtGui.QDoubleSpinBox()
63
+ self.dsb_minc = QtGui.QDoubleSpinBox()
64
+ self.dsb_susc = QtGui.QDoubleSpinBox()
65
+ self.pb_apply_lith_changes = QtGui.QPushButton()
66
+ self.dsb_rmi = QtGui.QDoubleSpinBox()
67
+ self.dsb_qratio = QtGui.QDoubleSpinBox()
68
+ self.dsb_magnetization = QtGui.QDoubleSpinBox()
69
+
70
+ self.setupui()
71
+ self.init()
72
+
73
+ def setupui(self):
74
+ """ Setup UI """
75
+ verticallayout = QtGui.QVBoxLayout(self.userint)
76
+
77
+ gbox1 = QtGui.QGroupBox()
78
+ gbox2 = QtGui.QGroupBox()
79
+ glayout = QtGui.QGridLayout(gbox1)
80
+ glayout2 = QtGui.QGridLayout(gbox2)
81
+ glayout3 = QtGui.QGridLayout(self.gbox_lithprops)
82
+
83
+ label_1 = QtGui.QLabel()
84
+ label_2 = QtGui.QLabel()
85
+ label_3 = QtGui.QLabel()
86
+ label_4 = QtGui.QLabel()
87
+ label_5 = QtGui.QLabel()
88
+ label_6 = QtGui.QLabel()
89
+ label_7 = QtGui.QLabel()
90
+ label_8 = QtGui.QLabel()
91
+ label_9 = QtGui.QLabel()
92
+ label_10 = QtGui.QLabel()
93
+ label_11 = QtGui.QLabel()
94
+ label_12 = QtGui.QLabel()
95
+ label_13 = QtGui.QLabel()
96
+
97
+ self.dsb_gregional.setMinimum(-10000.0)
98
+ self.dsb_gregional.setMaximum(10000.0)
99
+ self.dsb_gregional.setSingleStep(1.0)
100
+ self.dsb_gregional.setProperty("value", 100.0)
101
+ self.dsb_ght.setMaximum(999999999.0)
102
+ self.dsb_mht.setMaximum(999999999.0)
103
+ self.dsb_mht.setProperty("value", 100.0)
104
+ self.dsb_hint.setMaximum(999999999.0)
105
+ self.dsb_hint.setProperty("value", 27000.0)
106
+ self.dsb_hinc.setMinimum(-90.0)
107
+ self.dsb_hinc.setMaximum(90.0)
108
+ self.dsb_hinc.setProperty("value", -63.0)
109
+ self.dsb_hdec.setMinimum(-360.0)
110
+ self.dsb_hdec.setMaximum(360.0)
111
+ self.dsb_hdec.setProperty("value", -17.0)
112
+
113
+ sizepolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
114
+ QtGui.QSizePolicy.Preferred)
115
+ sizepolicy.setHorizontalStretch(0)
116
+ sizepolicy.setVerticalStretch(0)
117
+ sizepolicy.setHeightForWidth(
118
+ self.lw_param_defs.sizePolicy().hasHeightForWidth())
119
+ self.lw_param_defs.setSizePolicy(sizepolicy)
120
+ self.lw_param_defs.setEditTriggers(
121
+ QtGui.QAbstractItemView.NoEditTriggers)
122
+ self.dsb_susc.setDecimals(4)
123
+ self.dsb_susc.setMaximum(999999999.0)
124
+ self.dsb_susc.setSingleStep(0.01)
125
+ self.dsb_susc.setProperty("value", 0.01)
126
+ self.dsb_rmi.setEnabled(True)
127
+ self.dsb_rmi.setDecimals(3)
128
+ self.dsb_rmi.setMaximum(999999999.0)
129
+ self.dsb_qratio.setEnabled(True)
130
+ self.dsb_qratio.setMaximum(999999999.0)
131
+ self.dsb_magnetization.setEnabled(True)
132
+ self.dsb_magnetization.setDecimals(3)
133
+ self.dsb_magnetization.setMaximum(999999999.0)
134
+ self.dsb_minc.setEnabled(True)
135
+ self.dsb_minc.setMinimum(-90.0)
136
+ self.dsb_minc.setMaximum(90.0)
137
+ self.dsb_minc.setProperty("value", -63.0)
138
+ self.dsb_mdec.setEnabled(True)
139
+ self.dsb_mdec.setMinimum(-360.0)
140
+ self.dsb_mdec.setMaximum(360.0)
141
+ self.dsb_mdec.setProperty("value", -17.0)
142
+ self.dsb_density.setDecimals(3)
143
+ self.dsb_density.setSingleStep(0.01)
144
+ self.dsb_density.setProperty("value", 2.75)
145
+
146
+ gbox1.setTitle("General Properties")
147
+ gbox2.setTitle("Lithological Properties")
148
+ label_1.setText("Gravity Regional (mgal)")
149
+ label_2.setText("Height of observation - Gravity")
150
+ label_3.setText("Height of observation - Magnetic")
151
+ label_4.setText("Magnetic Field Intensity (nT)")
152
+ label_5.setText("Magnetic Inclination")
153
+ label_6.setText("Magnetic Declination")
154
+ label_7.setText("Magnetic Susceptibility (SI)")
155
+ label_8.setText("Remanent Magnetization Intensity (nT)")
156
+ label_9.setText("Q Ratio")
157
+ label_10.setText("Remanent Magnetization (A/m)")
158
+ label_11.setText("Remanent Inclination")
159
+ label_12.setText("Remanent Declination")
160
+ label_13.setText("Density (g/cm3)")
161
+ self.gbox_lithprops.setTitle("Lithological Properties")
162
+ self.pb_apply_lith_changes.setText("Apply Changes")
163
+ self.pb_apply_prop_changes.setText("Apply Changes")
164
+ self.pb_autoregional.setText("Lithology Based Regional Estimation")
165
+ self.pb_add_def.setText("Add New Lithological Definition")
166
+ self.pb_rename_def.setText("Rename Current Definition")
167
+ self.pb_rem_def.setText("Remove Current Definition")
168
+
169
+ verticallayout.addWidget(gbox1)
170
+ verticallayout.addWidget(gbox2)
171
+ glayout.addWidget(label_1, 0, 0, 1, 1)
172
+ glayout.addWidget(self.dsb_gregional, 0, 1, 1, 1)
173
+ glayout.addWidget(self.pb_autoregional, 1, 0, 1, 2)
174
+ glayout.addWidget(label_2, 2, 0, 1, 1)
175
+ glayout.addWidget(self.dsb_ght, 2, 1, 1, 1)
176
+ glayout.addWidget(label_3, 3, 0, 1, 1)
177
+ glayout.addWidget(self.dsb_mht, 3, 1, 1, 1)
178
+ glayout.addWidget(label_4, 4, 0, 1, 1)
179
+ glayout.addWidget(self.dsb_hint, 4, 1, 1, 1)
180
+ glayout.addWidget(label_5, 5, 0, 1, 1)
181
+ glayout.addWidget(self.dsb_hinc, 5, 1, 1, 1)
182
+ glayout.addWidget(label_6, 6, 0, 1, 1)
183
+ glayout.addWidget(self.dsb_hdec, 6, 1, 1, 1)
184
+ glayout.addWidget(self.pb_apply_prop_changes, 7, 0, 1, 2)
185
+ glayout2.addWidget(self.pb_add_def, 0, 0, 1, 1)
186
+ glayout2.addWidget(self.gbox_lithprops, 0, 1, 4, 1)
187
+ glayout2.addWidget(self.lw_param_defs, 1, 0, 1, 1)
188
+ glayout2.addWidget(self.pb_rename_def, 2, 0, 1, 1)
189
+ glayout2.addWidget(self.pb_rem_def, 3, 0, 1, 1)
190
+ glayout3.addWidget(label_13, 3, 0, 1, 1)
191
+ glayout3.addWidget(self.dsb_density, 3, 1, 1, 1)
192
+ glayout3.addWidget(label_7, 4, 0, 1, 1)
193
+ glayout3.addWidget(self.dsb_susc, 4, 1, 1, 1)
194
+ glayout3.addWidget(label_8, 5, 0, 1, 1)
195
+ glayout3.addWidget(self.dsb_rmi, 5, 1, 1, 1)
196
+ glayout3.addWidget(label_10, 6, 0, 1, 1)
197
+ glayout3.addWidget(self.dsb_magnetization, 6, 1, 1, 1)
198
+ glayout3.addWidget(label_9, 7, 0, 1, 1)
199
+ glayout3.addWidget(self.dsb_qratio, 7, 1, 1, 1)
200
+ glayout3.addWidget(label_11, 8, 0, 1, 1)
201
+ glayout3.addWidget(self.dsb_minc, 8, 1, 1, 1)
202
+ glayout3.addWidget(label_12, 9, 0, 1, 1)
203
+ glayout3.addWidget(self.dsb_mdec, 9, 1, 1, 1)
204
+ glayout3.addWidget(self.pb_apply_lith_changes, 10, 0, 1, 2)
205
+
206
+ self.add_defs(deftxt='Background') # First call is for background
207
+ self.add_defs() # Second is for the first lithology type
208
+
209
+ self.lw_param_defs.currentItemChanged.connect(self.lw_index_change)
210
+ self.lw_param_defs.itemDoubleClicked.connect(self.lw_color_change)
211
+ self.pb_add_def.clicked.connect(self.add_def)
212
+ self.pb_rem_def.clicked.connect(self.rem_defs)
213
+ self.pb_rename_def.clicked.connect(self.rename_defs)
214
+ self.pb_apply_lith_changes.clicked.connect(self.apply_lith_changes)
215
+ self.pb_apply_prop_changes.clicked.connect(self.apply_prop_changes)
216
+ self.lw_param_defs.itemChanged.connect(self.change_defs)
217
+ self.dsb_susc.valueChanged.connect(self.change_qratio)
218
+ self.dsb_rmi.valueChanged.connect(self.change_rmi)
219
+ self.dsb_magnetization.valueChanged.connect(self.change_magnetization)
220
+ self.dsb_qratio.valueChanged.connect(self.change_qratio)
221
+ self.pb_autoregional.clicked.connect(self.autoregional)
222
+
223
+ def autoregional(self):
224
+ """ Automatically estimates the regional """
225
+ if 'Gravity Dataset' not in self.lmod1.griddata.keys():
226
+ self.showtext('No gravity dataset!')
227
+ return
228
+
229
+ self.parent.grvmag.calc_regional()
230
+ grvmax = self.lmod2.griddata['Calculated Gravity'].data.max()
231
+ grvmean = self.lmod1.griddata['Gravity Dataset'].data.mean()
232
+ grvreg = grvmean-grvmax
233
+ self.dsb_gregional.setValue(grvreg)
234
+
235
+ self.showtext('Regional estimated.')
236
+ # self.apply_prop_changes()
237
+
238
+ def add_defs(self, deftxt='', getcol=False, lmod=None):
239
+ """ Add geophysical definitions and make them editable"""
240
+
241
+ if lmod is not None:
242
+ self.islmod1 = False
243
+ else:
244
+ lmod = self.lmod1
245
+ self.islmod1 = True
246
+
247
+ # self.max_lith_index = len(lmod.lith_list)-1
248
+ if len(lmod.lith_list) == 0:
249
+ self.max_lith_index = -1
250
+ else:
251
+ lmod.update_lith_list_reverse()
252
+ self.max_lith_index = max(lmod.lith_list_reverse.keys())
253
+
254
+ defnum = self.lw_param_defs.count()
255
+ if deftxt == '':
256
+ deftxt = 'Generic '+str(defnum)
257
+
258
+ # self.lw_param_defs.addItem(deftxt)
259
+ # self.lw_3dmod_defs.addItem(deftxt)
260
+ # self.lw_prof_defs.addItem(deftxt)
261
+ # self.lw_editor_defs.addItem(deftxt)
262
+
263
+ lmod.lith_list[deftxt] = grvmag3d.GeoData(
264
+ self.parent, lmod.numx, lmod.numy, lmod.numz, lmod.dxy, lmod.d_z,
265
+ lmod.mht, lmod.ght)
266
+
267
+ litho = lmod.lith_list['Background']
268
+ lithn = lmod.lith_list[deftxt]
269
+ lithn.hintn = litho.hintn
270
+ lithn.finc = litho.finc
271
+ lithn.fdec = litho.fdec
272
+ lithn.zobsm = litho.zobsm
273
+ lithn.bdensity = litho.bdensity
274
+ lithn.zobsg = litho.zobsg
275
+
276
+ self.max_lith_index += 1
277
+ lithn.lith_index = self.max_lith_index
278
+
279
+ if deftxt == 'Background':
280
+ lithn.susc = 0
281
+ lithn.density = lithn.bdensity
282
+
283
+ if getcol is True:
284
+ col = QtGui.QColorDialog.getColor()
285
+ lmod.mlut[lithn.lith_index] = [col.red(), col.green(), col.blue()]
286
+
287
+ # setup list widgets
288
+ # tmpitem = self.lw_param_defs.item(defnum)
289
+ # tmpitem.setFlags(tmpitem.flags() | QtCore.Qt.ItemIsEditable)
290
+ misc.update_lith_lw(self.lmod1, self.lw_param_defs)
291
+
292
+ # self.set_lw_colors(self.lw_param_defs, lmod)
293
+ # self.set_lw_colors(self.lw_3dmod_defs, lmod)
294
+ # self.set_lw_colors(self.lw_editor_defs, lmod)
295
+ # self.set_lw_colors(self.lw_prof_defs, lmod)
296
+
297
+ if defnum == 0:
298
+ lithn.susc = 0
299
+ lithn.density = lithn.bdensity
300
+
301
+ self.lw_index_change()
302
+
303
+ def apply_prop_changes(self):
304
+ """ Applies geophysical property changes """
305
+
306
+ self.lmod1.gregional = self.dsb_gregional.value()
307
+ self.lmod1.mht = self.dsb_mht.value()
308
+ self.lmod1.ght = self.dsb_ght.value()
309
+ self.lmod1.clith_index[:] = 0
310
+ for lith in list(self.lmod1.lith_list.values()):
311
+ lith.zobsg = -self.dsb_ght.value()
312
+ lith.zobsm = -self.dsb_mht.value()
313
+ lith.hintn = self.dsb_hint.value()
314
+ lith.finc = self.dsb_hinc.value()
315
+ lith.fdec = self.dsb_hdec.value()
316
+ lith.modified = True
317
+ self.showtext('Geophysical properties applied.')
318
+
319
+ def apply_lith_changes(self):
320
+ """ Applies lithological changes """
321
+
322
+ self.lmod1.clith_index[:] = 0
323
+ lith = self.get_lith()
324
+ lith.density = self.dsb_density.value()
325
+ if lith == self.lmod1.lith_list['Background']:
326
+ for lith in list(self.lmod1.lith_list.values()):
327
+ lith.bdensity = self.dsb_density.value()
328
+ lith.susc = self.dsb_susc.value()
329
+ lith.mstrength = self.dsb_magnetization.value()
330
+ lith.mdec = self.dsb_mdec.value()
331
+ lith.minc = self.dsb_minc.value()
332
+ lith.qratio = self.dsb_qratio.value()
333
+ lith.modified = True
334
+ self.showtext('Lithological changes applied.')
335
+
336
+ def change_rmi(self):
337
+ """ update spinboxes when rmi is changed """
338
+ rmi = self.dsb_rmi.value()
339
+ susc = self.dsb_susc.value()
340
+ hintn = self.dsb_hint.value()
341
+
342
+ mstrength = rmi/(400*np.pi)
343
+ qratio = rmi/(susc*hintn)
344
+
345
+ self.disconnect_spin()
346
+ self.dsb_magnetization.setValue(mstrength)
347
+ self.dsb_qratio.setValue(qratio)
348
+ self.connect_spin()
349
+
350
+ def change_magnetization(self):
351
+ """ update spinboxes when magnetization is changed """
352
+ mstrength = self.dsb_magnetization.value()
353
+ susc = self.dsb_susc.value()
354
+ hintn = self.dsb_hint.value()
355
+
356
+ rmi = 400*np.pi*mstrength
357
+ if susc != 0.0:
358
+ qratio = rmi/(susc*hintn)
359
+ else:
360
+ qratio = 0.0
361
+
362
+ self.disconnect_spin()
363
+ self.dsb_rmi.setValue(rmi)
364
+ self.dsb_qratio.setValue(qratio)
365
+ self.connect_spin()
366
+
367
+ def change_qratio(self):
368
+ """ update spinboxes when qratio is changed """
369
+ qratio = self.dsb_qratio.value()
370
+ susc = self.dsb_susc.value()
371
+ hintn = self.dsb_hint.value()
372
+
373
+ rmi = qratio*susc*hintn
374
+ mstrength = rmi/(400*np.pi)
375
+
376
+ self.disconnect_spin()
377
+ self.dsb_rmi.setValue(rmi)
378
+ self.dsb_magnetization.setValue(mstrength)
379
+ self.connect_spin()
380
+
381
+ def disconnect_spin(self):
382
+ """ Disconnect spin boxes """
383
+ self.dsb_susc.valueChanged.disconnect()
384
+ self.dsb_rmi.valueChanged.disconnect()
385
+ self.dsb_magnetization.valueChanged.disconnect()
386
+ self.dsb_qratio.valueChanged.disconnect()
387
+
388
+ def connect_spin(self):
389
+ """ Connect spin boxes """
390
+ self.dsb_susc.valueChanged.connect(self.change_qratio)
391
+ self.dsb_rmi.valueChanged.connect(self.change_rmi)
392
+ self.dsb_magnetization.valueChanged.connect(self.change_magnetization)
393
+ self.dsb_qratio.valueChanged.connect(self.change_qratio)
394
+
395
+ def change_defs(self, item):
396
+ """ Change geophysical definitions """
397
+ if self.islmod1 is False:
398
+ return
399
+ itxt = item.text()
400
+ itxtlist = []
401
+ for i in range(self.lw_param_defs.count()):
402
+ itxtlist.append(str(self.lw_param_defs.item(i).text()))
403
+
404
+ for i in self.lmod1.lith_list.keys():
405
+ if i not in itxtlist:
406
+ if i == 'Background':
407
+ j = self.lw_param_defs.currentRow()
408
+ self.lw_param_defs.item(j).setText(i)
409
+ else:
410
+ self.lmod1.lith_list[itxt] = self.lmod1.lith_list[i]
411
+ self.lmod1.lith_list.pop(i)
412
+ # self.lw_3dmod_defs.findItems(i,
413
+ # QtCore.Qt.MatchExactly)[0].setText(itxt)
414
+ # self.lw_prof_defs.findItems(i,
415
+ # QtCore.Qt.MatchExactly)[0].setText(itxt)
416
+ # self.lw_editor_defs.findItems(i,
417
+ # QtCore.Qt.MatchExactly)[0].setText(itxt)
418
+
419
+ def get_lith(self):
420
+ """ Get parameter definitions """
421
+ i = self.lw_param_defs.currentRow()
422
+ if i == -1:
423
+ i = 0
424
+ itxt = str(self.lw_param_defs.item(i).text())
425
+ lith = self.lmod1.lith_list[itxt]
426
+ return lith
427
+
428
+ def init(self):
429
+ """ Initialize parameters """
430
+ # Magetic Parameters
431
+ self.dsb_hdec.setValue(-17.5)
432
+ self.dsb_hinc.setValue(-62.9)
433
+ self.dsb_hint.setValue(28464.0)
434
+ self.dsb_mht.setValue(100.0)
435
+ self.dsb_susc.setValue(0.01)
436
+
437
+ # Remanence Parameters
438
+ self.dsb_minc.setValue(-62.9)
439
+ self.dsb_mdec.setValue(-17.5)
440
+
441
+ # Gravity Parameters
442
+ self.dsb_ght.setValue(0.0)
443
+ self.dsb_density.setValue(2.75)
444
+ self.dsb_gregional.setValue(100.00)
445
+
446
+ # Body Parameters
447
+ self.dsb_mdec.setValue(0.0)
448
+ self.dsb_minc.setValue(0.0)
449
+
450
+ def lw_color_change(self):
451
+ """ Routine to allow lithologies to have their colors changed """
452
+ ctxt = str(self.lw_param_defs.currentItem().text())
453
+ col = QtGui.QColorDialog.getColor()
454
+
455
+ lithi = self.lmod1.lith_list[ctxt].lith_index
456
+
457
+ self.lmod1.mlut[lithi] = [col.red(), col.green(), col.blue()]
458
+ self.set_lw_colors(self.lw_param_defs)
459
+
460
+ def lw_index_change(self):
461
+ """ List box in parameter tab for definitions """
462
+ i = self.lw_param_defs.currentRow()
463
+ if i == -1:
464
+ i = 0
465
+ itxt = str(self.lw_param_defs.item(i).text())
466
+ lith = self.lmod1.lith_list[itxt]
467
+
468
+ self.dsb_hint.setValue(lith.hintn)
469
+ self.dsb_hinc.setValue(lith.finc)
470
+ self.dsb_hdec.setValue(lith.fdec)
471
+ self.dsb_mht.setValue(-lith.zobsm)
472
+ self.dsb_susc.setValue(lith.susc)
473
+ self.dsb_magnetization.setValue(lith.mstrength)
474
+ self.dsb_qratio.setValue(lith.qratio)
475
+ self.dsb_minc.setValue(lith.minc)
476
+ self.dsb_mdec.setValue(lith.mdec)
477
+ self.dsb_density.setValue(lith.density)
478
+ self.dsb_ght.setValue(-lith.zobsg)
479
+
480
+ self.gbox_lithprops.setTitle('Lithological Properties - ' + itxt)
481
+
482
+ def add_def(self):
483
+ """ Routine being called by button push """
484
+ self.add_defs(getcol=True)
485
+
486
+ def rem_defs(self):
487
+ """ Remove geophysical definitions """
488
+ crow = self.lw_param_defs.currentRow()
489
+ if crow == -1:
490
+ return
491
+ ctxt = str(self.lw_param_defs.currentItem().text())
492
+ if ctxt == 'Background':
493
+ self.showtext('You cannot delete the background lithology')
494
+ return
495
+
496
+ if self.lw_param_defs.count() <= 2:
497
+ self.showtext('You must have at least two lithologies')
498
+ return
499
+
500
+ # self.lw_param_defs.takeItem(crow)
501
+ # self.lw_3dmod_defs.takeItem(crow)
502
+ # self.lw_prof_defs.takeItem(crow)
503
+ # self.lw_editor_defs.takeItem(crow)
504
+
505
+ lind = self.lmod1.lith_list[ctxt].lith_index
506
+ del self.lmod1.lith_list[ctxt]
507
+ self.lmod1.lith_index[self.lmod1.lith_index == lind] = 0
508
+ self.lw_param_defs.takeItem(crow)
509
+
510
+ misc.update_lith_lw(self.lmod1, self.lw_param_defs)
511
+
512
+ def rename_defs(self):
513
+ """ Used to rename a definition """
514
+
515
+ crow = self.lw_param_defs.currentRow()
516
+ if crow == -1:
517
+ return
518
+
519
+ ctxt = str(self.lw_param_defs.currentItem().text())
520
+
521
+ (skey, isokay) = QtGui.QInputDialog.getText(
522
+ self.parent, 'Rename Definition',
523
+ 'Please type in the new name for the definition',
524
+ QtGui.QLineEdit.Normal, ctxt)
525
+
526
+ if isokay:
527
+ self.lw_param_defs.currentItem().setText(skey)
528
+
529
+ self.change_defs(self.lw_param_defs.currentItem())
530
+
531
+ def set_lw_colors(self, lwidget, lmod=None):
532
+ """ Set list widget colors """
533
+ if lmod is None:
534
+ lmod = self.lmod1
535
+ for i in range(lwidget.count()):
536
+ tmp = lwidget.item(i)
537
+ tindex = lmod.lith_list[tmp.text()].lith_index
538
+ tcol = lmod.mlut[tindex]
539
+ tmp.setBackground(QtGui.QColor(tcol[0], tcol[1], tcol[2], 255))
540
+
541
+ def tab_activate(self):
542
+ """ Runs when the tab is activated """
543
+ self.lmod1 = self.parent.lmod1
544
+ misc.update_lith_lw(self.lmod1, self.lw_param_defs)
545
+ # Need this to init the first values.
546
+ self.lw_index_change()
547
+ self.dsb_gregional.setValue(self.lmod1.gregional)
548
+ # self.parent.mext.update_vals()