Skip to content

Commit 4d4d683

Browse files
committed
Modifications to help structures
1 parent d9ea284 commit 4d4d683

File tree

7 files changed

+83
-49
lines changed

7 files changed

+83
-49
lines changed

AnglesWidget.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def parse_azimuth_values(azimuths, az_type):
131131
else:
132132
plane_vals = None
133133
except Exception as e:
134-
raise Exception("Error in planar data parsing: {}".format(e.message))
134+
raise Exception("Error in planar data parsing: {}".format(e))
135135

136136
return xy_vals, plane_vals
137137

@@ -157,13 +157,10 @@ def setup_gui(self):
157157

158158
self.layout.addWidget(self.setup_inputdata())
159159
self.layout.addWidget(self.setup_processing())
160-
161-
self.pshHelp = QPushButton(self.tr("Help"))
162-
self.pshHelp.clicked.connect(self.open_help)
163-
self.layout.addWidget(self.pshHelp)
160+
self.layout.addWidget(self.setup_help())
164161

165162
self.setLayout(self.layout)
166-
self.setWindowTitle("Angles")
163+
self.setWindowTitle("{} - geological angles".format(self.pluginName))
167164
self.adjustSize()
168165

169166
def setup_inputdata(self):
@@ -194,6 +191,20 @@ def setup_processing(self):
194191

195192
return grpProcessing
196193

194+
def setup_help(self):
195+
196+
group_box = QGroupBox("Help")
197+
198+
layout = QVBoxLayout()
199+
200+
self.pshHelp = QPushButton(self.tr("Open help"))
201+
self.pshHelp.clicked.connect(self.open_help)
202+
layout.addWidget(self.pshHelp)
203+
204+
group_box.setLayout(layout)
205+
206+
return group_box
207+
197208
def user_define_angles_inparams(self):
198209

199210
self.anglesAnalysisParams = None
@@ -323,11 +334,10 @@ def __init__(self, plugin_name, parent=None):
323334
url_path = "file:///{}/help/help_geological_angles.html".format(os.path.dirname(__file__))
324335
helpTextBrwsr.setSource(QUrl(url_path))
325336
helpTextBrwsr.setSearchPaths(['{}/help'.format(os.path.dirname(__file__))])
337+
helpTextBrwsr.setMinimumSize(700, 800)
326338

327339
layout.addWidget(helpTextBrwsr)
328340

329341
self.setLayout(layout)
330342

331-
self.adjustSize()
332-
333-
self.setWindowTitle("{} - Geological Angles Help".format(plugin_name))
343+
self.setWindowTitle("{} - geological angles Help".format(plugin_name))

StereoplotWidget.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@
2828
from builtins import str
2929
from builtins import map
3030

31-
from qgis.utils import showPluginHelp
32-
3331
from .apsg import StereoNet, Lin as aLin, Fol as aFol, Fault as aFault
3432

3533
from .auxiliary_windows import *
3634
from .pygsf.orientations.orientations import Plane as GPlane, Axis as GAxis
37-
#from .gsf.geometry import GPlane, GAxis
3835
from .qgis_utils.qgs import pt_geoms_attrs
3936
from .mpl_utils.save_figure import FigureExportDlg
4037
from .fault_utils.utils import rake_to_apsg_movsense, movsense_to_apsg_movsense
@@ -131,7 +128,7 @@ def setup_gui(self):
131128
self.layout.addWidget(self.pshHelp)
132129

133130
self.setLayout(self.layout)
134-
self.setWindowTitle("Stereonet")
131+
self.setWindowTitle("{} - stereonet".format(self.pluginName))
135132
self.adjustSize()
136133

