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,107 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: menu.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
+ """ Potential Field Modelling """
26
+
27
+ from PyQt4 import QtGui
28
+ from . import pfmod
29
+ from . import cubes as mvis3d
30
+ from . import iodefs
31
+
32
+
33
+ class MenuWidget(object):
34
+ """
35
+ Widget class to call the main interface
36
+
37
+ This widget class creates the modelling menus to be found on the main
38
+ interface. Normal as well as context menus are defined here.
39
+
40
+ Attributes
41
+ ----------
42
+ parent : MainWidget
43
+ Reference to MainWidget class found in main.py
44
+ """
45
+ def __init__(self, parent):
46
+
47
+ self.parent = parent
48
+ self.parent.add_to_context('Model3D')
49
+ context_menu = self.parent.context_menu
50
+
51
+ # Normal menus
52
+ self.menu = QtGui.QMenu(parent.menubar)
53
+ self.menu.setTitle("Potential Field Modelling")
54
+ parent.menubar.addAction(self.menu.menuAction())
55
+
56
+ self.action_import_mod3d = QtGui.QAction(parent)
57
+ self.action_import_mod3d.setText("Import 3D Model")
58
+ self.menu.addAction(self.action_import_mod3d)
59
+ self.action_import_mod3d.triggered.connect(self.import_mod3d)
60
+
61
+ self.action_prof_pic = QtGui.QAction(parent)
62
+ self.action_prof_pic.setText("Import Profile Picture")
63
+ self.menu.addAction(self.action_prof_pic)
64
+ self.action_prof_pic.triggered.connect(self.import_prof_pic)
65
+
66
+ self.menu.addSeparator()
67
+
68
+ self.action_pfmod = QtGui.QAction(self.parent)
69
+ self.action_pfmod.setText("Model Creation and Editing")
70
+ self.menu.addAction(self.action_pfmod)
71
+ self.action_pfmod.triggered.connect(self.pfmod)
72
+
73
+ # Context Menu
74
+ context_menu['Model3D'].addSeparator()
75
+
76
+ self.action_mod3d = QtGui.QAction(self.parent)
77
+ self.action_mod3d.setText("3D Model Display")
78
+ context_menu['Model3D'].addAction(self.action_mod3d)
79
+ self.action_mod3d.triggered.connect(self.mod3d)
80
+
81
+ self.action_export_mod3d = QtGui.QAction(self.parent)
82
+ self.action_export_mod3d.setText("Export 3D Model")
83
+ context_menu['Model3D'].addAction(self.action_export_mod3d)
84
+ self.action_export_mod3d.triggered.connect(self.export_mod3d)
85
+
86
+ def export_mod3d(self):
87
+ """ Export 3D Model """
88
+ self.parent.launch_context_item(iodefs.ExportMod3D)
89
+
90
+ def pfmod(self):
91
+ """ voxel modelling of data"""
92
+ fnc = pfmod.MainWidget(self.parent)
93
+ self.parent.item_insert("Step", "Potential\nField\nModelling", fnc)
94
+
95
+ def mod3d(self):
96
+ """ 3D display of data"""
97
+ self.parent.launch_context_item(mvis3d.Mod3dDisplay)
98
+
99
+ def import_mod3d(self):
100
+ """ Imports data"""
101
+ fnc = iodefs.ImportMod3D(self.parent)
102
+ self.parent.item_insert("Io", "Import 3D Model", fnc)
103
+
104
+ def import_prof_pic(self):
105
+ """ Imports data"""
106
+ fnc = iodefs.ImportPicture(self.parent)
107
+ self.parent.item_insert("Io", "Import Profile\n Picture", fnc)
@@ -0,0 +1,301 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: misc.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
+ """ These are miscellaneous functions for the program """
26
+
27
+ from PyQt4 import QtGui, QtCore
28
+ import pygmi.menu_default as menu_default
29
+ import time
30
+
31
+
32
+ def update_lith_lw(lmod, lwidget):
33
+ """ Updates the lithology list widget """
34
+ lwidget.clear()
35
+ for i in lmod.lith_list.keys():
36
+ lwidget.addItem(i)
37
+
38
+ for i in range(lwidget.count()):
39
+ tmp = lwidget.item(i)
40
+ tindex = lmod.lith_list[str(tmp.text())].lith_index
41
+ tcol = lmod.mlut[tindex]
42
+ tmp.setBackground(QtGui.QColor(tcol[0], tcol[1], tcol[2], 255))
43
+
44
+
45
+ class RangedCopy(QtGui.QDialog):
46
+ """ Class to call up a dialog for ranged copying """
47
+ def __init__(self, parent=None):
48
+ QtGui.QDialog.__init__(self, parent)
49
+
50
+ self.sb_master = QtGui.QSpinBox()
51
+ self.sb_start = QtGui.QSpinBox()
52
+ self.lw_lithdel = QtGui.QListWidget()
53
+ self.lw_lithcopy = QtGui.QListWidget()
54
+ self.sb_end = QtGui.QSpinBox()
55
+
56
+ self.setupui()
57
+
58
+ def setupui(self):
59
+ """ Setup UI """
60
+ gridlayout = QtGui.QGridLayout(self)
61
+ buttonbox = QtGui.QDialogButtonBox()
62
+ helpdocs = menu_default.HelpButton('pygmi.pfmod.misc.rangedcopy')
63
+
64
+ label = QtGui.QLabel()
65
+ label_2 = QtGui.QLabel()
66
+ label_3 = QtGui.QLabel()
67
+ label_4 = QtGui.QLabel()
68
+ label_5 = QtGui.QLabel()
69
+
70
+ self.sb_master.setMaximum(999999999)
71
+ self.sb_start.setMaximum(999999999)
72
+ self.lw_lithcopy.setSelectionMode(self.lw_lithcopy.MultiSelection)
73
+ self.lw_lithdel.setSelectionMode(self.lw_lithdel.MultiSelection)
74
+ buttonbox.setOrientation(QtCore.Qt.Horizontal)
75
+ buttonbox.setStandardButtons(buttonbox.Cancel | buttonbox.Ok)
76
+ self.sb_end.setMaximum(999999999)
77
+
78
+ self.setWindowTitle("Ranged Copy")
79
+ label.setText("Range Start")
80
+ label_2.setText("Master Profile")
81
+ label_3.setText("Lithologies To Copy")
82
+ label_4.setText("Lithologies To Overwrite")
83
+ label_5.setText("Range End")
84
+
85
+ gridlayout.addWidget(label_2, 0, 0, 1, 1)
86
+ gridlayout.addWidget(self.sb_master, 0, 1, 1, 1)
87
+ gridlayout.addWidget(label, 1, 0, 1, 1)
88
+ gridlayout.addWidget(self.sb_start, 1, 1, 1, 1)
89
+ gridlayout.addWidget(label_5, 2, 0, 1, 1)
90
+ gridlayout.addWidget(self.sb_end, 2, 1, 1, 1)
91
+ gridlayout.addWidget(label_3, 3, 0, 1, 1)
92
+ gridlayout.addWidget(self.lw_lithcopy, 3, 1, 1, 1)
93
+ gridlayout.addWidget(label_4, 4, 0, 1, 1)
94
+ gridlayout.addWidget(self.lw_lithdel, 4, 1, 1, 1)
95
+ gridlayout.addWidget(helpdocs, 5, 0, 1, 1)
96
+ gridlayout.addWidget(buttonbox, 5, 1, 1, 1)
97
+
98
+ buttonbox.accepted.connect(self.accept)
99
+ buttonbox.rejected.connect(self.reject)
100
+
101
+
102
+ def rcopy_dialog(lmod1, islayer=True, is_ew=True):
103
+ """ Main routine to perform actual ranged copy """
104
+ rcopy = RangedCopy()
105
+ for i in lmod1.lith_list.keys():
106
+ rcopy.lw_lithcopy.addItem(i)
107
+ rcopy.lw_lithdel.addItem(i)
108
+
109
+ if islayer is True:
110
+ rmax = lmod1.numz-1
111
+ elif is_ew is True:
112
+ rmax = lmod1.numy-1
113
+ else:
114
+ rmax = lmod1.numx-1
115
+
116
+ rcopy.sb_start.setMaximum(rmax)
117
+ rcopy.sb_end.setMaximum(rmax)
118
+ rcopy.sb_end.setValue(rmax)
119
+
120
+ if islayer is True:
121
+ rcopy.sb_master.setValue(lmod1.curlayer)
122
+ else:
123
+ rcopy.sb_master.setValue(lmod1.curprof)
124
+
125
+ tmp = rcopy.exec_()
126
+ if tmp == 0:
127
+ return
128
+
129
+ lithcopy = rcopy.lw_lithcopy.selectedItems()
130
+ lithdel = rcopy.lw_lithdel.selectedItems()
131
+ lstart = rcopy.sb_start.value()
132
+ lend = rcopy.sb_end.value()
133
+ lmaster = rcopy.sb_master.value()
134
+
135
+ if lstart > lend:
136
+ lstart, lend = lend, lstart
137
+
138
+ if islayer is True:
139
+ mtmp = lmod1.lith_index[:, :, lmaster]
140
+ if lend > lmod1.numz:
141
+ lend = lmod1.numz
142
+ else:
143
+ if is_ew is True:
144
+ mtmp = lmod1.lith_index[:, lmaster, ::-1]
145
+ if lend > lmod1.numy:
146
+ lend = lmod1.numy
147
+ else:
148
+ mtmp = lmod1.lith_index[lmaster, :, ::-1]
149
+ if lend > lmod1.numx:
150
+ lend = lmod1.numx
151
+
152
+ mslice = mtmp * 0
153
+ for i in lithcopy:
154
+ mslice[mtmp == lmod1.lith_list[i.text()].lith_index] = 1
155
+
156
+ for i in range(lstart, lend+1):
157
+ if islayer is True:
158
+ ltmp = lmod1.lith_index[:, :, i]
159
+ else:
160
+ if is_ew is True:
161
+ ltmp = lmod1.lith_index[:, i, ::-1]
162
+ else:
163
+ ltmp = lmod1.lith_index[i, :, ::-1]
164
+
165
+ lslice = ltmp * 0
166
+ for j in lithdel:
167
+ lslice[ltmp == lmod1.lith_list[j.text()].lith_index] = 1
168
+ mlslice = mslice + lslice
169
+ mlslice[mlslice == 1] = 0
170
+ mlslice[mlslice > 0] = 1
171
+ mtmp2 = mtmp.copy()
172
+ mtmp2[mlslice == 0] = 0
173
+ ltmp[mlslice == 1] = 0
174
+ ltmp += mtmp2
175
+
176
+
177
+ class ProgressBar(object):
178
+ """ Wrapper for a progress bar """
179
+ def __init__(self, pbar, pbarmain):
180
+ self.pbar = pbar
181
+ self.pbarmain = pbarmain
182
+ self.max = 1
183
+ self.value = 0
184
+ self.mmax = 1
185
+ self.mvalue = 0
186
+ self.otime = None
187
+ self.mtime = None
188
+ self.resetall()
189
+
190
+ def incr(self):
191
+ """ increases value by one """
192
+ if self.value < self.max:
193
+ self.value += 1
194
+ if self.value == self.max and self.mvalue < self.mmax:
195
+ self.mvalue += 1
196
+ self.value = 0
197
+ self.pbarmain.setValue(self.mvalue)
198
+ if self.mvalue == self.mmax:
199
+ self.value = self.max
200
+ self.pbar.setValue(self.value)
201
+
202
+ QtCore.QCoreApplication.processEvents()
203
+
204
+ def iter(self, iterable):
205
+ """
206
+ Iterator Routine
207
+ """
208
+ total = len(iterable)
209
+ self.max = total
210
+ self.pbar.setMaximum(total)
211
+ self.pbar.setMinimum(0)
212
+ self.pbar.setValue(0)
213
+
214
+ self.otime = time.clock()
215
+ time1 = self.otime
216
+ time2 = self.otime
217
+
218
+ n = 0
219
+ for obj in iterable:
220
+ yield obj
221
+ n += 1
222
+
223
+ time2 = time.clock()
224
+ if time2-time1 > 1:
225
+ self.pbar.setValue(n)
226
+ tleft = (total-n)*(time2-self.otime)/n
227
+ if tleft > 60:
228
+ tleft = int(tleft // 60)
229
+ self.pbar.setFormat('%p% '+str(tleft)+'min left')
230
+ else:
231
+ tleft = int(tleft)
232
+ self.pbar.setFormat('%p% '+str(tleft)+'s left')
233
+ QtGui.QApplication.processEvents()
234
+ time1 = time2
235
+
236
+ self.pbar.setFormat('%p%')
237
+ self.pbar.setValue(total)
238
+
239
+ self.incrmain()
240
+ self.value = 0
241
+ QtGui.QApplication.processEvents()
242
+
243
+ def incrmain(self, i=1):
244
+ """ increases value by one """
245
+ self.mvalue += i
246
+ self.pbarmain.setValue(self.mvalue)
247
+
248
+ n = self.mvalue
249
+ total = self.mmax
250
+ tleft = (total-n)*(time.clock()-self.mtime)/n
251
+ if tleft > 60:
252
+ tleft = int(tleft // 60)
253
+ self.pbarmain.setFormat('%p% '+str(tleft)+'min left')
254
+ else:
255
+ tleft = int(tleft)
256
+ self.pbarmain.setFormat('%p% '+str(tleft)+'s left')
257
+ QtGui.QApplication.processEvents()
258
+
259
+ def maxall(self):
260
+ """ Sets all progress bars to maximum value """
261
+ self.mvalue = self.mmax
262
+ self.value = self.max
263
+ self.pbarmain.setValue(self.mvalue)
264
+ self.pbar.setValue(self.value)
265
+ self.pbar.setFormat('%p%')
266
+ self.pbarmain.setFormat('%p%')
267
+
268
+ def resetall(self, maximum=1, mmax=1):
269
+ """ Sets min and max and resets all bars to 0 """
270
+
271
+ self.pbar.setFormat('%p%')
272
+ self.pbarmain.setFormat('%p%')
273
+ self.mtime = time.clock()
274
+
275
+ self.max = maximum
276
+ self.value = 0
277
+ self.mmax = mmax
278
+ self.mvalue = 0
279
+ self.pbar.setMinimum(self.value)
280
+ self.pbar.setMaximum(self.max)
281
+ self.pbar.setValue(self.value)
282
+ self.pbarmain.setMinimum(self.mvalue)
283
+ self.pbarmain.setMaximum(self.mmax)
284
+ self.pbarmain.setValue(self.mvalue)
285
+
286
+ def resetsub(self, maximum=1):
287
+ """ Sets min and max and resets sub bar to 0 """
288
+
289
+ self.pbar.setFormat('%p%')
290
+ self.max = maximum
291
+ self.value = 0
292
+ self.pbar.setMinimum(self.value)
293
+ self.pbar.setMaximum(self.max)
294
+ self.pbar.setValue(self.value)
295
+
296
+ def busysub(self):
297
+ """ Busy """
298
+ self.pbar.setMinimum(0)
299
+ self.pbar.setMaximum(0)
300
+ self.pbar.setValue(-1)
301
+ QtCore.QCoreApplication.processEvents()
@@ -0,0 +1,248 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: pfmod.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
+ """ This is the main program for the modelling package """
26
+
27
+ from PyQt4 import QtGui, QtCore
28
+
29
+ # Other dependancies
30
+ from . import misc
31
+ from . import tab_ddisp
32
+ from . import tab_layer
33
+ from . import tab_prof
34
+ from . import tab_pview
35
+ from . import tab_param
36
+ from . import tab_mext
37
+ from . import grvmag3d
38
+ from . import iodefs
39
+ from .datatypes import LithModel
40
+ import pygmi.menu_default as menu_default
41
+ import pygmi.misc as pmisc
42
+
43
+
44
+ class MainWidget(QtGui.QMainWindow):
45
+ """ Widget class to call the main interface """
46
+ def __init__(self, parent=None):
47
+ QtGui.QMainWindow.__init__(self, parent)
48
+
49
+ self.indata = {}
50
+ self.inraster = {}
51
+ self.outdata = {}
52
+ self.parent = parent
53
+ self.showprocesslog = self.parent.showprocesslog
54
+ self.lmod1 = LithModel() # actual model
55
+ self.lmod2 = LithModel() # regional model
56
+
57
+ # General
58
+ self.txtmsg = ''
59
+ self.modelfilename = r'./tmp'
60
+
61
+ self.toolbar = QtGui.QToolBar()
62
+ self.statusbar = QtGui.QStatusBar()
63
+ self.tabwidget = QtGui.QTabWidget()
64
+ self.pbar_sub = pmisc.ProgressBar()
65
+ self.pbar_main = pmisc.ProgressBar()
66
+ self.textbrowser = QtGui.QTextBrowser()
67
+ self.actionsave = QtGui.QPushButton()
68
+
69
+ self.tabwidget.setCurrentIndex(0)
70
+ self.oldtab = self.tabwidget.tabText(0)
71
+ self.pbars = misc.ProgressBar(self.pbar_sub, self.pbar_main)
72
+ self.outdata['Raster'] = list(self.lmod1.griddata.values())
73
+
74
+ # Model Extent Tab
75
+ self.mext = tab_mext.MextDisplay(self)
76
+ self.tabwidget.addTab(self.mext.userint, "Model Extent Parameters")
77
+
78
+ # Geophysical Parameters Tab
79
+ self.param = tab_param.ParamDisplay(self)
80
+ self.tabwidget.addTab(self.param.userint, "Geophysical Parameters")
81
+
82
+ # Data Display Tab
83
+ self.ddisp = tab_ddisp.DataDisplay(self)
84
+ self.tabwidget.addTab(self.ddisp.userint, "Data Display")
85
+
86
+ # Layer Editor Tab
87
+ self.layer = tab_layer.LayerDisplay(self)
88
+ self.tabwidget.addTab(self.layer.userint, "Layer Editor")
89
+
90
+ # Profile Editor Tab
91
+ self.profile = tab_prof.ProfileDisplay(self)
92
+ self.tabwidget.addTab(self.profile.userint, "Profile Editor")
93
+
94
+ # Profile Viewer Tab
95
+ self.pview = tab_pview.ProfileDisplay(self)
96
+ self.tabwidget.addTab(self.pview.userint, "Custom Profile Editor")
97
+
98
+ # Gravity and magnetic modelling routines
99
+ self.grvmag = grvmag3d.GravMag(self)
100
+
101
+ self.setupui()
102
+
103
+ def setupui(self):
104
+ """ Setup for the GUI """
105
+ centralwidget = QtGui.QWidget(self)
106
+ verticallayout = QtGui.QVBoxLayout(centralwidget)
107
+ hlayout = QtGui.QHBoxLayout()
108
+
109
+ helpdocs = menu_default.HelpButton()
110
+
111
+ self.setCentralWidget(centralwidget)
112
+ self.resize(1024, 768)
113
+ self.toolbar.setStyleSheet('QToolBar{spacing:10px;}')
114
+ self.setStatusBar(self.statusbar)
115
+ self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolbar)
116
+ self.textbrowser.setFrameShape(QtGui.QFrame.StyledPanel)
117
+ # self.pbar_sub.setTextVisible(False)
118
+ # self.pbar_main.setTextVisible(False)
119
+ self.toolbar.setMovable(True)
120
+ self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
121
+ self.toolbar.addWidget(self.actionsave)
122
+
123
+ self.setWindowTitle("Potential Field Modelling")
124
+ self.actionsave.setText("Save Model")
125
+
126
+ hlayout.addWidget(self.textbrowser)
127
+ hlayout.addWidget(helpdocs)
128
+ verticallayout.addWidget(self.tabwidget)
129
+ verticallayout.addLayout(hlayout)
130
+ verticallayout.addWidget(self.pbar_sub)
131
+ verticallayout.addWidget(self.pbar_main)
132
+
133
+ helpdocs.clicked.disconnect()
134
+ helpdocs.clicked.connect(self.help_docs)
135
+ self.actionsave.clicked.connect(self.savemodel)
136
+ self.tabwidget.currentChanged.connect(self.tab_change)
137
+
138
+ def savemodel(self):
139
+ """ Model Save """
140
+ tmp = iodefs.ExportMod3D(self)
141
+ tmp.indata = self.outdata
142
+ tmp.run()
143
+
144
+ del tmp
145
+
146
+ def help_docs(self):
147
+ """
148
+ Help Routine
149
+ """
150
+ index = self.tabwidget.currentIndex()
151
+ htmlfile = ''
152
+
153
+ if self.tabwidget.tabText(index) == 'Geophysical Parameters':
154
+ htmlfile += 'pygmi.pfmod.param'
155
+
156
+ if self.tabwidget.tabText(index) == 'Model Extent Parameters':
157
+ htmlfile += 'pygmi.pfmod.mext'
158
+
159
+ if self.tabwidget.tabText(index) == 'Profile Editor':
160
+ htmlfile += 'pygmi.pfmod.prof'
161
+
162
+ if self.tabwidget.tabText(index) == 'Custom Profile Editor':
163
+ htmlfile += 'pygmi.pfmod.pview'
164
+
165
+ if self.tabwidget.tabText(index) == 'Layer Editor':
166
+ htmlfile += 'pygmi.pfmod.layer'
167
+
168
+ if self.tabwidget.tabText(index) == 'Data Display':
169
+ htmlfile += 'pygmi.pfmod.ddisp'
170
+
171
+ menu_default.HelpDocs(self, htmlfile)
172
+
173
+ def settings(self):
174
+ """ Settings """
175
+ if 'Raster' not in self.indata:
176
+ self.indata['Raster'] = list(self.lmod1.griddata.values())
177
+
178
+ for i in self.indata['Raster']:
179
+ self.inraster[i.dataid] = i
180
+ if 'Model3D' in self.indata.keys():
181
+ self.lmod1 = self.indata['Model3D'][0]
182
+ # self.lmod1.init_calc_grids()
183
+ self.lmod2 = self.indata['Model3D'][-1]
184
+ # self.lmod2.init_calc_grids()
185
+
186
+ self.outdata['Model3D'] = [self.lmod1]
187
+ self.mext.update_combos()
188
+ self.mext.tab_activate()
189
+ self.outdata['Raster'] = list(self.lmod1.griddata.values())
190
+
191
+ if 'ProfPic' in self.indata:
192
+ icnt = 0
193
+ for i in self.indata['ProfPic']:
194
+ icnt += 1
195
+ self.lmod1.profpics['Profile: '+str(icnt)] = i
196
+
197
+ self.show()
198
+
199
+ return True
200
+
201
+ def showtext(self, txt, replacelast=False):
202
+ """ Show text on the text panel of the main user interface"""
203
+ if replacelast is True:
204
+ self.txtmsg = self.txtmsg[:self.txtmsg.rfind('\n')]
205
+ self.txtmsg = self.txtmsg[:self.txtmsg.rfind('\n')]
206
+ self.txtmsg += '\n'
207
+ self.txtmsg += txt + '\n'
208
+ self.textbrowser.setPlainText(self.txtmsg)
209
+ tmp = self.textbrowser.verticalScrollBar()
210
+ tmp.setValue(tmp.maximumHeight())
211
+ self.repaint()
212
+
213
+ def tab_change(self, index=None):
214
+ """ This gets called any time we change a tab, and activates the
215
+ routines behind the new tab """
216
+
217
+ index = self.tabwidget.currentIndex()
218
+ self.profile.change_defs()
219
+ self.layer.change_defs()
220
+
221
+ if self.oldtab == 'Layer Editor':
222
+ self.layer.update_model()
223
+
224
+ if self.oldtab == 'Profile Editor':
225
+ self.profile.update_model()
226
+
227
+ if self.oldtab == 'Custom Profile Editor':
228
+ self.pview.update_model()
229
+
230
+ if self.tabwidget.tabText(index) == 'Geophysical Parameters':
231
+ self.param.tab_activate()
232
+
233
+ if self.tabwidget.tabText(index) == 'Model Extent Parameters':
234
+ self.mext.tab_activate()
235
+
236
+ if self.tabwidget.tabText(index) == 'Profile Editor':
237
+ self.profile.tab_activate()
238
+
239
+ if self.tabwidget.tabText(index) == 'Custom Profile Editor':
240
+ self.pview.tab_activate()
241
+
242
+ if self.tabwidget.tabText(index) == 'Layer Editor':
243
+ self.layer.tab_activate()
244
+
245
+ if self.tabwidget.tabText(index) == 'Data Display':
246
+ self.ddisp.tab_activate()
247
+
248
+ self.oldtab = self.tabwidget.tabText(index)