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.
- pygmi-2.2.7/LICENSE.txt +623 -0
- pygmi-2.2.7/MANIFEST.in +7 -0
- pygmi-2.2.7/PKG-INFO +47 -0
- pygmi-2.2.7/README.md +55 -0
- pygmi-2.2.7/README.rst +20 -0
- pygmi-2.2.7/log.txt +242 -0
- pygmi-2.2.7/pygmi/__init__.py +22 -0
- pygmi-2.2.7/pygmi/clust/__init__.py +4 -0
- pygmi-2.2.7/pygmi/clust/crisp_clust.py +708 -0
- pygmi-2.2.7/pygmi/clust/datatypes.py +65 -0
- pygmi-2.2.7/pygmi/clust/fuzzy_clust.py +906 -0
- pygmi-2.2.7/pygmi/clust/graphs.py +421 -0
- pygmi-2.2.7/pygmi/clust/graphtool.py +667 -0
- pygmi-2.2.7/pygmi/clust/menu.py +139 -0
- pygmi-2.2.7/pygmi/clust/var_ratio.py +92 -0
- pygmi-2.2.7/pygmi/clust/xie_beni.py +93 -0
- pygmi-2.2.7/pygmi/helpdocs/linepointer.png +0 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.main.html +31 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.ddisp.html +15 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.exportkmz.html +13 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.iodefs.importpicture.html +16 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.layer.html +17 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.mext.html +44 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.misc.rangedcopy.html +16 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.param.html +37 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.prof.html +32 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.pfmod.pview.html +26 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.gradients.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.tilt.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.cooper.visibility.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datagrid.html +13 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datamerge.html +11 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.datareproj.html +11 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.dataprep.rtp.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.ginterp.html +31 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.igrf.html +20 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.normalisation.html +14 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.smooth.html +22 -0
- pygmi-2.2.7/pygmi/helpdocs/pygmi.raster.tiltdepth.html +20 -0
- pygmi-2.2.7/pygmi/images/Help.png +0 -0
- pygmi-2.2.7/pygmi/images/bringtofront.png +0 -0
- pygmi-2.2.7/pygmi/images/cgs2.emf +0 -0
- pygmi-2.2.7/pygmi/images/delete.png +0 -0
- pygmi-2.2.7/pygmi/images/linepointer.png +0 -0
- pygmi-2.2.7/pygmi/images/logo256.ico +0 -0
- pygmi-2.2.7/pygmi/images/logo256.png +0 -0
- pygmi-2.2.7/pygmi/images/pointer.png +0 -0
- pygmi-2.2.7/pygmi/images/pygmi.png +0 -0
- pygmi-2.2.7/pygmi/images/sendtoback.png +0 -0
- pygmi-2.2.7/pygmi/main.py +1037 -0
- pygmi-2.2.7/pygmi/menu_default.py +327 -0
- pygmi-2.2.7/pygmi/misc.py +147 -0
- pygmi-2.2.7/pygmi/pfmod/__init__.py +6 -0
- pygmi-2.2.7/pygmi/pfmod/cubes.py +1488 -0
- pygmi-2.2.7/pygmi/pfmod/datatypes.py +292 -0
- pygmi-2.2.7/pygmi/pfmod/grvmag3d.py +1265 -0
- pygmi-2.2.7/pygmi/pfmod/iodefs.py +1001 -0
- pygmi-2.2.7/pygmi/pfmod/menu.py +107 -0
- pygmi-2.2.7/pygmi/pfmod/misc.py +301 -0
- pygmi-2.2.7/pygmi/pfmod/pfmod.py +248 -0
- pygmi-2.2.7/pygmi/pfmod/tab_ddisp.py +425 -0
- pygmi-2.2.7/pygmi/pfmod/tab_layer.py +490 -0
- pygmi-2.2.7/pygmi/pfmod/tab_mext.py +544 -0
- pygmi-2.2.7/pygmi/pfmod/tab_param.py +548 -0
- pygmi-2.2.7/pygmi/pfmod/tab_prof.py +946 -0
- pygmi-2.2.7/pygmi/pfmod/tab_pview.py +740 -0
- pygmi-2.2.7/pygmi/raster/IGRF11.COF +1635 -0
- pygmi-2.2.7/pygmi/raster/__init__.py +14 -0
- pygmi-2.2.7/pygmi/raster/cooper.py +718 -0
- pygmi-2.2.7/pygmi/raster/dataprep.py +1640 -0
- pygmi-2.2.7/pygmi/raster/datatypes.py +123 -0
- pygmi-2.2.7/pygmi/raster/equation_editor.py +256 -0
- pygmi-2.2.7/pygmi/raster/ginterp.py +1901 -0
- pygmi-2.2.7/pygmi/raster/graphs.py +531 -0
- pygmi-2.2.7/pygmi/raster/igrf.py +860 -0
- pygmi-2.2.7/pygmi/raster/iodefs.py +813 -0
- pygmi-2.2.7/pygmi/raster/menu.py +307 -0
- pygmi-2.2.7/pygmi/raster/normalisation.py +187 -0
- pygmi-2.2.7/pygmi/raster/show_table.py +245 -0
- pygmi-2.2.7/pygmi/raster/smooth.py +406 -0
- pygmi-2.2.7/pygmi/raster/tiltdepth.py +590 -0
- pygmi-2.2.7/pygmi/seis/__init__.py +0 -0
- pygmi-2.2.7/pygmi/seis/beachball.py +751 -0
- pygmi-2.2.7/pygmi/seis/datatypes.py +605 -0
- pygmi-2.2.7/pygmi/seis/del_rec.py +410 -0
- pygmi-2.2.7/pygmi/seis/iodefs.py +1261 -0
- pygmi-2.2.7/pygmi/seis/menu.py +136 -0
- pygmi-2.2.7/pygmi/seis/scan_imp.py +795 -0
- pygmi-2.2.7/pygmi/test/__init__.py +6 -0
- pygmi-2.2.7/pygmi/test/pfmod.py +212 -0
- pygmi-2.2.7/pygmi/test/tests.py +39 -0
- pygmi-2.2.7/pygmi/vector/__init__.py +7 -0
- pygmi-2.2.7/pygmi/vector/datatypes.py +74 -0
- pygmi-2.2.7/pygmi/vector/graphs.py +443 -0
- pygmi-2.2.7/pygmi/vector/iodefs.py +345 -0
- pygmi-2.2.7/pygmi/vector/menu.py +127 -0
- pygmi-2.2.7/pygmi.egg-info/PKG-INFO +47 -0
- pygmi-2.2.7/pygmi.egg-info/SOURCES.txt +105 -0
- pygmi-2.2.7/pygmi.egg-info/dependency_links.txt +1 -0
- pygmi-2.2.7/pygmi.egg-info/entry_points.txt +3 -0
- pygmi-2.2.7/pygmi.egg-info/not-zip-safe +1 -0
- pygmi-2.2.7/pygmi.egg-info/requires.txt +7 -0
- pygmi-2.2.7/pygmi.egg-info/top_level.txt +1 -0
- pygmi-2.2.7/quickstart.py +35 -0
- pygmi-2.2.7/setup.cfg +8 -0
- pygmi-2.2.7/setup.py +80 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Name: dataprep.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
|
+
"""
|
|
26
|
+
Tilt Depth Routine
|
|
27
|
+
Based on work by EH Stettler
|
|
28
|
+
|
|
29
|
+
References:
|
|
30
|
+
Salem et al., 2007, Leading Edge, Dec,p1502-5
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import os
|
|
34
|
+
import numpy as np
|
|
35
|
+
import pygmi.raster.cooper as cooper
|
|
36
|
+
import matplotlib.pyplot as plt
|
|
37
|
+
import pygmi.raster.iodefs as iodefs
|
|
38
|
+
import numexpr as ne
|
|
39
|
+
import pygmi.raster.dataprep as dataprep
|
|
40
|
+
from math import atan2, pi
|
|
41
|
+
|
|
42
|
+
from PyQt4 import QtGui
|
|
43
|
+
import matplotlib
|
|
44
|
+
from matplotlib.figure import Figure
|
|
45
|
+
import matplotlib.cm as cm
|
|
46
|
+
from matplotlib.backends.backend_qt4agg import FigureCanvas
|
|
47
|
+
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as \
|
|
48
|
+
NavigationToolbar
|
|
49
|
+
import pygmi.menu_default as menu_default
|
|
50
|
+
# import pdb
|
|
51
|
+
import pygmi.misc as misc
|
|
52
|
+
# import scipy.spatial.distance as sd
|
|
53
|
+
from numba import jit
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class TiltDepth(QtGui.QDialog):
|
|
57
|
+
"""
|
|
58
|
+
This is the primary class for the Tilt Depth.
|
|
59
|
+
|
|
60
|
+
Attributes
|
|
61
|
+
----------
|
|
62
|
+
parent : parent
|
|
63
|
+
reference to the parent routine
|
|
64
|
+
indata : dictionary
|
|
65
|
+
dictionary of input datasets
|
|
66
|
+
outdata : dictionary
|
|
67
|
+
dictionary of output datasets
|
|
68
|
+
self.mmc : MyMplCanvas, FigureCanvas
|
|
69
|
+
main canvas containing the image
|
|
70
|
+
"""
|
|
71
|
+
def __init__(self, parent=None):
|
|
72
|
+
super().__init__(parent)
|
|
73
|
+
self.indata = {}
|
|
74
|
+
self.outdata = {}
|
|
75
|
+
self.parent = parent
|
|
76
|
+
self.units = {}
|
|
77
|
+
self.X = None
|
|
78
|
+
self.Y = None
|
|
79
|
+
self.Z = None
|
|
80
|
+
self.depths = None
|
|
81
|
+
self.cbar = cm.jet
|
|
82
|
+
self.showtext = self.parent.showprocesslog
|
|
83
|
+
self.x0 = None
|
|
84
|
+
self.x1 = None
|
|
85
|
+
self.x2 = None
|
|
86
|
+
self.y0 = None
|
|
87
|
+
self.y1 = None
|
|
88
|
+
self.y2 = None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
self.figure = Figure()
|
|
93
|
+
self.mmc = FigureCanvas(self.figure)
|
|
94
|
+
self.axes = self.figure.add_subplot(111)
|
|
95
|
+
|
|
96
|
+
self.cbox_band1 = QtGui.QComboBox()
|
|
97
|
+
self.cbox_cbar = QtGui.QComboBox(self)
|
|
98
|
+
self.dsb_inc = QtGui.QDoubleSpinBox()
|
|
99
|
+
self.dsb_dec = QtGui.QDoubleSpinBox()
|
|
100
|
+
self.btn_apply = QtGui.QPushButton()
|
|
101
|
+
self.btn_save = QtGui.QPushButton()
|
|
102
|
+
self.pbar = misc.ProgressBar()
|
|
103
|
+
|
|
104
|
+
self.setupui()
|
|
105
|
+
|
|
106
|
+
def setupui(self):
|
|
107
|
+
""" Setup UI """
|
|
108
|
+
helpdocs = menu_default.HelpButton('pygmi.raster.tiltdepth')
|
|
109
|
+
label2 = QtGui.QLabel()
|
|
110
|
+
labelc = QtGui.QLabel()
|
|
111
|
+
label_inc = QtGui.QLabel()
|
|
112
|
+
label_dec = QtGui.QLabel()
|
|
113
|
+
|
|
114
|
+
self.dsb_inc.setMaximum(90.0)
|
|
115
|
+
self.dsb_inc.setMinimum(-90.0)
|
|
116
|
+
self.dsb_inc.setValue(-67.)
|
|
117
|
+
self.dsb_dec.setMaximum(360.0)
|
|
118
|
+
self.dsb_dec.setMinimum(-360.0)
|
|
119
|
+
self.dsb_dec.setValue(-17.)
|
|
120
|
+
|
|
121
|
+
vbl_raster = QtGui.QVBoxLayout()
|
|
122
|
+
hbl_all = QtGui.QHBoxLayout(self)
|
|
123
|
+
vbl_right = QtGui.QVBoxLayout()
|
|
124
|
+
|
|
125
|
+
mpl_toolbar = NavigationToolbar(self.mmc, self)
|
|
126
|
+
spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
|
|
127
|
+
QtGui.QSizePolicy.Expanding)
|
|
128
|
+
tmp = sorted(cm.datad.keys())
|
|
129
|
+
self.cbox_cbar.addItem('jet')
|
|
130
|
+
self.cbox_cbar.addItems(tmp)
|
|
131
|
+
|
|
132
|
+
self.setWindowTitle("Tilt Depth Interpretation")
|
|
133
|
+
label2.setText('Band to perform Tilt Depth:')
|
|
134
|
+
labelc.setText('Color Bar:')
|
|
135
|
+
label_inc.setText("Inclination of Magnetic Field:")
|
|
136
|
+
label_dec.setText("Declination of Magnetic Field:")
|
|
137
|
+
self.btn_apply.setText('Calculate Tilt Depth')
|
|
138
|
+
self.btn_save.setText('Save Depths to Text File')
|
|
139
|
+
|
|
140
|
+
vbl_raster.addWidget(label2)
|
|
141
|
+
vbl_raster.addWidget(self.cbox_band1)
|
|
142
|
+
vbl_raster.addWidget(labelc)
|
|
143
|
+
vbl_raster.addWidget(self.cbox_cbar)
|
|
144
|
+
vbl_raster.addWidget(label_inc)
|
|
145
|
+
vbl_raster.addWidget(self.dsb_inc)
|
|
146
|
+
vbl_raster.addWidget(label_dec)
|
|
147
|
+
vbl_raster.addWidget(self.dsb_dec)
|
|
148
|
+
vbl_raster.addWidget(self.btn_apply)
|
|
149
|
+
vbl_raster.addWidget(self.pbar)
|
|
150
|
+
vbl_raster.addItem(spacer)
|
|
151
|
+
vbl_raster.addWidget(self.btn_save)
|
|
152
|
+
vbl_raster.addWidget(helpdocs)
|
|
153
|
+
vbl_right.addWidget(self.mmc)
|
|
154
|
+
vbl_right.addWidget(mpl_toolbar)
|
|
155
|
+
|
|
156
|
+
hbl_all.addLayout(vbl_raster)
|
|
157
|
+
hbl_all.addLayout(vbl_right)
|
|
158
|
+
|
|
159
|
+
self.cbox_cbar.currentIndexChanged.connect(self.change_cbar)
|
|
160
|
+
# self.cbox_band1.currentIndexChanged.connect(self.change_band1)
|
|
161
|
+
self.btn_apply.clicked.connect(self.change_band1)
|
|
162
|
+
self.btn_save.clicked.connect(self.save_depths)
|
|
163
|
+
|
|
164
|
+
def save_depths(self):
|
|
165
|
+
""" Save Depths """
|
|
166
|
+
|
|
167
|
+
if self.depths is None:
|
|
168
|
+
return
|
|
169
|
+
|
|
170
|
+
ext = "Text File (*.csv)"
|
|
171
|
+
|
|
172
|
+
filename = QtGui.QFileDialog.getSaveFileName(self.parent,
|
|
173
|
+
'Save File', '.', ext)
|
|
174
|
+
if filename == '':
|
|
175
|
+
return False
|
|
176
|
+
|
|
177
|
+
os.chdir(filename.rpartition('/')[0])
|
|
178
|
+
np.savetxt(filename, self.depths, delimiter=',',
|
|
179
|
+
header='x, y, id, depth')
|
|
180
|
+
|
|
181
|
+
def change_cbar(self):
|
|
182
|
+
""" Change the color map for the color bar """
|
|
183
|
+
zout = self.indata['Raster'][0]
|
|
184
|
+
txt = str(self.cbox_cbar.currentText())
|
|
185
|
+
|
|
186
|
+
self.figure.clear()
|
|
187
|
+
self.axes = self.figure.add_subplot(111)
|
|
188
|
+
|
|
189
|
+
self.axes.contour(self.X, self.Y, self.Z, [0])
|
|
190
|
+
self.axes.contour(self.X, self.Y, self.Z, [45], linestyles='dashed')
|
|
191
|
+
self.axes.contour(self.X, self.Y, self.Z, [-45], linestyles='dashed')
|
|
192
|
+
|
|
193
|
+
cmap = plt.get_cmap(txt)
|
|
194
|
+
cmap2 = np.array([cmap(i) for i in range(cmap.N)])
|
|
195
|
+
low = int(cmap.N*(45/180))
|
|
196
|
+
high = int(cmap.N*(135/180))
|
|
197
|
+
cmap2[low:high] = cmap2[int(cmap.N/2)]
|
|
198
|
+
|
|
199
|
+
cmap3 = matplotlib.colors.ListedColormap(cmap2)
|
|
200
|
+
ims = self.axes.imshow(self.Z, extent=dataprep.dat_extent(zout),
|
|
201
|
+
cmap=cmap3)
|
|
202
|
+
|
|
203
|
+
if self.x0 is not None:
|
|
204
|
+
i = 0
|
|
205
|
+
self.axes.plot(self.x1[i], self.y1[i], 'oy')
|
|
206
|
+
self.axes.plot(self.x0[i], self.y0[i], 'sy')
|
|
207
|
+
self.axes.plot(self.x2[i], self.y2[i], 'oy')
|
|
208
|
+
|
|
209
|
+
# self.axes.contourf(self.X, self.Y, self.Z, [-45, 45], cmap=cmap3)
|
|
210
|
+
|
|
211
|
+
self.figure.colorbar(ims)
|
|
212
|
+
|
|
213
|
+
self.figure.canvas.draw()
|
|
214
|
+
|
|
215
|
+
def change_band1(self):
|
|
216
|
+
"""
|
|
217
|
+
Action which occurs when button is pressed. Combo box to change
|
|
218
|
+
the first band.
|
|
219
|
+
"""
|
|
220
|
+
txt = str(self.cbox_band1.currentText())
|
|
221
|
+
|
|
222
|
+
self.btn_apply.setText('Calculating...')
|
|
223
|
+
QtGui.QApplication.processEvents()
|
|
224
|
+
self.btn_apply.setEnabled(False)
|
|
225
|
+
|
|
226
|
+
for i in self.indata['Raster']:
|
|
227
|
+
if i.dataid == txt:
|
|
228
|
+
self.tiltdepth(i)
|
|
229
|
+
self.change_cbar()
|
|
230
|
+
|
|
231
|
+
self.btn_apply.setEnabled(True)
|
|
232
|
+
self.btn_apply.setText('Calculate Tilt Depth')
|
|
233
|
+
QtGui.QApplication.processEvents()
|
|
234
|
+
|
|
235
|
+
def settings(self):
|
|
236
|
+
""" This is called when the used double clicks the routine from the
|
|
237
|
+
main PyGMI interface"""
|
|
238
|
+
if 'Raster' not in self.indata:
|
|
239
|
+
return
|
|
240
|
+
|
|
241
|
+
self.indata['Raster'] = dataprep.merge(self.indata['Raster'])
|
|
242
|
+
|
|
243
|
+
data = self.indata['Raster']
|
|
244
|
+
blist = []
|
|
245
|
+
for i in data:
|
|
246
|
+
blist.append(i.dataid)
|
|
247
|
+
|
|
248
|
+
# self.cbox_band1.currentIndexChanged.disconnect()
|
|
249
|
+
self.cbox_band1.clear()
|
|
250
|
+
self.cbox_band1.addItems(blist)
|
|
251
|
+
|
|
252
|
+
# self.cbox_band1.currentIndexChanged.connect(self.change_band1)
|
|
253
|
+
|
|
254
|
+
# self.change_band1()
|
|
255
|
+
|
|
256
|
+
self.show()
|
|
257
|
+
QtGui.QApplication.processEvents()
|
|
258
|
+
|
|
259
|
+
return True
|
|
260
|
+
|
|
261
|
+
def tiltdepth(self, data):
|
|
262
|
+
""" Calculate tilt depth """
|
|
263
|
+
self.pbar.setValue(0)
|
|
264
|
+
self.pbar.setMaximum(4)
|
|
265
|
+
|
|
266
|
+
# RTP
|
|
267
|
+
inc = self.dsb_inc.value()
|
|
268
|
+
dec = self.dsb_dec.value()
|
|
269
|
+
|
|
270
|
+
zout = dataprep.rtp(data, inc, dec)
|
|
271
|
+
|
|
272
|
+
# Tilt
|
|
273
|
+
self.pbar.setValue(1)
|
|
274
|
+
|
|
275
|
+
nr, nc = zout.data.shape
|
|
276
|
+
dy, dx = np.gradient(zout.data)
|
|
277
|
+
dxtot = np.sqrt(dx**2+dy**2)
|
|
278
|
+
dz = cooper.vertical(zout.data)
|
|
279
|
+
t1 = np.arctan(dz/dxtot)
|
|
280
|
+
|
|
281
|
+
self.pbar.setValue(2)
|
|
282
|
+
# A negative number implies we are straddling 0
|
|
283
|
+
|
|
284
|
+
# Contour tilt
|
|
285
|
+
x = zout.tlx + np.arange(nc)*zout.xdim+zout.xdim/2
|
|
286
|
+
y = zout.tly - np.arange(nr)*zout.ydim-zout.ydim/2
|
|
287
|
+
X, Y = np.meshgrid(x, y)
|
|
288
|
+
Z = np.rad2deg(t1)
|
|
289
|
+
self.X = X
|
|
290
|
+
self.Y = Y
|
|
291
|
+
self.Z = Z
|
|
292
|
+
|
|
293
|
+
cnt0 = self.axes.contour(X, Y, Z, [0])
|
|
294
|
+
cnt45 = self.axes.contour(X, Y, Z, [45], alpha=0)
|
|
295
|
+
cntm45 = self.axes.contour(X, Y, Z, [-45], alpha=0)
|
|
296
|
+
|
|
297
|
+
self.pbar.setValue(3)
|
|
298
|
+
|
|
299
|
+
gx0, gy0, cgrad0, cntid0 = vgrad(cnt0)
|
|
300
|
+
gx45, gy45, cgrad45, _ = vgrad(cnt45)
|
|
301
|
+
gxm45, gym45, cgradm45, _ = vgrad(cntm45)
|
|
302
|
+
|
|
303
|
+
g0 = np.transpose([gx0, gy0])
|
|
304
|
+
|
|
305
|
+
self.pbar.setValue(4)
|
|
306
|
+
|
|
307
|
+
# dmin1 = distpc2(dx, dy, gx0, gy0, np.zeros(gx0.size, dtype=int))
|
|
308
|
+
# dmin2 = distpc2(dxm, dym, gx0, gy0, np.zeros(gx0.size, dtype=int))
|
|
309
|
+
|
|
310
|
+
dmin1 = []
|
|
311
|
+
dmin2 = []
|
|
312
|
+
|
|
313
|
+
for i, j in self.pbar.iter(g0):
|
|
314
|
+
dmin1.append(distpc(gx45, gy45, i, j, 0))
|
|
315
|
+
dmin2.append(distpc(gxm45, gym45, i, j, 0))
|
|
316
|
+
|
|
317
|
+
dx1 = gx45[dmin1] - gx0
|
|
318
|
+
dy1 = gy45[dmin1] - gy0
|
|
319
|
+
|
|
320
|
+
dx2 = gxm45[dmin2] - gx0
|
|
321
|
+
dy2 = gym45[dmin2] - gy0
|
|
322
|
+
|
|
323
|
+
grad = np.arctan2(dy1, dx1)*180/pi
|
|
324
|
+
grad[grad > 90] -= 180
|
|
325
|
+
grad[grad < -90] += 180
|
|
326
|
+
gtmp1 = np.abs(90-np.abs(grad-cgrad0))
|
|
327
|
+
|
|
328
|
+
grad = np.arctan2(dy2, dx2)*180/pi
|
|
329
|
+
grad[grad > 90] -= 180
|
|
330
|
+
grad[grad < -90] += 180
|
|
331
|
+
gtmp2 = np.abs(90-np.abs(grad-cgrad0))
|
|
332
|
+
|
|
333
|
+
gtmp = np.logical_and(gtmp1 <= 10, gtmp2 <= 10)
|
|
334
|
+
|
|
335
|
+
gx0 = gx0[gtmp]
|
|
336
|
+
gy0 = gy0[gtmp]
|
|
337
|
+
cntid0 = cntid0[gtmp]
|
|
338
|
+
dx1 = dx1[gtmp]
|
|
339
|
+
dy1 = dy1[gtmp]
|
|
340
|
+
dx2 = dx2[gtmp]
|
|
341
|
+
dy2 = dy2[gtmp]
|
|
342
|
+
|
|
343
|
+
dist1 = np.sqrt(dx1**2+dy1**2)
|
|
344
|
+
dist2 = np.sqrt(dx2**2+dy2**2)
|
|
345
|
+
|
|
346
|
+
# dist = (dist1+dist2)/2
|
|
347
|
+
dist = np.min([dist1, dist2], 0)
|
|
348
|
+
|
|
349
|
+
self.x0 = gx0
|
|
350
|
+
self.x1 = dx1+gx0
|
|
351
|
+
self.x2 = dx2+gx0
|
|
352
|
+
self.y0 = gy0
|
|
353
|
+
self.y1 = dy1+gy0
|
|
354
|
+
self.y2 = dy2+gy0
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
self.depths = np.transpose([gx0, gy0, cntid0.astype(int), dist])
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
@jit(nopython=True, nogil=True)
|
|
361
|
+
def distpc2(dx, dy, dx0, dy0, dmin):
|
|
362
|
+
""" Find closest distances """
|
|
363
|
+
|
|
364
|
+
num = dx.size
|
|
365
|
+
num2 = dx0.size
|
|
366
|
+
|
|
367
|
+
dmin2 = (dx0[0]-dx[0])**2+(dy0[0]-dy[0])**2
|
|
368
|
+
dcnt = 0
|
|
369
|
+
|
|
370
|
+
for j in range(num2):
|
|
371
|
+
for i in range(num):
|
|
372
|
+
dist = (dx0[j]-dx[i])**2+(dy0[j]-dy[i])**2
|
|
373
|
+
if dmin2 < dist:
|
|
374
|
+
dcnt = i
|
|
375
|
+
dmin2 = dist
|
|
376
|
+
dmin[j] = dcnt
|
|
377
|
+
return dmin
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
@jit(nopython=True, nogil=True)
|
|
381
|
+
def distpc(dx, dy, dx0, dy0, dcnt):
|
|
382
|
+
""" Find closest distances """
|
|
383
|
+
|
|
384
|
+
num = dx.size
|
|
385
|
+
dmin = (dx0-dx[dcnt])**2+(dy0-dy[dcnt])**2
|
|
386
|
+
|
|
387
|
+
for i in range(num):
|
|
388
|
+
dist = (dx0-dx[i])**2+(dy0-dy[i])**2
|
|
389
|
+
if dmin > dist:
|
|
390
|
+
dcnt = i
|
|
391
|
+
dmin = dist
|
|
392
|
+
|
|
393
|
+
return dcnt
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def main():
|
|
397
|
+
""" Main """
|
|
398
|
+
ifile = r'C:\Work\Programming\pygmi\data\m2920ac.ers'
|
|
399
|
+
|
|
400
|
+
data = iodefs.get_raster(ifile)
|
|
401
|
+
data = data[0]
|
|
402
|
+
|
|
403
|
+
x, y, depth = tiltdepth(data, -17, -67)
|
|
404
|
+
|
|
405
|
+
dmin = distpc(np.array([1., 2.]), np.array([1., 2.]), 3, 4, 0)
|
|
406
|
+
print(dmin)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def vgrad(cnt):
|
|
410
|
+
""" Gets contour gradients at vertices """
|
|
411
|
+
|
|
412
|
+
gx = []
|
|
413
|
+
gy = []
|
|
414
|
+
dx2 = []
|
|
415
|
+
dy2 = []
|
|
416
|
+
cntid = []
|
|
417
|
+
|
|
418
|
+
n = 0
|
|
419
|
+
for cntvert in cnt.allsegs[0]:
|
|
420
|
+
n += 1
|
|
421
|
+
|
|
422
|
+
dx = np.diff(cntvert[:, 0])
|
|
423
|
+
dy = np.diff(cntvert[:, 1])
|
|
424
|
+
|
|
425
|
+
cntid.extend([n]*dx.size)
|
|
426
|
+
|
|
427
|
+
gx.extend((cntvert[:, 0][:-1] + dx/2).tolist())
|
|
428
|
+
gy.extend((cntvert[:, 1][:-1] + dy/2).tolist())
|
|
429
|
+
dx2.extend(dx)
|
|
430
|
+
dy2.extend(dy)
|
|
431
|
+
|
|
432
|
+
cgrad = np.arctan2(dy2, dx2)
|
|
433
|
+
cgrad = np.rad2deg(cgrad)
|
|
434
|
+
cgrad[cgrad > 90] -= 180.
|
|
435
|
+
cgrad[cgrad < -90] += 180.
|
|
436
|
+
|
|
437
|
+
return np.array(gx), np.array(gy), cgrad, np.array(cntid)
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def vgrad2(cnt):
|
|
441
|
+
""" Gets contour gradients at vertices """
|
|
442
|
+
|
|
443
|
+
gx = np.array([])
|
|
444
|
+
gy = np.array([])
|
|
445
|
+
dx2 = np.array([])
|
|
446
|
+
dy2 = np.array([])
|
|
447
|
+
|
|
448
|
+
for i in cnt.collections[0].get_paths():
|
|
449
|
+
cntvert = i.vertices
|
|
450
|
+
|
|
451
|
+
dx = cntvert[:, 0][1:] - cntvert[:, 0][:-1]
|
|
452
|
+
dy = cntvert[:, 1][1:] - cntvert[:, 1][:-1]
|
|
453
|
+
|
|
454
|
+
gx = np.append(gx, cntvert[:, 0][:-1] + dx/2)
|
|
455
|
+
gy = np.append(gy, cntvert[:, 1][:-1] + dy/2)
|
|
456
|
+
dx2 = np.append(dx2, dx)
|
|
457
|
+
dy2 = np.append(dy2, dy)
|
|
458
|
+
|
|
459
|
+
cgrad = np.arctan2(dy2, dx2)
|
|
460
|
+
cgrad = np.rad2deg(cgrad)
|
|
461
|
+
cgrad[cgrad > 90] -= 180.
|
|
462
|
+
cgrad[cgrad < -90] += 180.
|
|
463
|
+
|
|
464
|
+
return gx, gy, cgrad, np.zeros_like(gx)
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def tiltdepth(data, dec, inc):
|
|
468
|
+
""" Calculate tilt depth """
|
|
469
|
+
# RTP
|
|
470
|
+
zout = dataprep.rtp(data, inc, dec)
|
|
471
|
+
|
|
472
|
+
# Tilt
|
|
473
|
+
nr, nc = zout.data.shape
|
|
474
|
+
dy, dx = np.gradient(zout.data)
|
|
475
|
+
dxtot = np.sqrt(dx**2+dy**2)
|
|
476
|
+
dz = cooper.vertical(zout.data)
|
|
477
|
+
t1 = np.arctan(dz/dxtot)
|
|
478
|
+
# A negative number implies we are straddling 0
|
|
479
|
+
|
|
480
|
+
# Contour tilt
|
|
481
|
+
x = zout.tlx + np.arange(nc)*zout.xdim+zout.xdim/2
|
|
482
|
+
y = zout.tly - np.arange(nr)*zout.ydim-zout.ydim/2
|
|
483
|
+
|
|
484
|
+
# x = zout.tlx + np.arange(nc)*zout.xdim
|
|
485
|
+
# y = zout.tly - np.arange(nr)*zout.ydim
|
|
486
|
+
X, Y = np.meshgrid(x, y)
|
|
487
|
+
Z = np.rad2deg(t1)
|
|
488
|
+
|
|
489
|
+
cnt0 = plt.contour(X, Y, Z, [0])
|
|
490
|
+
cnt45 = plt.contour(X, Y, Z, [45], alpha=0)
|
|
491
|
+
cntm45 = plt.contour(X, Y, Z, [-45], alpha=0)
|
|
492
|
+
plt.contourf(X, Y, Z, [-45, 45])
|
|
493
|
+
|
|
494
|
+
# plt.imshow(zout.data, extent=dataprep.dat_extent(zout))
|
|
495
|
+
plt.imshow(Z, extent=dataprep.dat_extent(zout))
|
|
496
|
+
plt.colorbar()
|
|
497
|
+
|
|
498
|
+
gx0, gy0, cgrad0, _ = vgrad(cnt0)
|
|
499
|
+
gx45, gy45, cgrad45, _ = vgrad(cnt45)
|
|
500
|
+
gxm45, gym45, cgradm45, _ = vgrad(cntm45)
|
|
501
|
+
|
|
502
|
+
pairs0 = []
|
|
503
|
+
pairs1 = []
|
|
504
|
+
pairs2 = []
|
|
505
|
+
|
|
506
|
+
g0 = np.transpose([gx0, gy0, cgrad0])
|
|
507
|
+
|
|
508
|
+
dx = gx45
|
|
509
|
+
dy = gy45
|
|
510
|
+
dxm = gxm45
|
|
511
|
+
dym = gym45
|
|
512
|
+
dmin1 = []
|
|
513
|
+
dmin2 = []
|
|
514
|
+
|
|
515
|
+
for i, j, k in g0:
|
|
516
|
+
dist = ne.evaluate('(dx-i)**2+(dy-j)**2')
|
|
517
|
+
dmin = np.nonzero(dist == dist.min())[0]
|
|
518
|
+
dmin1.append(dmin)
|
|
519
|
+
dx1 = dx[dmin]
|
|
520
|
+
dy1 = dy[dmin]
|
|
521
|
+
dist1 = dx1**2+dy1**2
|
|
522
|
+
|
|
523
|
+
grad = atan2(dy1-j, dx1-i)*180/pi
|
|
524
|
+
if grad > 90:
|
|
525
|
+
grad -= 180
|
|
526
|
+
elif grad < -90:
|
|
527
|
+
grad += 180
|
|
528
|
+
gtmp = abs(90-abs(grad-k))
|
|
529
|
+
if gtmp > 10:
|
|
530
|
+
continue # means all angles greater than 10 are excluded
|
|
531
|
+
|
|
532
|
+
dist = ne.evaluate('(dxm-i)**2+(dym-j)**2')
|
|
533
|
+
dmin = np.nonzero(dist == dist.min())[0]
|
|
534
|
+
dmin2.append(dmin)
|
|
535
|
+
dx2 = dxm[dmin]
|
|
536
|
+
dy2 = dym[dmin]
|
|
537
|
+
dist2 = dx2**2+dy2**2
|
|
538
|
+
|
|
539
|
+
grad = atan2(dy2-j, dx2-i)*180/pi
|
|
540
|
+
if grad > 90:
|
|
541
|
+
grad -= 180
|
|
542
|
+
elif grad < -90:
|
|
543
|
+
grad += 180
|
|
544
|
+
gtmp = abs(90-abs(grad-k))
|
|
545
|
+
if gtmp > 10:
|
|
546
|
+
continue
|
|
547
|
+
|
|
548
|
+
pairs0.append([i, j])
|
|
549
|
+
pairs1.append([dx1, dy1, dist1])
|
|
550
|
+
pairs2.append([dx2, dy2, dist2])
|
|
551
|
+
|
|
552
|
+
dmin1 = np.array(dmin1).flatten()
|
|
553
|
+
dmin2 = np.array(dmin2).flatten()
|
|
554
|
+
|
|
555
|
+
pairs0 = np.array(pairs0)
|
|
556
|
+
pairs1 = np.array(pairs1)
|
|
557
|
+
pairs2 = np.array(pairs2)
|
|
558
|
+
|
|
559
|
+
dist1 = pairs1[:, 2]
|
|
560
|
+
dist2 = pairs2[:, 2]
|
|
561
|
+
|
|
562
|
+
dist = np.min([dist1, dist2], 0)
|
|
563
|
+
|
|
564
|
+
gx0f = pairs0[:, 0]
|
|
565
|
+
gy0f = pairs0[:, 1]
|
|
566
|
+
gx45f = pairs1[:, 0]
|
|
567
|
+
gy45f = pairs1[:, 1]
|
|
568
|
+
gxm45f = pairs2[:, 0]
|
|
569
|
+
gym45f = pairs2[:, 1]
|
|
570
|
+
|
|
571
|
+
plt.axes().set_aspect('equal')
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
# plt.plot(gx0, gy0, '.')
|
|
575
|
+
# plt.plot(gx45, gy45, '.')
|
|
576
|
+
# plt.plot(gxm45, gym45, '.')
|
|
577
|
+
# pdb.set_trace()
|
|
578
|
+
|
|
579
|
+
i = 200
|
|
580
|
+
plt.plot(gx45f[i], gy45f[i], 'o')
|
|
581
|
+
plt.plot(gx0f[i], gy0f[i], 's')
|
|
582
|
+
plt.plot(gxm45f[i], gym45f[i], 'o')
|
|
583
|
+
|
|
584
|
+
plt.show()
|
|
585
|
+
|
|
586
|
+
return gx0f, gy0f, dist.flatten()
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
if __name__ == "__main__":
|
|
590
|
+
main()
|
|
File without changes
|