137134
def open_help(self):
@@ -517,7 +514,7 @@ def get_fault_slikenline_data(struct_vals):
517514
try:
518515
sense = rake_to_apsg_movsense(rake)
519516
except RakeInputException as e:
520-
self.warn(e.message)
517+
self.warn(e)
521518
return []
522519
elif "ln_tr" in row and "ln_pl" in row and "ln_ms" in row:
523520
lin_tr, lin_pl = row["ln_tr"], row["ln_pl"]
@@ -678,11 +675,14 @@ def save_figure(self):
678675

679676
try:
680677
self.stereonet.fig.savefig(str(fig_outpath), dpi=fig_resolution_dpi)
681-
success, msg, func = True, "Image saved", self.info
678+
success, msg = True, "Image saved"
682679
except Exception as e:
683-
success, msg, func = False, "Exception with image saving: {}".format(e.message), self.warn
684-
finally:
685-
func(msg)
680+
success, msg = False, "Exception with image saving: {}".format(e)
681+
682+
if success:
683+
self.info(msg)
684+
else:
685+
self.warn(msg)
686686

687687
def info(self, msg):
688688

@@ -730,14 +730,12 @@ def __init__(self, plugin_name, parent=None):
730730
url_path = "file:///{}/help/help_stereonet.html".format(os.path.dirname(__file__))
731731
helpTextBrwsr.setSource(QUrl(url_path))
732732
helpTextBrwsr.setSearchPaths(['{}/help'.format(os.path.dirname(__file__))])
733-
733+
helpTextBrwsr.setMinimumSize(700, 800)
734734
layout.addWidget(helpTextBrwsr)
735735

736736
self.setLayout(layout)
737737

738-
self.adjustSize()
739-
740-
self.setWindowTitle("{} - Stereonet Help".format(plugin_name))
738+
self.setWindowTitle("{} - stereonet help".format(plugin_name))
741739

742740

743741

geocouche.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .AnglesWidget import AnglesWidget
2828
from .about_dialog import about_Dialog
2929

30-
_plugin_name_ = "geocouche"
30+
_plugin_name_ = "Geocouche"
3131
_settings_name_ = "alberese"
3232

3333

@@ -84,7 +84,9 @@ def open_stereoplot_widget(self):
8484
self.warn("Geologic stereonets already open")
8585
return
8686

87-
dwgtStereoplotDockWidget = QDockWidget(self.tPluginName, self.interface.mainWindow())
87+
dwgtStereoplotDockWidget = QDockWidget(
88+
"{} - stereonet".format(self.tPluginName),
89+
self.interface.mainWindow())
8890
dwgtStereoplotDockWidget.setAttribute(Qt.WA_DeleteOnClose)
8991
dwgtStereoplotDockWidget.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
9092

metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ icon=./icons/stereoplot.png
1414

1515
; start of optional metadata
1616
changelog=
17-
2.0.1 : - help and about modified
17+
2.0.1 : - help and about sections modified
1818
2.0.0 : - porting to QGIS 3 and integration of pygsf and other minor modules
1919
1.1.0 : - integration of module "gsf" (vers. 0.1.0) and related restructuration of "geosurf" in independent modules
2020
1.0.0 : - first stable release: calculate geological angles, plot great circles and poles in stereonet

pygsf/libs_utils/gdal/ogr.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ def shapefile_create(path, geom_type, fields_dict_list, crs=None):
114114
else:
115115
outShapelayer = outShapefile.CreateLayer("layer", geom_type=geom_type)
116116

117-
for field_def_params in fields_dict_list:
118-
field_def = shapefile_create_def_field(field_def_params)
119-
outShapelayer.CreateField(field_def)
117+
map(lambda field_def_params: outShapelayer.CreateField(shapefile_create_def_field(field_def_params)),
118+
fields_dict_list)
120119

121120
return outShapefile, outShapelayer
122121

pygsf/mathematics/transformations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def deformMatrices(deform_params):
7777

