Skip to content

Commit 8286dd0

Browse files
committed
Vers.2.0.0 for QGIS 3
1 parent 0a93400 commit 8286dd0

File tree

11 files changed

+117
-90
lines changed

11 files changed

+117
-90
lines changed

AnglesWidget.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ def calculate_angles(self):
256256
dict(name='dip_angle', ogr_type=ogr.OFTReal),
257257
dict(name='angle', ogr_type=ogr.OFTReal)]
258258

259-
point_shapefile, point_shapelayer = shapefile_create(self.anglesAnalysisParams["output_shapefile_path"],
260-
ogr.wkbPoint,
261-
fields_dict_list)
259+
point_shapefile, point_shapelayer = shapefile_create(
260+
self.anglesAnalysisParams["output_shapefile_path"],
261+
ogr.wkbPoint,
262+
fields_dict_list)
262263

263264
lFields = [field_dict["name"] for field_dict in fields_dict_list]
264265

StereoplotWidget.py

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from builtins import str
2828
from builtins import map
2929

30-
#from .apsg import StereoNet, Lin as aLin, Fol as aFol, Fault as aFault
30+
from .apsg import StereoNet, Lin as aLin, Fol as aFol, Fault as aFault
3131

3232
from .auxiliary_windows import *
3333
from .pygsf.orientations.orientations import Plane as GPlane, Axis as GAxis
@@ -99,6 +99,10 @@ def setup_gui(self):
9999

100100
self.layout = QVBoxLayout()
101101

102+
self.stereonet = StereoNet()
103+
104+
self.layout.addWidget(self.stereonet.fig.canvas)
105+
102106
self.pshDefineInput = QPushButton(self.tr("Input data"))
103107
self.pshDefineInput.clicked.connect(self.define_input)
104108
self.layout.addWidget(self.pshDefineInput)
@@ -249,36 +253,39 @@ def parse_fault_mov_sense(raw_values):
249253

250254
return azim, dip_ang, lin_trend, lin_plunge, mov_sense
251255

252-
raw_values = row.split(sep)
253256
record_dict = dict()
254-
if data_type == "planes":
255-
azim, dip_ang = list(map(float, raw_values))
256-
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
257-
record_dict["pln_dipang"] = dip_ang
258-
elif data_type == "axes":
259-
trend, plunge = list(map(float, raw_values))
260-
record_dict["ln_tr"] = trend
261-
record_dict["ln_pl"] = plunge
262-
elif data_type == "planes & axes":
263-
azim, dip_ang, trend, plunge = list(map(float, raw_values))
264-
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
265-
record_dict["pln_dipang"] = dip_ang
266-
record_dict["ln_tr"] = trend
267-
record_dict["ln_pl"] = plunge
268-
elif data_type == "fault planes with slickenline trend, plunge and movement sense":
269-
azim, dip_ang, slick_tr, slick_pl, mov_sense = parse_fault_mov_sense(raw_values)
270-
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
271-
record_dict["pln_dipang"] = dip_ang
272-
record_dict["ln_tr"] = slick_tr
273-
record_dict["ln_pl"] = slick_pl
274-
record_dict["ln_ms"] = mov_sense
275-
elif data_type == "fault planes with rake":
276-
azim, dip_ang, rake = list(map(float, raw_values))
277-
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
278-
record_dict["pln_dipang"] = dip_ang
279-
record_dict["ln_rk"] = rake
280-
else:
281-
raise Exception("Unimplemented input type")
257+
try:
258+
raw_values = row.split(sep)
259+
if data_type == "planes":
260+
azim, dip_ang = list(map(float, raw_values))
261+
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
262+
record_dict["pln_dipang"] = dip_ang
263+
elif data_type == "axes":
264+
trend, plunge = list(map(float, raw_values))
265+
record_dict["ln_tr"] = trend
266+
record_dict["ln_pl"] = plunge
267+
elif data_type == "planes & axes":
268+
azim, dip_ang, trend, plunge = list(map(float, raw_values))
269+
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
270+
record_dict["pln_dipang"] = dip_ang
271+
record_dict["ln_tr"] = trend
272+
record_dict["ln_pl"] = plunge
273+
elif data_type == "fault planes with slickenline trend, plunge and movement sense":
274+
azim, dip_ang, slick_tr, slick_pl, mov_sense = parse_fault_mov_sense(raw_values)
275+
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
276+
record_dict["pln_dipang"] = dip_ang
277+
record_dict["ln_tr"] = slick_tr
278+
record_dict["ln_pl"] = slick_pl
279+
record_dict["ln_ms"] = mov_sense
280+
elif data_type == "fault planes with rake":
281+
azim, dip_ang, rake = list(map(float, raw_values))
282+
record_dict["pln_dipdir"] = parse_plane_dirdir(azim)
283+
record_dict["pln_dipang"] = dip_ang
284+
record_dict["ln_rk"] = rake
285+
else:
286+
raise Exception("Unimplemented input type")
287+
except:
288+
self.warn("Check input values")
282289

