Skip to content

Commit 5f3dfb2

Browse files
Refactor map2model wrapper as topology functions
1 parent 48cb912 commit 5f3dfb2

File tree

6 files changed

+245
-205
lines changed

6 files changed

+245
-205
lines changed

map2loop/map2model_wrapper.py

Lines changed: 0 additions & 190 deletions
This file was deleted.

map2loop/mapdata.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,11 +1360,10 @@ def calculate_bounding_box_and_projection(self):
13601360
def export_wkt_format_files(self):
13611361
"""
13621362
Save out the geology and fault GeoDataFrames in WKT format
1363-
This is used by map2model
1363+
This is used by topology
13641364
"""
1365-
# TODO: - Move away from tab seperators entirely (topology and map2model)
1366-
1367-
self.map2model_tmp_path = pathlib.Path(tempfile.mkdtemp())
1365+
# TODO: - Move away from tab seperators entirely (topology)
1366+
self.topology_tmp_path = pathlib.Path(tempfile.mkdtemp())
13681367

13691368
# Check geology data status and export to a WKT format file
13701369
self.load_map_data(Datatype.GEOLOGY)
@@ -1398,7 +1397,7 @@ def export_wkt_format_files(self):
13981397
geology["ROCKTYPE1"] = geology["ROCKTYPE1"].replace("", "None")
13991398
geology["ROCKTYPE2"] = geology["ROCKTYPE2"].replace("", "None")
14001399
geology.to_csv(
1401-
pathlib.Path(self.map2model_tmp_path) / "geology_wkt.csv", sep="\t", index=False
1400+
pathlib.Path(self.topology_tmp_path) / "geology_wkt.csv", sep="\t", index=False
14021401
)
14031402

14041403
# Check faults data status and export to a WKT format file
@@ -1413,7 +1412,7 @@ def export_wkt_format_files(self):
14131412
faults = self.get_map_data(Datatype.FAULT).copy()
14141413
faults.rename(columns={"geometry": "WKT"}, inplace=True)
14151414
faults.to_csv(
1416-
pathlib.Path(self.map2model_tmp_path) / "faults_wkt.csv", sep="\t", index=False
1415+
pathlib.Path(self.topology_tmp_path) / "faults_wkt.csv", sep="\t", index=False
14171416
)
14181417

14191418
@beartype.beartype

map2loop/project.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .sorter import Sorter, SorterAgeBased, SorterAlpha, SorterUseNetworkX, SorterUseHint
1111
from .stratigraphic_column import StratigraphicColumn
1212
from .deformation_history import DeformationHistory
13-
from .map2model_wrapper import Map2ModelWrapper
13+
from .topology import run_topology, calculate_unit_unit_relationships
1414
from .data_checks import validate_config_dictionary
1515

1616
# external imports
@@ -47,8 +47,8 @@ class Project(object):
4747
The name of the loop project file used in this project
4848
map_data: MapData
4949
The structure that holds all map and dtm data
50-
map2model: Map2ModelWrapper
51-
A wrapper around the map2model module that extracts unit and fault adjacency
50+
topology_results: dict
51+
A dictionary storing results from the topology process
5252
stratigraphic_column: StratigraphicColumn
5353
The structure that holds the unit information and ordering
5454
deformation_history: DeformationHistory
@@ -143,7 +143,7 @@ def __init__(
143143
self.throw_calculator = ThrowCalculatorAlpha()
144144
self.fault_orientation = FaultOrientationNearest()
145145
self.map_data = MapData(verbose_level=verbose_level)
146-
self.map2model = Map2ModelWrapper(self.map_data)
146+
self.topology_results = None
147147
self.stratigraphic_column = StratigraphicColumn()
148148
self.deformation_history = DeformationHistory(project=self)
149149
self.loop_filename = loop_project_filename
@@ -583,7 +583,7 @@ def calculate_stratigraphic_order(self, take_best=False):
583583
columns = [
584584
sorter.sort(
585585
self.stratigraphic_column.stratigraphicUnits,
586-
self.map2model.get_unit_unit_relationships(),
586+
calculate_unit_unit_relationships(self.map_data),
587587
self.map_data.contacts,
588588
self.map_data,
589589
)
@@ -613,7 +613,7 @@ def calculate_stratigraphic_order(self, take_best=False):
613613
logger.info(f'Calculating stratigraphic column using sorter {self.sorter.sorter_label}')
614614
self.stratigraphic_column.column = self.sorter.sort(
615615
self.stratigraphic_column.stratigraphicUnits,
616-
self.map2model.get_unit_unit_relationships(),
616+
calculate_unit_unit_relationships(self.map_data),
617617
self.map_data.contacts,
618618
self.map_data,
619619
)
@@ -802,7 +802,7 @@ def run_all(self, user_defined_stratigraphic_column=None, take_best=False):
802802
# Calculate the stratigraphic column
803803
if issubclass(type(user_defined_stratigraphic_column), list):
804804
self.stratigraphic_column.column = user_defined_stratigraphic_column
805-
self.map2model.run() # if we use a user defined stratigraphic column, we still need to calculate the results of map2model
805+
self.topology_results = run_topology(self.map_data)
806806
else:
807807
if user_defined_stratigraphic_column is not None:
808808
logger.warning(
@@ -1050,9 +1050,9 @@ def save_into_projectfile(self):
10501050
observations["dipPolarity"] = self.structure_samples["OVERTURNED"]
10511051
LPF.Set(self.loop_filename, "stratigraphicObservations", data=observations)
10521052

1053-
if self.map2model.fault_fault_relationships is not None:
1053+
if self.topology_results and self.topology_results.get("fault_fault_relationships") is not None:
10541054
ff_relationships = self.deformation_history.get_fault_relationships_with_ids(
1055-
self.map2model.fault_fault_relationships
1055+
self.topology_results["fault_fault_relationships"]
10561056
)
10571057
relationships = numpy.zeros(len(ff_relationships), LPF.eventRelationshipType)
10581058

0 commit comments

Comments
 (0)