7878
for deform_param in deform_params:
7979
if deform_param['type'] == 'displacement':
80-
displ_x = deform_param['parameters']['deltaX']
81-
displ_y = deform_param['parameters']['deltaY']
82-
displ_z = deform_param['parameters']['deltaZ']
80+
displ_x = deform_param['parameters']['delta_x']
81+
displ_y = deform_param['parameters']['delta_y']
82+
displ_z = deform_param['parameters']['delta_z']
8383
deformation = {'increment': 'additive',
8484
'matrix': np.array([displ_x, displ_y, displ_z])}
8585
elif deform_param['type'] == 'rotation':

pygsf/spatial/vectorial/meshes.py

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ def __init__(self, analytical_params, geogr_params, deform_params):
197197
geog_scale_matr = geographic_scale_matrix(a_range, b_range, area_height, area_width)
198198
geogr_rot_matrix = geographic_rotation_matrix(area_rot_ang_deg)
199199

200-
self.geographic_transformation_matrix = np.dot(geogr_rot_matrix, geog_scale_matr)
200+
self.geographic_transformation_matrix = dot(geogr_rot_matrix, geog_scale_matr)
201201

202202
self.geographic_offset_matrix = geographic_offset(self.geographic_transformation_matrix,
203-
np.array([a_min, b_min, 0.0]),
204-
np.array([geog_x_min, geog_y_min, 0.0]))
203+
array([a_min, b_min, 0.0]),
204+
array([geog_x_min, geog_y_min, 0.0]))
205205

206206
# apply total transformations to grid points
207207
self.deformations = deformMatrices(self.deformational_params)
@@ -295,13 +295,13 @@ def transform_loc(self, x, y, z):
295295
:return:
296296
"""
297297

298-
pt = np.dot(self.geographic_transformation_matrix, np.array([x, y, z])) + self.geographic_offset_matrix
298+
pt = dot(self.geographic_transformation_matrix, array([x, y, z])) + self.geographic_offset_matrix
299299
for deformation in self.deformations:
300300
if deformation['increment'] == 'additive':
301301
pt = pt + deformation['matrix']
302302
elif deformation['increment'] == 'multiplicative':
303303
pt = pt - deformation['shift_pt']
304-
pt = np.dot(deformation['matrix'], pt)
304+
pt = dot(deformation['matrix'], pt)
305305
pt = pt + deformation['shift_pt']
306306
return pt
307307

@@ -325,7 +325,7 @@ def geographic_scale_matrix(a_range, b_range, grid_height, grid_width):
325325
sy = grid_height / b_range
326326
sz = 1
327327

328-
return np.array([(sx, 0.0, 0.0), (0.0, sy, 0.0), (0.0, 0.0, sz)])
328+
return array([(sx, 0.0, 0.0), (0.0, sy, 0.0), (0.0, 0.0, sz)])
329329

330330

331331
def geographic_rotation_matrix(grid_rot_angle_degr):
@@ -339,7 +339,7 @@ def geographic_rotation_matrix(grid_rot_angle_degr):
339339
sin_rot_angle = sin(grid_rot_angle_rad)
340340
cos_rot_angle = cos(grid_rot_angle_rad)
341341

342-
return np.array([(cos_rot_angle, -sin_rot_angle, 0.0),
342+
return array([(cos_rot_angle, -sin_rot_angle, 0.0),
343343
(sin_rot_angle, cos_rot_angle, 0.0),
344344
(0.0, 0.0, 1.0)])
345345

@@ -353,7 +353,7 @@ def geographic_offset(transformation_matrix, llc_point_matr, llc_point_geog):
353353
:return:
354354
"""
355355

356-
return llc_point_geog - np.dot(transformation_matrix, llc_point_matr)
356+
return llc_point_geog - dot(transformation_matrix, llc_point_matr)
357357

358358

359359
def geosurface_export_vtk(output_filepath, geodata):
@@ -367,11 +367,11 @@ def geosurface_export_vtk(output_filepath, geodata):
367367
geosurface_XYZ, grid_dims = geodata
368368
X, Y, Z = geosurface_XYZ
369369

