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,292 @@
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 data types """
26
+
27
+ import numpy as np
28
+ from ..raster.datatypes import Data
29
+
30
+
31
+ class LithModel(object):
32
+ """ Lithological Model Data.
33
+
34
+ This is the main data structure for the modelling program
35
+
36
+ Attributes:
37
+ mlut (dictionary): color table for lithologies
38
+ numx (int): number of columns per layer in model
39
+ numy (int): number of rows per layer in model
40
+ numz (int): number of layers in model
41
+ dxy (float): dimension of cubes in the x and y directions
42
+ d_z (float): dimension of cubes in the z direction
43
+ lith_index (numpy array): 3D array of lithological indices.
44
+ clith_index (numpy array): 3D array of calculated lithological indices.
45
+ calt_calc (bool): boolean specifying which calculation was used.
46
+ curlayer (int): Current layer
47
+ xrange (list): minimum and maximum x coordinates
48
+ yrange (list): minimum and maximum y coordinates
49
+ zrange (list): minimum and maximum z coordinates
50
+ curprof (int): current profile (in x or y direction)
51
+ griddata (dictionary): dictionary of Data classes with raster data
52
+ custprofx (dictionary): custom profile x coordinates
53
+ custprofy (dictionary): custom profile y coordinates
54
+ profpics (dictionary): = profile pictures
55
+ lith_list (dictionary): = list of lithologies
56
+ lith_list_reverse (dictionary): = reverse lookup for lith_list
57
+ mht (float): height of magnetic sensor
58
+ ght (float): height of gravity sensor
59
+ gregional (float): gravity regional correction
60
+ name (str): name of the model
61
+ """
62
+
63
+ def __init__(self):
64
+ self.mlut = {0: [170, 125, 90], 1: [255, 255, 0]}
65
+ self.numx = None
66
+ self.numy = None
67
+ self.numz = None
68
+ self.dxy = None
69
+ self.d_z = None
70
+ self.lith_index = None
71
+ self.clith_index = None
72
+ self.cmagcalc = False
73
+ self.curlayer = None
74
+ self.xrange = [None, None]
75
+ self.yrange = [None, None]
76
+ self.zrange = [None, None]
77
+ self.curprof = None
78
+ self.griddata = {}
79
+ self.custprofx = {}
80
+ self.custprofy = {}
81
+ self.profpics = {}
82
+ self.lith_list = {}
83
+ self.lith_list_reverse = {}
84
+ self.mht = None
85
+ self.ght = None
86
+ self.gregional = 100
87
+ self.name = '3D Model'
88
+ self.dataid = '3D Model'
89
+
90
+ # Next line calls a function to update the variables above.
91
+ self.update(100, 75, 40, 0, 150000, 0, 1500, 100, 100, 0)
92
+
93
+ self.olith_index = None
94
+ self.odxy = None
95
+ self.od_z = None
96
+ self.oxrng = None
97
+ self.oyrng = None
98
+ self.ozrng = None
99
+ self.onumx = None
100
+ self.onumy = None
101
+ self.onumz = None
102
+
103
+ self.is_ew = True
104
+
105
+ def lithold_to_lith(self):
106
+ """ Transfers an old lithology to the new one, using updates parameters
107
+ """
108
+ if self.olith_index is None:
109
+ return
110
+ xvals = np.arange(self.xrange[0], self.xrange[1], self.dxy) + \
111
+ .5 * self.dxy
112
+ yvals = np.arange(self.yrange[0], self.yrange[1], self.dxy) + \
113
+ .5 * self.dxy
114
+ zvals = np.arange(self.zrange[0], self.zrange[1], self.d_z) + \
115
+ .5 * self.d_z
116
+ xvals = xvals[self.oxrng[0] < xvals]
117
+ xvals = xvals[xvals < self.oxrng[1]]
118
+ yvals = yvals[self.oyrng[0] < yvals]
119
+ yvals = yvals[yvals < self.oyrng[1]]
120
+ zvals = zvals[self.ozrng[0] < zvals]
121
+ zvals = zvals[zvals < self.ozrng[1]]
122
+
123
+ for x_i in xvals:
124
+ o_i = int((x_i - self.oxrng[0]) / self.odxy)
125
+ i = int((x_i - self.xrange[0]) / self.dxy)
126
+ for x_j in yvals:
127
+ o_j = int((x_j - self.oyrng[0]) / self.odxy)
128
+ j = int((x_j - self.yrange[0]) / self.dxy)
129
+ for x_k in zvals:
130
+ o_k = int((self.ozrng[1] - x_k) / self.od_z)
131
+ k = int((self.zrange[1] - x_k) / self.d_z)
132
+
133
+ if (self.lith_index[i, j, k] != -1 and
134
+ self.olith_index[o_i, o_j, o_k] != -1):
135
+ self.lith_index[i, j, k] = \
136
+ self.olith_index[o_i, o_j, o_k]
137
+
138
+ def dtm_to_lith(self):
139
+ """ Assign the DTM to the model. This means creating nodata values in
140
+ areas above the DTM. These values are assigned a lithology of -1."""
141
+
142
+ if 'DTM Dataset' not in list(self.griddata.keys()):
143
+
144
+ return
145
+
146
+ self.lith_index = np.zeros([self.numx, self.numy, self.numz],
147
+ dtype=int)
148
+
149
+ curgrid = self.griddata['DTM Dataset']
150
+
151
+ d_x = curgrid.xdim
152
+ d_y = curgrid.ydim
153
+ utlx = curgrid.tlx
154
+ utly = curgrid.tly
155
+ gcols = curgrid.cols
156
+ grows = curgrid.rows
157
+
158
+ gxmin = utlx
159
+ gymax = utly
160
+ utlz = curgrid.data.max()
161
+
162
+ self.lith_index[:, :, :] = 0
163
+
164
+ for i in range(self.numx):
165
+ for j in range(self.numy):
166
+ xcrd = self.xrange[0] + (i + .5) * self.dxy
167
+ ycrd = self.yrange[1] - (j + .5) * self.dxy
168
+ xcrd2 = int((xcrd - gxmin) / d_x)
169
+ ycrd2 = grows - int((gymax - ycrd) / d_y)
170
+ if (ycrd2 >= 0 and xcrd2 >= 0 and ycrd2 < grows and
171
+ xcrd2 < gcols):
172
+ alt = curgrid.data.data[ycrd2, xcrd2]
173
+ if (curgrid.data.mask[ycrd2, xcrd2] is True or
174
+ np.isnan(alt) or alt == curgrid.nullvalue):
175
+ alt = curgrid.data.mean()
176
+ k_2 = int((utlz - alt) / self.d_z)
177
+ self.lith_index[i, j, :k_2] = -1
178
+ self.clith_index = self.lith_index.copy()
179
+
180
+ def init_grid(self, data):
181
+ """ Initializes raster variables in the Data class
182
+
183
+ Args:
184
+ data (numpy masked array): masked array containing raster data."""
185
+
186
+ grid = Data()
187
+ grid.data = data
188
+ grid.cols = self.numx
189
+ grid.rows = self.numy
190
+ grid.xdim = self.dxy
191
+ grid.ydim = self.dxy
192
+ grid.tlx = self.xrange[0]
193
+ grid.tly = self.yrange[1]
194
+ return grid
195
+
196
+ def init_calc_grids(self):
197
+ """ Initializes mag and gravity from the model """
198
+ tmp = np.ma.zeros([self.numy, self.numx])
199
+ self.griddata['Calculated Magnetics'] = self.init_grid(tmp.copy())
200
+ self.griddata['Calculated Magnetics'].dataid = 'Calculated Magnetics'
201
+ self.griddata['Calculated Magnetics'].units = 'nT'
202
+ self.griddata['Calculated Gravity'] = self.init_grid(tmp.copy())
203
+ self.griddata['Calculated Gravity'].dataid = 'Calculated Gravity'
204
+ self.griddata['Calculated Gravity'].units = 'mgal'
205
+
206
+ def is_modified(self, modified=True):
207
+ """ Updates modified flag
208
+
209
+ Args:
210
+ modified (bool): flag for whether the lithology has been modified
211
+ """
212
+ for i in list(self.lith_list.keys()):
213
+ self.lith_list[i].modified = modified
214
+
215
+ def update(self, cols, rows, layers, utlx, utly, utlz, dxy, d_z, mht=-1,
216
+ ght=-1):
217
+ """ Updates the local variables for the LithModel class
218
+
219
+ Args:
220
+ cols (int): number of columns per layer in model
221
+ rows (int): number of rows per layer in model
222
+ layers (int): number of layers in model
223
+ utlx (float): upper top left (NW) x coordinate
224
+ utly (float): upper top left (NW) y coordinate
225
+ utlz (float): upper top left (NW) z coordinate
226
+ dxy (float): dimension of cubes in the x and y directions
227
+ d_z (float): dimension of cubes in the z direction
228
+ mht (float): height of magnetic sensor
229
+ ght (float): height of gravity sensor
230
+ """
231
+ if mht != -1:
232
+ self.mht = mht
233
+ if ght != -1:
234
+ self.ght = ght
235
+
236
+ self.olith_index = self.lith_index
237
+ self.odxy = self.dxy
238
+ self.od_z = self.d_z
239
+ self.oxrng = np.copy(self.xrange)
240
+ self.oyrng = np.copy(self.yrange)
241
+ self.ozrng = np.copy(self.zrange)
242
+ self.onumx = self.numx
243
+ self.onumy = self.numy
244
+ self.onumz = self.numz
245
+
246
+ xextent = cols * dxy
247
+ yextent = rows * dxy
248
+ zextent = layers * d_z
249
+
250
+ self.numx = cols
251
+ self.numy = rows
252
+ self.numz = layers
253
+ self.xrange = [utlx, utlx + xextent]
254
+ self.yrange = [utly - yextent, utly]
255
+ self.zrange = [utlz - zextent, utlz]
256
+
257
+ self.custprofx[0] = self.xrange
258
+ self.custprofy[0] = (self.yrange[0], self.yrange[0])
259
+
260
+ self.dxy = dxy
261
+ self.d_z = d_z
262
+ self.curlayer = 0
263
+ self.curprof = 0
264
+ self.lith_index = np.zeros([self.numx, self.numy, self.numz],
265
+ dtype=int)
266
+ self.clith_index = np.zeros([self.numx, self.numy, self.numz],
267
+ dtype=int)
268
+ self.init_calc_grids()
269
+ self.dtm_to_lith()
270
+ self.lithold_to_lith()
271
+ self.update_lithlist()
272
+ self.is_modified()
273
+
274
+ def update_lithlist(self):
275
+ """ Updates lith_list from local variables"""
276
+ for i in list(self.lith_list.keys()):
277
+ self.lith_list[i].set_xyz(self.numx, self.numy, self.numz,
278
+ self.dxy, self.mht, self.ght, self.d_z,
279
+ modified=False)
280
+
281
+ def update_lith_list_reverse(self):
282
+ """ Update the lith_list reverse lookup. It must be run at least once
283
+ before using lith_list_reverse"""
284
+ keys = list(self.lith_list.keys())
285
+ values = list(self.lith_list.values())
286
+
287
+ if len(keys) == 0:
288
+ return
289
+
290
+ self.lith_list_reverse = {}
291
+ for i in range(len(keys)):
292
+ self.lith_list_reverse[list(values)[i].lith_index] = list(keys)[i]