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,123 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: datatypes.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
+ """ Class for raster data types and conversion routines"""
26
+
27
+ import numpy as np
28
+
29
+
30
+ def numpy_to_pygmi(data):
31
+ """
32
+ Converts an MxN numpy array into a PyGMI data object
33
+
34
+ Parameters
35
+ ----------
36
+ data : numpy array
37
+ MxN array
38
+
39
+ Returns
40
+ -------
41
+ tmp : Data
42
+ PyGMI raster dataset
43
+ """
44
+ if data.ndim != 2:
45
+ print("Error: you need 2 dimensions")
46
+ return
47
+ tmp = Data()
48
+ if np.ma.isMaskedArray(data):
49
+ tmp.data = data
50
+ else:
51
+ tmp.data.data = data
52
+ tmp.ydim, tmp.xdim = data.shape
53
+
54
+ return tmp
55
+
56
+
57
+ def pygmi_to_numpy(tmp):
58
+ """
59
+ Converts a PyGMI data object into an MxN numpy array
60
+
61
+ Parameters
62
+ ----------
63
+ tmp : Data
64
+ PyGMI raster dataset
65
+
66
+ Returns
67
+ -------
68
+ array : numpy array
69
+ MxN numpy array
70
+ """
71
+ return np.array(tmp.data)
72
+
73
+
74
+ class Data(object):
75
+ """
76
+ PyGMI Data Object
77
+
78
+ Attributes
79
+ ----------
80
+ data : numpy masked array
81
+ array to contain raster data
82
+ tlx : float
83
+ Top Left X coordinate of raster grid
84
+ tly : float
85
+ Top Left Y coordinate of raster grid
86
+ xdim : float
87
+ x-dimension of grid cell
88
+ ydim : float
89
+ y-dimension of grid cell
90
+ nrofbands : int
91
+ number of raster bands
92
+ dataid : str
93
+ band name or id
94
+ rows : int
95
+ number of rows for each raster grid/band
96
+ cols : int
97
+ number of columns for each raster grid/band
98
+ nullvalue : float
99
+ grid null or nodata value
100
+ norm : dictionary
101
+ normalized data
102
+ gtr : tuple
103
+ projection information
104
+ wkt : str
105
+ projection information
106
+ units : str
107
+ description of units to be used with color bars
108
+ """
109
+ def __init__(self):
110
+ self.data = np.ma.array([])
111
+ self.tlx = 0.0 # Top Left X coordinate
112
+ self.tly = 0.0 # Top Left Y coordinate
113
+ self.xdim = 1.0
114
+ self.ydim = 1.0
115
+ self.nrofbands = 1
116
+ self.dataid = ''
117
+ self.rows = -1
118
+ self.cols = -1
119
+ self.nullvalue = 1e+20
120
+ self.norm = {}
121
+ self.gtr = (0.0, 1.0, 0.0, 0.0, -1.0)
122
+ self.wkt = ''
123
+ self.units = ''
@@ -0,0 +1,256 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Name: equation_editor.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 function which calls the equation editor """
26
+
27
+ from PyQt4 import QtGui, QtCore
28
+ import numpy as np
29
+ import copy
30
+ import numexpr as ne
31
+ import pygmi.raster.dataprep as dataprep
32
+
33
+
34
+ class EquationEditor(QtGui.QDialog):
35
+ """
36
+ Equation Editor
37
+
38
+ This class allows the input of equations using raster datasets as
39
+ variables. This is commonly done in remote sensing applications, where
40
+ there is a requirement for band ratioing etc. It uses the numexpr library.
41
+
42
+ Attributes
43
+ ----------
44
+ parent : parent
45
+ reference to the parent routine
46
+ indata : dictionary
47
+ dictionary of input datasets
48
+ outdata : dictionary
49
+ dictionary of output datasets
50
+ equation : str
51
+ string with the equation in it
52
+ bands : dictionary
53
+ dictionary of bands
54
+ bandsall : list
55
+ list of all bands
56
+ """
57
+ def __init__(self, parent=None):
58
+ QtGui.QDialog.__init__(self, parent)
59
+
60
+ self.indata = {}
61
+ self.outdata = {}
62
+ self.parent = parent
63
+ self.equation = ''
64
+ self.bands = {}
65
+ self.bandsall = []
66
+ self.localdict = {}
67
+
68
+ self.bands['all data'] = 'iall'
69
+
70
+ self.combobox = QtGui.QComboBox()
71
+
72
+ self.textbrowser = QtGui.QTextEdit()
73
+ self.textbrowser2 = QtGui.QTextBrowser()
74
+ self.label = QtGui.QLabel()
75
+
76
+ self.setupui()
77
+
78
+ def textchanged(self):
79
+ """ Text Changed """
80
+ self.equation = self.textbrowser.toPlainText()
81
+
82
+ def setupui(self):
83
+ """ Setup UI """
84
+ gridlayout = QtGui.QGridLayout(self)
85
+ buttonbox = QtGui.QDialogButtonBox()
86
+ label_2 = QtGui.QLabel()
87
+
88
+ self.textbrowser.setEnabled(True)
89
+ self.resize(600, 480)
90
+
91
+ buttonbox.setOrientation(QtCore.Qt.Horizontal)
92
+ buttonbox.setStandardButtons(buttonbox.Cancel | buttonbox.Ok)
93
+
94
+ ptmp = self.textbrowser2.palette()
95
+ ptmp.setColor(0, 9, ptmp.color(10))
96
+ ptmp.setColor(1, 9, ptmp.color(10))
97
+ ptmp.setColor(2, 9, ptmp.color(10))
98
+ self.textbrowser2.setPalette(ptmp)
99
+ self.textbrowser2.setFrameShape(QtGui.QFrame.NoFrame)
100
+
101
+ self.setWindowTitle("Equation Editor")
102
+ self.label.setText(": iall")
103
+ label_2.setText("Output Equation:")
104
+ self.textbrowser.setText('iall')
105
+ tmp = ('<h1>Instructions:</h1>'
106
+ '<p>Equation editor uses the numexpr library. Use the variables'
107
+ ' iall, i1, i2 etc in formulas. The combobox above shows which '
108
+ 'band is assigned to each variable.</p>'
109
+ '<h2>Examples</h2>'
110
+ '<p>Sum:</p>'
111
+ '<p> i1 + 1000</p>'
112
+ '<p>Threshold between values 1 and 98, substituting -999 as a '
113
+ 'nodata value:</p>'
114
+ '<p> where((i1 &gt; 1) &amp; (i1 &lt; 98) , i1, -999)</p>'
115
+ '<h2>Commands</h2>'
116
+ '<ul>'
117
+ ' <li> Logical operators: &amp;, |, ~</li>'
118
+ ' <li> Comparison operators: &lt;, &lt;=, ==, !=, &gt;=, &gt;</li>'
119
+ ' <li> Arithmetic operators: +, -, *, /, **, %, <<, >></li>'
120
+ ' <li> where(bool, number1, number2) : number1 if the bool '
121
+ 'condition is true, number2 otherwise.</li>'
122
+ ' <li> sin, cos, tan, arcsin, arccos, arctan, '
123
+ 'sinh, cosh, tanh, arctan2, arcsinh, arccosh, arctanh</li>'
124
+ ' <li> log, log10, log1p, exp, expm1</li>'
125
+ ' <li> sqrt, abs</li>'
126
+ '</ul>')
127
+ self.textbrowser2.setHtml(tmp)
128
+
129
+ gridlayout.addWidget(label_2, 0, 0, 1, 1)
130
+ gridlayout.addWidget(self.textbrowser, 1, 0, 1, 2)
131
+ gridlayout.addWidget(self.combobox, 4, 0, 1, 1)
132
+ gridlayout.addWidget(self.label, 4, 1, 1, 1)
133
+ gridlayout.addWidget(self.textbrowser2, 5, 0, 1, 2)
134
+ gridlayout.addWidget(buttonbox, 6, 0, 1, 2)
135
+
136
+ self.combobox.currentIndexChanged.connect(self.combo)
137
+ self.textbrowser.textChanged.connect(self.textchanged)
138
+ buttonbox.accepted.connect(self.accept)
139
+ buttonbox.rejected.connect(self.reject)
140
+
141
+ def combo(self):
142
+ """ update combo information """
143
+ txt = self.combobox.currentText()
144
+ if txt == '':
145
+ return
146
+ self.label.setText(': '+self.bands[txt])
147
+
148
+ def eq_fix(self):
149
+ """ Corrects names in equation to variable names """
150
+ neweq = str(self.equation)
151
+ neweq = neweq.replace('ln', 'log')
152
+ neweq = neweq.replace('^', '**')
153
+
154
+ return neweq
155
+
156
+ def settings(self):
157
+ """ Settings """
158
+ self.combobox.clear()
159
+ self.combobox.addItem('all data')
160
+
161
+ self.bandsall = []
162
+
163
+ if 'Cluster' in self.indata:
164
+ intype = 'Cluster'
165
+ elif 'Raster' in self.indata:
166
+ intype = 'Raster'
167
+ else:
168
+ self.parent.showprocesslog('No raster data')
169
+ return
170
+
171
+ indata = dataprep.merge(self.indata[intype])
172
+
173
+ mask = indata[-1].data.mask
174
+ for i in indata:
175
+ mask = np.logical_or(mask, i.data.mask)
176
+ for i in indata:
177
+ i.data.mask = mask
178
+
179
+ self.localdict = {}
180
+ j = 0
181
+ for i in indata:
182
+ j += 1
183
+ self.localdict['i'+str(j)] = i.data
184
+ self.bands[i.dataid] = 'i'+str(j)
185
+ self.bandsall.append(i.data)
186
+ self.combobox.addItem(i.dataid)
187
+ self.localdict['iall'] = np.ma.array(self.bandsall)
188
+
189
+ self.bandsall = np.ma.array(self.bandsall)
190
+
191
+ temp = self.exec_()
192
+
193
+ if temp == 0:
194
+ return
195
+
196
+ self.equation = self.textbrowser.toPlainText()
197
+
198
+ if self.equation == '':
199
+ return
200
+
201
+ neweq = self.eq_fix()
202
+
203
+ findat = ne.evaluate(neweq, self.localdict)
204
+ outdata = []
205
+
206
+ if np.size(findat) == 1:
207
+ QtGui.QMessageBox.warning(
208
+ self.parent, 'Warning',
209
+ ' Nothing processed! Your equation outputs a single ' +
210
+ 'value instead of a minimum of one band.',
211
+ QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
212
+ return
213
+ elif len(findat.shape) == 2:
214
+ masktmp = np.logical_or(indata[0].data.mask, np.isnan(findat))
215
+ outdata = [copy.copy(indata[0])]
216
+ outdata[0].data = np.ma.array(findat, mask=masktmp)
217
+ outdata[0].dataid = 'equation output'
218
+ else:
219
+ for i in range(len(findat)):
220
+ masktmp = np.logical_or(indata[i].data.mask,
221
+ np.isnan(findat[i]))
222
+ outdata.append(copy.copy(indata[i]))
223
+ outdata[-1].data = np.ma.array(findat[i], mask=masktmp)
224
+
225
+ self.outdata[intype] = outdata
226
+
227
+ return True
228
+
229
+
230
+ def hmode(data):
231
+ """
232
+ Mode - this uses a histogram to generate a fast mode estimate
233
+
234
+ Parameters
235
+ ----------
236
+ data : list
237
+ list of values to generate the mode from.
238
+
239
+ Returns
240
+ -------
241
+ mode2 : float
242
+ mode value
243
+ """
244
+ mmin = np.min(data)
245
+ mmax = np.max(data)
246
+ for _ in range(2):
247
+ mhist = np.histogram(data, 255, range=(mmin, mmax))
248
+ mtmp = mhist[0].tolist()
249
+ mind = mtmp.index(max(mtmp))
250
+ mmin = mhist[1][mind]
251
+ mmax = mhist[1][mind+1]
252
+
253
+ mode2 = (mmax-mmin)/2 + mmin
254
+ # mcnt = mhist[0][mind]
255
+
256
+ return mode2