Skip to content

Commit 982c5c1

Browse files
committed
first working version
1 parent a6f9b18 commit 982c5c1

File tree

2 files changed

+53
-23
lines changed

2 files changed

+53
-23
lines changed

geocouche_QWidget.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from qgis.core import QgsMapLayerRegistry
1010
from geosurf.qgs_tools import loaded_point_layers, get_point_data
1111

12+
from processing import plot_stereonet
13+
1214

1315
class geocouche_QWidget( QWidget ):
1416

@@ -225,35 +227,44 @@ def process_geodata(self):
225227
_, structural_data = get_point_data(self.point_layer, self.actual_field_names, selected)
226228

227229
input_data_types = self.get_actual_data_type()
228-
229-
xy_vals, plane_orientations, lineament_orientations = self.parse_geodata(input_data_types, structural_data)
230-
231-
for rec in lineament_orientations:
232-
print rec
230+
231+
try:
232+
_, plane_orientations, lineament_orientations = self.parse_geodata(input_data_types, structural_data)
233+
except Exception, msg:
234+
self.warn(str(msg))
235+
return
236+
237+
plot_stereonet(plane_orientations, lineament_orientations)
233238

234239

235240
def parse_geodata(self, input_data_types, structural_data):
236241

237242
xy_vals = [ (float(rec[0]), float(rec[1]) ) for rec in structural_data]
238243

239-
if input_data_types["planar_data"]:
240-
if input_data_types["planar_az_type"] == "dip_dir":
241-
dipdir_vals = [ float(rec[2]) for rec in structural_data]
242-
elif input_data_types["planar_az_type"] == "strike_rhr":
243-
dipdir_raw_vals = [ float(rec[2]) + 90.0 for rec in structural_data]
244-
dipdir_vals = [ val if val < 360.0 else val - 360.0 for val in dipdir_raw_vals ]
245-
dipangle_vals = [ float(rec[3]) for rec in structural_data]
246-
plane_vals = zip(dipdir_vals, dipangle_vals)
247-
line_data_ndx_start = 4
248-
else:
249-
plane_vals = None
250-
line_data_ndx_start = 2
251-
252-
if input_data_types["linear_data"]:
253-
line_vals = [ (float(rec[line_data_ndx_start]), float(rec[line_data_ndx_start + 1])) for rec in structural_data]
254-
else:
255-
line_vals = None
256-
244+
try:
245+
if input_data_types["planar_data"]:
246+
if input_data_types["planar_az_type"] == "dip_dir":
247+
dipdir_vals = [ float(rec[2]) for rec in structural_data]
248+
elif input_data_types["planar_az_type"] == "strike_rhr":
249+
dipdir_raw_vals = [ float(rec[2]) + 90.0 for rec in structural_data]
250+
dipdir_vals = [ val if val < 360.0 else val - 360.0 for val in dipdir_raw_vals ]
251+
dipangle_vals = [ float(rec[3]) for rec in structural_data]
252+
plane_vals = zip(dipdir_vals, dipangle_vals)
253+
line_data_ndx_start = 4
254+
else:
255+
plane_vals = None
256+
line_data_ndx_start = 2
257+
except:
258+
raise Exception, "Error in planar data"
259+
260+
try:
261+
if input_data_types["linear_data"]:
262+
line_vals = [ (float(rec[line_data_ndx_start]), float(rec[line_data_ndx_start + 1])) for rec in structural_data]
263+
else:
264+
line_vals = None
265+
except:
266+
raise Exception, "Error in linear data"
267+
257268
return xy_vals, plane_vals, line_vals
258269

259270

processing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
from apsg import *
3+
4+
5+
def plot_stereonet(plane_data, line_data):
6+
7+
s = StereoNet()
8+
9+
if plane_data is not None:
10+
for plane in plane_data:
11+
p = Fol(*plane)
12+
s.plane(p)
13+
14+
if line_data is not None:
15+
for line_rec in line_data:
16+
l = Lin(*line_rec)
17+
s.line(l)
18+
19+
s.show()

0 commit comments

Comments
 (0)