Skip to content

Commit 4db4a62

Browse files
committed
check if column in df
1 parent 8df6c52 commit 4db4a62

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

loopstructural/gui/modelling/modelling_widget.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def _connectSignals(self):
116116
self.addFaultTracesToProject.clicked.connect(self.onAddFaultTracesToProject)
117117
self.addScalarFieldToProject.clicked.connect(self.onAddScalarFieldToProject)
118118
self.saveThicknessOrderButton.clicked.connect(self.saveThicknessOrder)
119+
119120
def onInitialiseModel(self):
120121

121122
columnmap = {
@@ -433,6 +434,7 @@ def onSaveModel(self):
433434
log_level=2,
434435
push=True,
435436
)
437+
436438
def saveThicknessOrder(self):
437439
layer = self.basalContactsLayer.currentLayer()
438440
layer.startEditing()
@@ -442,7 +444,7 @@ def saveThicknessOrder(self):
442444
if field_name not in [field.name() for field in layer.fields()]:
443445
layer.dataProvider().addAttributes([QgsField(field_name, QVariant.Double)])
444446
layer.updateFields()
445-
447+
446448
for unit, value in self._units.items():
447449
for feature in layer.getFeatures():
448450
if feature.attributeMap().get(self.unitNameField.currentField()) == unit:
@@ -453,7 +455,7 @@ def saveThicknessOrder(self):
453455
layer.commitChanges()
454456
layer.updateFields()
455457
self.logger(message=f"Thickness and order saved to {layer.name()}", log_level=1, push=True)
456-
458+
457459
def onPathTextChanged(self, text):
458460
self.outputPath = text
459461

loopstructural/main/loopstructuralwrapper.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pandas as pd
66
import numpy as np
77

8+
89
class QgsProcessInputData(ProcessInputData):
910
def __init__(
1011
self,
@@ -42,17 +43,22 @@ def __init__(
4243

4344
origin = (minx, miny, bottom)
4445
maximum = (maxx, maxy, top)
45-
if contact_locations is not None and 'unitname' in columnmap.keys():
46+
if contact_locations is not None and columnmap['unitname'] in contact_locations:
4647
contact_locations = contact_locations.rename(columns={columnmap['unitname']: 'name'})[
4748
['X', 'Y', 'Z', 'name']
4849
]
49-
if fault_data is not None and 'faultname' in columnmap.keys():
50+
if fault_data is not None and columnmap['faultname'] in fault_data:
5051
fault_data = fault_data.rename(columns={columnmap['faultname']: 'fault_name'})[
5152
['X', 'Y', 'Z', 'fault_name']
5253
]
5354
if np.all(fault_data['fault_name'].isna()):
5455
raise ValueError('Fault column name is all None. Check the column name')
55-
if contact_orientations is not None and 'dip' in columnmap.keys() and 'orientation' in columnmap.keys() and 'structure_unitname' in columnmap.keys():
56+
if (
57+
contact_orientations is not None
58+
and columnmap['structure_unitname'] in contact_orientations
59+
and columnmap['dip'] in contact_orientations
60+
and columnmap['orientation'] in contact_orientations
61+
):
5662
contact_orientations = contact_orientations.rename(
5763
columns={
5864
columnmap['structure_unitname']: 'name',

0 commit comments

Comments
 (0)