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,6 @@
1
+ """
2
+ Tests for PyGMI
3
+ """
4
+ __all__ = ["pfmod"]
5
+ from . import pfmod
6
+
@@ -0,0 +1,212 @@
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
+ """ These are pfmod tests. Run this file from within this directory to do the
26
+ tests """
27
+
28
+ import numpy as np
29
+ from pygmi.pfmod.grvmag3d import quick_model
30
+ from pygmi.pfmod.grvmag3d import calc_field
31
+ import matplotlib.pyplot as plt
32
+ import pygmi.misc as ptimer
33
+
34
+
35
+ def test(doplt=False):
36
+ """
37
+ Main test function
38
+
39
+ This test function compares the calculations performed by PyGMI to
40
+ calculations performed by a external software - namely mag2dc and grav2dc
41
+ by G.R.J Cooper.
42
+
43
+ A series of graphs are produced. If the test is successful, points and
44
+ lines on the graphs will coincide.
45
+ """
46
+ print('Testing modelling of gravity and potential field data')
47
+
48
+ # First initialise variables
49
+ x = []
50
+ z = []
51
+ xpos = []
52
+ g2dc = []
53
+ m2dc = []
54
+
55
+ # start to load in gravity data
56
+ gfile = open('Grav2dc_grav.txt')
57
+ tmp = gfile.read()
58
+ tmp2 = tmp.splitlines()
59
+
60
+ numx = get_int(tmp2, 2, 2)
61
+ cnrs = get_int(tmp2, 6, 4)
62
+ dens = get_float(tmp2, 6, 8) + 2.67
63
+ strike = get_float(tmp2, 7, 3)
64
+
65
+ for i in range(cnrs):
66
+ x.append(get_float(tmp2, 9+i, 0))
67
+ z.append(get_float(tmp2, 9+i, 1))
68
+
69
+ for i in range(numx):
70
+ xpos.append(get_float(tmp2, 11+cnrs+i, 0))
71
+ g2dc.append(get_float(tmp2, 11+cnrs+i, 1))
72
+
73
+ gfile.close()
74
+
75
+ # Convert to numpy and correct orientation of depths.
76
+ x = np.array(x)
77
+ z = -np.array(z)
78
+ xpos = np.array(xpos)
79
+ g2dc = np.array(g2dc)
80
+
81
+ # Start to load in magnetic data
82
+ mfile = open('Mag2dc_mag.txt')
83
+ tmp = mfile.read()
84
+ tmp2 = tmp.splitlines()
85
+
86
+ finc = get_float(tmp2, 4, 5)
87
+ fdec = get_float(tmp2, 4, 8)
88
+ mht = get_float(tmp2, 7, 5)
89
+ susc = get_float(tmp2, 12, 7)
90
+ minc = get_float(tmp2, 14, 9)
91
+ mdec = get_float(tmp2, 14, 12)
92
+ mstrength = get_float(tmp2, 14, 5)/(400*np.pi)
93
+
94
+ for i in range(numx):
95
+ m2dc.append(get_float(tmp2, 18+cnrs+i, 1))
96
+
97
+ mfile.close()
98
+
99
+ # Convert to numpy
100
+ m2dc = np.array(m2dc)
101
+
102
+ # for testing purposes the cube being modelled should have dxy = d_z to
103
+ # keep things simple
104
+ dxy = (xpos[1]-xpos[0])
105
+ d_z = 50
106
+ ypos = np.arange(-strike, strike, dxy)
107
+ zpos = np.arange(z.min(), 0, d_z)
108
+ xpos2 = np.arange(xpos.min(), xpos.max(), dxy)
109
+ numy = ypos.size
110
+ numz = zpos.size
111
+ tlx = xpos.min()
112
+ tly = ypos.max()
113
+ tlz = zpos.max()
114
+
115
+ # quick model initialises a model with all the variables we have defined.
116
+ ttt = ptimer.PTime()
117
+ lmod = quick_model(xpos2.size, numy, numz, dxy, d_z,
118
+ tlx, tly, tlz, 0, 0, finc, fdec,
119
+ ['Generic'], [susc], [dens],
120
+ [minc], [mdec], [mstrength])
121
+ ttt.since_last_call('quick model')
122
+
123
+ # Create the actual model. It is a 3 dimensional vector with '1' where the
124
+ # body lies
125
+ for i in np.arange(x.min(), x.max(), dxy):
126
+ for j in np.arange(0, 2*strike, dxy):
127
+ for k in np.arange(abs(z).min()/d_z, abs(z).max()/d_z):
128
+ i2 = int(i/dxy)
129
+ j2 = int(j/dxy)
130
+ k2 = int(k)
131
+ lmod.lith_index[i2, j2, k2] = 1
132
+
133
+ ttt.since_last_call('model create')
134
+
135
+ # Calculate the gravity
136
+ calc_field(lmod)
137
+ gdata = lmod.griddata['Calculated Gravity'].data[numy/2].copy()
138
+ ttt.since_last_call('gravity calculation')
139
+
140
+ # Change to observation height to 100 meters and calculate magnetics
141
+ lmod.mht = mht
142
+ calc_field(lmod, magcalc=True)
143
+
144
+ mdata = lmod.griddata['Calculated Magnetics'].data[numy/2]
145
+
146
+ ttt.since_last_call('magnetic calculation')
147
+
148
+ if doplt:
149
+ # Display results
150
+ _, ax1 = plt.subplots()
151
+ ax1.set_xlabel('Distance (m)')
152
+ ax1.plot(xpos2+dxy/2, gdata, 'r', label='PyGMI')
153
+ ax1.plot(xpos, g2dc, 'r.', label='Grav2DC')
154
+ ax1.set_ylabel('mGal')
155
+ ax1.legend(loc='upper left', shadow=True)
156
+
157
+ ax2 = ax1.twinx()
158
+ ax2.plot(xpos2+dxy/2, mdata, 'b', label='PyGMI')
159
+ ax2.plot(xpos, m2dc, 'b.', label='Mag2DC')
160
+ ax2.set_ylabel('nT')
161
+ ax2.legend(loc='upper right', shadow=True)
162
+ plt.show()
163
+
164
+ # print(mdata[:-1]-m2dc[2::2])
165
+ # np.testing.assert_almost_equal(gdata[:-1], g2dc[2::2], 1)
166
+ # np.testing.assert_almost_equal(mdata[:-1], m2dc[2::2], 1)
167
+
168
+
169
+ def get_int(tmp, row, word):
170
+ """
171
+ Gets an int from a list of strings.
172
+
173
+ Parameters
174
+ ----------
175
+ tmp : list
176
+ list of strings
177
+ row : int
178
+ row in list to extract. First row is 0
179
+ word : int
180
+ word to extract from row. First word is 0
181
+
182
+ Returns
183
+ -------
184
+ output : int
185
+ return an integer from the row.
186
+ """
187
+ return int(tmp[row].split()[word])
188
+
189
+
190
+ def get_float(tmp, row, word):
191
+ """
192
+ Gets a float from a list of strings.
193
+
194
+ Parameters
195
+ ----------
196
+ tmp : list
197
+ list of strings
198
+ row : int
199
+ row in list to extract. First row is 0
200
+ word : int
201
+ word to extract from row. First word is 0
202
+
203
+ Returns
204
+ -------
205
+ output : float
206
+ return a float from the row.
207
+ """
208
+ return float(tmp[row].split()[word])
209
+
210
+
211
+ if __name__ == "__main__":
212
+ test(True)
@@ -0,0 +1,39 @@
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
+ """ These are tests. Run this file from within this directory to do the
26
+ tests """
27
+
28
+ import numpy as np
29
+ import pfmod
30
+ import nose
31
+
32
+
33
+ def test():
34
+ """ Test Routine """
35
+ pfmod.test()
36
+
37
+ if __name__ == "__main__":
38
+ # doctest.testmod(pygmi.raster)
39
+ nose.run()
@@ -0,0 +1,7 @@
1
+ """
2
+ Vector data routines
3
+ """
4
+ __all__ = ["datatypes", "iodefs", "graphs"]
5
+ from . import datatypes
6
+ from . import iodefs
7
+ from . import graphs
@@ -0,0 +1,74 @@
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
+ """ Module for vector data types """
26
+
27
+ import numpy as np
28
+
29
+
30
+ class PData(object):
31
+ """
32
+ Class for point data
33
+
34
+ Attributes
35
+ ----------
36
+ xdata : numpy array
37
+ array of x coordinates
38
+ ydata : numpy array
39
+ array of y coordinates
40
+ zdata : numpy array
41
+ array of z coordinates
42
+ dataid : str
43
+ data description
44
+ """
45
+
46
+ def __init__(self):
47
+ self.xdata = np.array([])
48
+ self.ydata = np.array([])
49
+ self.zdata = np.array([])
50
+ self.dataid = ""
51
+
52
+
53
+ class VData(object):
54
+ """
55
+ Class for Vector data. Typically used for storage of shape files.
56
+
57
+ Attributes
58
+ ----------
59
+ crds : list
60
+ List of coordinates
61
+ attrib : list
62
+ list of dictionaries, where each dictionary is the column in a table
63
+ dataid : str
64
+ data description
65
+ dtype : str
66
+ type of data - Line, Point, Poly
67
+ """
68
+ def __init__(self):
69
+ # Since each line can have variable amount of points, it is best to
70
+ # store in a list
71
+ self.crds = []
72
+ self.attrib = [{}]
73
+ self.dataid = ""
74
+ self.dtype = ""