283290
return record_dict
284291

@@ -291,12 +298,11 @@ def parse_fault_mov_sense(raw_values):
291298
geostructural_data = []
292299
for row in rows:
293300
if row:
294-
try:
295-
geostructural_data.append(extract_values(row))
296-
except Exception as e:
297-
return False, e.message
298-
else:
299-
continue
301+
data_row = extract_values(row)
302+
if not data_row:
303+
return False, "Error with input"
304+
else:
305+
geostructural_data.append(data_row)
300306

301307
if geostructural_data:
302308
return True, geostructural_data
@@ -455,7 +461,7 @@ def parse_transparency(tTranspar):
455461

456462
def downaxis_from_rake(dipdir, dipang, rk):
457463

458-
return GPlane(dipdir, dipang).rake_to_gv(float(rk)).downward.tp
464+
return GPlane(dipdir, dipang).rakeToDirect(float(rk)).downward().d
459465

460466
def get_plane_data(struct_vals):
461467

@@ -548,7 +554,7 @@ def get_fault_slikenline_data(struct_vals):
548554
color=line_color,
549555
alpha=line_alpha)
550556
elif plot_setts["tPlotPlanesFormat"] == "normal axes":
551-
line_rec = GPlane(*plane).normal.downward.tp
557+
line_rec = GPlane(*plane).normDirect().d
552558
l = aLin(*line_rec)
553559
self.stereonet.line(l,
554560
marker=marker_style,

apsg/Note

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
commented lines 6-10 in helpers.py to avoid dependency in possibly missing Scipy module

apsg/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
from __future__ import division
44
import numpy as np
5+
"""
56
from scipy.stats import uniform
67
from scipy.special import gamma as gamma_fun
78
from scipy.special import iv as modified_bessel_2ndkind
89
from scipy.special import ivp as modified_bessel_2ndkind_derivative
910
from scipy.stats import norm as gauss
11+
"""
1012

1113
def sind(x):
1214
return np.sin(np.deg2rad(x))

auxiliary_windows.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,9 @@ def __init__(self, parent=None):
425425

426426
btnOk = QPushButton("&OK")
427427
btnCancel = QPushButton("Cancel")
428-
self.connect(btnOk, SIGNAL("clicked()"),
429-
self, SLOT("accept()"))
430-
self.connect(btnCancel, SIGNAL("clicked()"),
431-
self, SLOT("reject()"))
428+
429+
btnOk.clicked.connect(self.accept)
430+
btnCancel.clicked.connect(self.reject)
432431

433432
lytButtons = QHBoxLayout()
434433
lytButtons.addStretch()
@@ -547,10 +546,8 @@ def __init__(self, dFigureParams, parent=None):
547546

548547
layout.addLayout(lytButtons)
549548

550-
self.connect(btnOk, SIGNAL("clicked()"),
551-
self, SLOT("accept()"))
552-
self.connect(btnCancel, SIGNAL("clicked()"),
553-
self, SLOT("reject()"))
549+
btnOk.clicked.connect(self.accept)
550+
btnCancel.clicked.connect(self.reject)
554551

555552
self.setLayout(layout)
556553

fault_utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def rake_to_apsg_movsense(rake):
1515

1616
def movsense_to_apsg_movsense(str_val):
1717

18-
if str_val == "R":
18+
if str_val.upper()[0] == "R":
1919
return 1
20-
elif str_val == "N":
20+
elif str_val.upper()[0] == "N":
2121
return -1
2222
else:
2323
raise RakeInputException("Input rake value not acceptable")

geocouche.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def open_cal_angles_widget(self):
118118

119119
def open_html_help(self):
120120

121-
webbrowser.open('{}/help/help.html'.format(os.path.dirname(__file__)), new=True)
121+
dialog = HelpDialog()
122+
dialog.exec_()
122123

123124
def stereoplot_off(self):
124125

@@ -142,3 +143,24 @@ def unload(self):
142143
self.interface.removePluginMenu(self.tPluginName, self.actAngles)
143144
self.interface.removePluginMenu(self.tPluginName, self.actHelp)
144145

146+
147+
class HelpDialog(QDialog):
148+
149+
def __init__(self, parent=None):
150+
super(HelpDialog, self).__init__(parent)
151+
152+
layout = QVBoxLayout()
153+
154+
# About section
155+
156+
helpTextBrwsr = QTextBrowser(self)
157+
158+
helpTextBrwsr.setSource(QUrl('{}/help/help.html'.format(os.path.dirname(__file__))))
159+
helpTextBrwsr.setSearchPaths(['{}/help'.format(os.path.dirname(__file__))])
160+
161+
layout.addWidget(helpTextBrwsr)
162+
163+
self.setLayout(layout)
164+
165+
self.setWindowTitle("{} Help".format(_plugin_name_))
166+

help/help.html

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ <h1>geocouche</h1>
2020
<br />
2121
<br />Currently, it can:
2222
<ul>
23-
<li>plot data in stereonets - from point layer or text input</li>
23+
<li>plot data in stereonets - from point layer or text input</li>
2424
<li>calculate the angles between planes stored in a layer and a reference plane</li>
2525

2626
</ul>
2727
These two tools are available in the QGIS plugin interface (Fig. 1).
28-
28+
<br /><br />
2929
<figure>
3030
<img src="ims/screenshot_01.png" alt="plugin QGIS interface">
31+
<br />
3132
<figcaption>Fig. 1. <b>geocouche</b> interface.</figcaption>
3233
</figure>
33-
34+
<br /><br />
3435
The two tools are:
3536
<ul>
3637
<li>Geological stereonets</li>
@@ -39,20 +40,19 @@ <h1>geocouche</h1>
3940
</ul>
4041

4142
</div>
42-
43-
4443

4544
<h2>Geological stereonets</h2>
4645

4746
With this module it is possible to create stereonets representing geological plane and axis/slickenline attitudes
4847
as great circles, poles, faults with slickenlines and T-L diagrams.
4948
Its interface is represented in Fig. 2.
50-
49+
<br /><br />
5150
<figure>
5251
<img src="ims/geocouche_bl_total.png" alt="Geological stereonets">
52+
<br />
5353
<figcaption>Fig. 2. Stereonet interface.</figcaption>
5454
</figure>
55-
55+
<br /><br />
5656
To plot data in a stereoplot, there are three main steps to follow:
5757
<ul>
5858
<li>Choice of input data</li>
@@ -79,13 +79,14 @@ <h4>Input from point layer</h4>
7979
<br />
8080
Remember that rake information takes precedence over (shadows) line trend/dip and optional movement sense, even if you want just to plot
8181
data as planes and lines, not just as faults with slickenlines.
82-
<br />
8382

84-
83+
<br /><br />
8584
<figure>
8685
<img src="ims/geocouche_bl_input_layer.png" alt="Input from point layer">
86+
<br />
8787
<figcaption>Fig. 3. Interface for input from point layer interface.</figcaption>
8888
</figure>
89+
<br /><br />
8990

9091
To plot faults, the movement sense or the fault rake must be also defined.
9192
Since the current (incorporated) version of <b>apsg</b> do not explicitly support <u>pure</u> transcurrent faults,
@@ -117,67 +118,70 @@ <h4>Input from text</h4>
117118
</ul>
118119
Another option to take care of for plane data, is whether orientations are expressed
119120
using dip direction or RHR strike.
120-
121+
<br /><br />
121122
<figure>
122123
<img src="ims/geocouche_bl_input_text.png" alt="Input from text">
124+
<br />
123125
<figcaption>Fig. 4. Input from text interface.</figcaption>
124126
</figure>
125-
127+
<br /><br />
126128
<h3>Plot style</h3>
127129

128130
Styles can be defined for both great circles and poles: color, width/size, line/marker style, and transparency (Fig. 5).
129131
<br />Settings are stored in memory and resused in subsequent sessions.
130-
132+
<br /><br />
131133
<figure>
132134
<img src="ims/geocouche_bl_plot_style.png" alt="Plot style">
135+
<br />
133136
<figcaption>Fig. 5. Plot style interface.</figcaption>
134137
</figure>
135-
138+
<br /><br />
136139
<h3>Stereonet plotting</h3>
137140

138141
Plots can use a new or a pre-existing stereonet plot. Previous plots can be erased by using the button <b>Clear stereonet</b> (see Fig. 2).
139142
<br />Plane can be plotted as great circles or as plane normals, axes as poles or as normal great circles, faults with slickenlines
140143
as great circles with arrows or alternatvely as T-L diagrams (Fig. 6).
141-
144+
<br /><br />
142145
<figure>
143146
<img src="ims/geocouche_bl_plot_choices.png" alt="Stereonet plotting">
147+
<br />
144148
<figcaption>Fig. 6. Stereonet plot interface.</figcaption>
145149
</figure>
146-
150+
<br /><br />
147151
An example of stereonet is shown in Fig. 7.
148-
152+
<br /><br />
149153
<figure>
150154
<img src="ims/stereonet_06.png" alt="Stereonet interface">
155+
<br />
151156
<figcaption>Fig. 7. Stereonet example.</figcaption>
152157
</figure>
153-
154-
158+
<br /><br />
155159

156160
<h2>Geological angles</h2>
157161

158162
This tool allows to calculate the angles (as degrees) between a reference plane and the (eventually selected) features in a point layer (Fig. 8).
159163
<br />It can be applied to determine the degree of misalignement between a reference (for instance, regional) measure and local geological measures.
160-
164+
<br /><br />
161165
<figure>
162166
<img src="ims/angles_01.png" alt="Calculate Angles interface">
167+
<br />
163168
<figcaption>Fig. 8. Geological angles calculation interface.</figcaption>
164169
</figure>
165-
170+
<br /><br />
166171
The user has to define the two fields storing the azimuth (dip direction or RHR strike) and the dip angle of each feature,
167172
the attitude of the reference plane, and the name of the output shapefile with a new field storing the calculated angle (Fig. 9).
168-
173+
<br /><br />
169174
<figure>
170175
<img src="ims/angles_02.png" alt="Definition of parameters">
176+
<br />
171177
<figcaption>Fig. 9. Definition of parameters for angle calculation.</figcaption>
172178
</figure>
173-
174-
175-
176179
<br /><br />
180+
177181
<div style="font-size: 85%; font-style: italic;">
178182
-----
179183
<br /><br />
180-
Doc version 2017-06-03, by Mauro Alberti - <a href="mailto:alberti.m65@gmail.com">alberti.m65@gmail.com</a>
184+
Doc version 2018-08-12, by Mauro Alberti - <a href="mailto:alberti.m65@gmail.com">alberti.m65@gmail.com</a>
181185
</div>
182186

183187
<br /><br />

0 commit comments

Comments
 (0)