370-
X_arr = np.array(X, dtype=float)
371-
Y_arr = np.array(Y, dtype=float)
372-
Z_arr = np.array(Z, dtype=float)
370+
X_arr = array(X, dtype=float)
371+
Y_arr = array(Y, dtype=float)
372+
Z_arr = array(Z, dtype=float)
373373

374-
n_points = np.size(X_arr)
374+
n_points = size(X_arr)
375375

376376
n_rows, n_cols = grid_dims
377377

@@ -398,6 +398,8 @@ def geosurface_export_vtk(output_filepath, geodata):
398398
triangle_strip_string += "\n"
399399
outfile.write(triangle_strip_string)
400400

401+
return True
402+
401403

402404
def geosurface_export_grass(output_filepath, geodata):
403405
"""
@@ -411,9 +413,9 @@ def geosurface_export_grass(output_filepath, geodata):
411413
geosurface_XYZ, grid_dims = geodata
412414
X, Y, Z = geosurface_XYZ
413415

414-
X_arr = np.array(X, dtype=float)
415-
Y_arr = np.array(Y, dtype=float)
416-
Z_arr = np.array(Z, dtype=float)
416+
X_arr = array(X, dtype=float)
417+
Y_arr = array(Y, dtype=float)
418+
Z_arr = array(Z, dtype=float)
417419

418420
n_rows, n_cols = grid_dims
419421

@@ -443,6 +445,8 @@ def geosurface_export_grass(output_filepath, geodata):
443445
outfile.write(' %.4f %.4f %.4f\n' % (
444446
X_arr[forward_line_point_ndx], Y_arr[forward_line_point_ndx], Z_arr[forward_line_point_ndx]))
445447

448+
return True
449+
446450

447451
def geosurface_export_esri_generate(output_filepath, geodata):
448452
"""
@@ -457,9 +461,9 @@ def geosurface_export_esri_generate(output_filepath, geodata):
457461
geosurface_XYZ, grid_dims = geodata
458462
X, Y, Z = geosurface_XYZ
459463

460-
X_arr = np.array(X, dtype=float)
461-
Y_arr = np.array(Y, dtype=float)
462-
Z_arr = np.array(Z, dtype=float)
464+
X_arr = array(X, dtype=float)
465+
Y_arr = array(Y, dtype=float)
466+
Z_arr = array(Z, dtype=float)
463467

464468
n_rows, n_cols = grid_dims
465469

@@ -495,6 +499,8 @@ def geosurface_export_esri_generate(output_filepath, geodata):
495499
outfile.write('END\n')
496500
outfile.write('END\n')
497501

502+
return True
503+
498504

499505
def geosurface_save_gas(output_filepath, geodata):
500506
"""
@@ -507,6 +513,24 @@ def geosurface_save_gas(output_filepath, geodata):
507513
with open(output_filepath, 'w') as outfile:
508514
json.dump(geodata, outfile)
509515

516+
return True
517+
518+
519+
def geosurface_export_xyz( xyz_file_path, geodata, ):
520+
521+
geosurface_XYZ, _ = geodata
522+
X, Y, Z = geosurface_XYZ
523+
assert len(X) == len(Y)
524+
assert len(X) == len(Z)
525+
526+
rec_values_list2 = zip( X, Y, Z )
527+
528+
with open( xyz_file_path, "w") as ofile:
529+
for line in rec_values_list2:
530+
ofile.write( ",".join([str(val) for val in line ])+"\n")
531+
532+
return True
533+
510534

511535
def geosurface_read_gas_input(infile_path):
512536
"""
@@ -557,3 +581,4 @@ def geosurface_export_shapefile_pt3d(shapefile_path, geodata, fields_dict_list,
557581
rec_values_list2 = zip(ids, X, Y, Z)
558582
ogr_write_point_result(point_shapelayer, field_list, rec_values_list2)
559583

584+
return True

0 commit comments

Comments
 (0)