Skip to content

Commit

Permalink
first working version
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroalberti committed Apr 26, 2015
1 parent a6f9b18 commit 982c5c1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 23 deletions.
57 changes: 34 additions & 23 deletions geocouche_QWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from qgis.core import QgsMapLayerRegistry
from geosurf.qgs_tools import loaded_point_layers, get_point_data

from processing import plot_stereonet


class geocouche_QWidget( QWidget ):

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

input_data_types = self.get_actual_data_type()

xy_vals, plane_orientations, lineament_orientations = self.parse_geodata(input_data_types, structural_data)

for rec in lineament_orientations:
print rec

try:
_, plane_orientations, lineament_orientations = self.parse_geodata(input_data_types, structural_data)
except Exception, msg:
self.warn(str(msg))
return

plot_stereonet(plane_orientations, lineament_orientations)


def parse_geodata(self, input_data_types, structural_data):

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

if input_data_types["planar_data"]:
if input_data_types["planar_az_type"] == "dip_dir":
dipdir_vals = [ float(rec[2]) for rec in structural_data]
elif input_data_types["planar_az_type"] == "strike_rhr":
dipdir_raw_vals = [ float(rec[2]) + 90.0 for rec in structural_data]
dipdir_vals = [ val if val < 360.0 else val - 360.0 for val in dipdir_raw_vals ]
dipangle_vals = [ float(rec[3]) for rec in structural_data]
plane_vals = zip(dipdir_vals, dipangle_vals)
line_data_ndx_start = 4
else:
plane_vals = None
line_data_ndx_start = 2

if input_data_types["linear_data"]:
line_vals = [ (float(rec[line_data_ndx_start]), float(rec[line_data_ndx_start + 1])) for rec in structural_data]
else:
line_vals = None

try:
if input_data_types["planar_data"]:
if input_data_types["planar_az_type"] == "dip_dir":
dipdir_vals = [ float(rec[2]) for rec in structural_data]
elif input_data_types["planar_az_type"] == "strike_rhr":
dipdir_raw_vals = [ float(rec[2]) + 90.0 for rec in structural_data]
dipdir_vals = [ val if val < 360.0 else val - 360.0 for val in dipdir_raw_vals ]
dipangle_vals = [ float(rec[3]) for rec in structural_data]
plane_vals = zip(dipdir_vals, dipangle_vals)
line_data_ndx_start = 4
else:
plane_vals = None
line_data_ndx_start = 2
except:
raise Exception, "Error in planar data"

try:
if input_data_types["linear_data"]:
line_vals = [ (float(rec[line_data_ndx_start]), float(rec[line_data_ndx_start + 1])) for rec in structural_data]
else:
line_vals = None
except:
raise Exception, "Error in linear data"

return xy_vals, plane_vals, line_vals


Expand Down
19 changes: 19 additions & 0 deletions processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from apsg import *


def plot_stereonet(plane_data, line_data):

s = StereoNet()

if plane_data is not None:
for plane in plane_data:
p = Fol(*plane)
s.plane(p)

if line_data is not None:
for line_rec in line_data:
l = Lin(*line_rec)
s.line(l)

s.show()

0 comments on commit 982c5c1

Please sign in to comment.