Skip to content

Commit 8175437

Browse files
committed
fix: formatting
1 parent 754541f commit 8175437

File tree

8 files changed

+22
-209
lines changed

8 files changed

+22
-209
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,4 @@ docs/source/test/*
131131
examples/*.png
132132
dev/scalar_field
133133
dev/unconf
134+
docs/source/sg_execution_times.rst

LoopStructural/interpolators/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ class InterpolatorType(IntEnum):
8989
InterpolatorType.BASE_DATA_SUPPORTED: GeologicalInterpolator,
9090
# InterpolatorType.SURFE: SurfeRBFInterpolator,
9191
}
92+
from ._interpolator_factory import InterpolatorFactory

LoopStructural/interpolators/_interpolator_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from . import interpolator_map, InterpolatorType, support_interpolator_map
3+
from . import interpolator_map, InterpolatorType # , support_interpolator_map
44
from LoopStructural.utils import BoundingBox
55
from typing import Optional
66
import numpy as np
@@ -32,9 +32,9 @@ def create_interpolator(
3232
bounding_box=boundingbox,
3333
nelements=nelements,
3434
element_volume=element_volume,
35-
)
35+
)
3636
return interpolator_map[interpolatortype](support)
37-
37+
3838
@staticmethod
3939
def from_dict(d):
4040
d = d.copy()

LoopStructural/interpolators/_p2interpolator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Piecewise linear interpolator
33
"""
44
import logging
5+
from typing import Optional
56

67
import numpy as np
78

@@ -169,7 +170,7 @@ def add_value_constraints(self, w=1.0):
169170
)
170171

171172
def minimise_grad_steepness(
172-
self, w: float = 0.1, maskall: bool = False, wtfunc: callable = None
173+
self, w: float = 0.1, maskall: bool = False, wtfunc: Optional[callable] = None
173174
):
174175
"""This constraint minimises the second derivative of the gradient
175176
mimimising the 2nd derivative should prevent high curvature solutions

LoopStructural/interpolators/supports/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class SupportType(IntEnum):
3939
SupportType.P2UnstructuredTetMesh: P2UnstructuredTetMesh,
4040
}
4141

42+
from ._support_factory import SupportFactory
43+
4244
__all__ = [
4345
"BaseUnstructured2d",
4446
"P1Unstructured2d",

LoopStructural/modelling/core/geological_model.py

Lines changed: 11 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -696,202 +696,6 @@ def set_stratigraphic_column(self, stratigraphic_column, cmap="tab20"):
696696

697697
self.stratigraphic_column = stratigraphic_column
698698

699-
# ## TODO CREATE SEPARATE API FOR THIS
700-
# def get_interpolator(
701-
# self,
702-
# interpolatortype="FDI",
703-
# nelements=1e4,
704-
# buffer=0.2,
705-
# element_volume=None,
706-
# **kwargs,
707-
# ):
708-
# """
709-
# Returns an interpolator given the arguments, also constructs a
710-
# support for a discrete interpolator
711-
712-
# Parameters
713-
# ----------
714-
# interpolatortype : string
715-
# define the interpolator type
716-
# nelements : int
717-
# number of elements in the interpolator
718-
# buffer : double or numpy array 3x1
719-
# value(s) between 0,1 specifying the buffer around the bounding box
720-
# data_bb : bool
721-
# whether to use the model boundary or the boundary around
722-
# kwargs : no kwargs used, this just catches any additional arguments
723-
724-
# Returns
725-
# -------
726-
# interpolator : GeologicalInterpolator
727-
# A geological interpolator
728-
729-
# Notes
730-
# -----
731-
# This method will create a geological interpolator for the bounding box of the model. A
732-
# buffer area is added to the interpolation region to avoid boundaries and issues with faults.
733-
# This function wil create a :class:`LoopStructural.interpolators.GeologicalInterpolator` which can either be:
734-
# A discrete interpolator :class:`LoopStructural.interpolators.DiscreteInterpolator`
735-
736-
# - 'FDI' :class:`LoopStructural.interpolators.FiniteDifferenceInterpolator`
737-
# - 'PLI' :class:`LoopStructural.interpolators.PiecewiseLinearInterpolator`
738-
# - 'P1' :class:`LoopStructural.interpolators.P1Interpolator`
739-
# - 'DFI' :class:`LoopStructural.interpolators.DiscreteFoldInterpolator`
740-
# - 'P2' :class:`LoopStructural.interpolators.P2Interpolator`
741-
# or
742-
743-
# - 'surfe' :class:`LoopStructural.interpolators.SurfeRBFInterpolator`
744-
745-
# The discrete interpolators will require a support.
746-
747-
# - 'PLI','DFI','P1Interpolator','P2Interpolator' :class:`LoopStructural.interpolators.supports.TetMesh` or you can provide another
748-
# mesh builder which returns :class:`LoopStructural.interpolators.support.UnStructuredTetMesh`
749-
750-
# - 'FDI' :class:`LoopStructural.interpolators.supports.StructuredGrid`
751-
# """
752-
# bb = np.copy(self.bounding_box)
753-
# # add a buffer to the interpolation domain, this is necessary for
754-
# # faults but also generally a good
755-
# # idea to avoid boundary problems
756-
# # buffer = bb[1, :]
757-
# buffer = (np.min(bb[1, :] - bb[0, :])) * buffer
758-
# bb[0, :] -= buffer # *(bb[1,:]-bb[0,:])
759-
# bb[1, :] += buffer # *(bb[1,:]-bb[0,:])
760-
# box_vol = (bb[1, 0] - bb[0, 0]) * (bb[1, 1] - bb[0, 1]) * (bb[1, 2] - bb[0, 2])
761-
# if interpolatortype == "PLI" and pli:
762-
# if element_volume is None:
763-
# # nelements /= 5
764-
# element_volume = box_vol / nelements
765-
# # calculate the step vector of a regular cube
766-
# step_vector = np.zeros(3)
767-
# step_vector[:] = element_volume ** (1.0 / 3.0)
768-
# # step_vector /= np.array([1,1,2])
769-
# # number of steps is the length of the box / step vector
770-
# nsteps = np.ceil((bb[1, :] - bb[0, :]) / step_vector).astype(int)
771-
# if np.any(np.less(nsteps, 3)):
772-
# axis_labels = ["x", "y", "z"]
773-
# for i in range(3):
774-
# if nsteps[i] < 3:
775-
# logger.error(
776-
# f"Number of steps in direction {axis_labels[i]} is too small, try increasing nelements"
777-
# )
778-
# logger.error("Cannot create interpolator: number of steps is too small")
779-
# raise ValueError("Number of steps too small cannot create interpolator")
780-
# # create a structured grid using the origin and number of steps
781-
# if self.reuse_supports:
782-
# mesh_id = f"mesh_{nelements}"
783-
# mesh = self.support.get(
784-
# mesh_id,
785-
# TetMesh(origin=bb[0, :], nsteps=nsteps, step_vector=step_vector),
786-
# )
787-
# if mesh_id not in self.support:
788-
# self.support[mesh_id] = mesh
789-
# else:
790-
# if "meshbuilder" in kwargs:
791-
# mesh = kwargs["meshbuilder"](bb, nelements)
792-
# else:
793-
# mesh = TetMesh(
794-
# origin=bb[0, :], nsteps=nsteps, step_vector=step_vector
795-
# )
796-
# logger.info(
797-
# "Creating regular tetrahedron mesh with %i elements \n"
798-
# "for modelling using PLI" % (mesh.ntetra)
799-
# )
800-
801-
# return PLI(mesh)
802-
# if interpolatortype == "P2":
803-
# if element_volume is None:
804-
# # nelements /= 5
805-
# element_volume = box_vol / nelements
806-
# # calculate the step vector of a regular cube
807-
# step_vector = np.zeros(3)
808-
# step_vector[:] = element_volume ** (1.0 / 3.0)
809-
# # step_vector /= np.array([1,1,2])
810-
# # number of steps is the length of the box / step vector
811-
# nsteps = np.ceil((bb[1, :] - bb[0, :]) / step_vector).astype(int)
812-
# if "meshbuilder" in kwargs:
813-
# mesh = kwargs["meshbuilder"](bb, nelements)
814-
# else:
815-
# raise NotImplementedError(
816-
# "Cannot use P2 interpolator without external mesh"
817-
# )
818-
# logger.info(
819-
# "Creating regular tetrahedron mesh with %i elements \n"
820-
# "for modelling using P2" % (mesh.ntetra)
821-
# )
822-
# return P2Interpolator(mesh)
823-
# if interpolatortype == "FDI":
824-
# # find the volume of one element
825-
# if element_volume is None:
826-
# element_volume = box_vol / nelements
827-
# # calculate the step vector of a regular cube
828-
# step_vector = np.zeros(3)
829-
# step_vector[:] = element_volume ** (1.0 / 3.0)
830-
# # number of steps is the length of the box / step vector
831-
# nsteps = np.ceil((bb[1, :] - bb[0, :]) / step_vector).astype(int)
832-
# if np.any(np.less(nsteps, 3)):
833-
# logger.error("Cannot create interpolator: number of steps is too small")
834-
# axis_labels = ["x", "y", "z"]
835-
# for i in range(3):
836-
# if nsteps[i] < 3:
837-
# logger.error(
838-
# f"Number of steps in direction {axis_labels[i]} is too small, try increasing nelements"
839-
# )
840-
# raise ValueError("Number of steps too small cannot create interpolator")
841-
# # create a structured grid using the origin and number of steps
842-
# if self.reuse_supports:
843-
# grid_id = "grid_{}".format(nelements)
844-
# grid = self.support.get(
845-
# grid_id,
846-
# StructuredGrid(
847-
# origin=bb[0, :], nsteps=nsteps, step_vector=step_vector
848-
# ),
849-
# )
850-
# if grid_id not in self.support:
851-
# self.support[grid_id] = grid
852-
# else:
853-
# grid = StructuredGrid(
854-
# origin=bb[0, :], nsteps=nsteps, step_vector=step_vector
855-
# )
856-
# logger.info(
857-
# f"Creating regular grid with {grid.n_elements} elements \n"
858-
# "for modelling using FDI"
859-
# )
860-
# return FDI(grid)
861-
862-
# if interpolatortype == "DFI" and dfi is True:
863-
# if element_volume is None:
864-
# nelements /= 5
865-
# element_volume = box_vol / nelements
866-
# # calculate the step vector of a regular cube
867-
# step_vector = np.zeros(3)
868-
# step_vector[:] = element_volume ** (1.0 / 3.0)
869-
# # number of steps is the length of the box / step vector
870-
# nsteps = np.ceil((bb[1, :] - bb[0, :]) / step_vector).astype(int)
871-
# # create a structured grid using the origin and number of steps
872-
# if "meshbuilder" in kwargs:
873-
# mesh = kwargs["meshbuilder"].build(bb, nelements)
874-
# else:
875-
# mesh = kwargs.get(
876-
# "mesh",
877-
# TetMesh(origin=bb[0, :], nsteps=nsteps, step_vector=step_vector),
878-
# )
879-
# logger.info(
880-
# f"Creating regular tetrahedron mesh with {mesh.ntetra} elements \n"
881-
# "for modelling using DFI"
882-
# )
883-
# return DFI(mesh, kwargs["fold"])
884-
# if interpolatortype == "Surfe" or interpolatortype == "surfe":
885-
# # move import of surfe to where we actually try and use it
886-
# if not surfe:
887-
# logger.warning("Cannot import Surfe, try another interpolator")
888-
# raise ImportError("Cannot import surfepy, try pip install surfe")
889-
# method = kwargs.get("method", "single_surface")
890-
# logger.info("Using surfe interpolator")
891-
# return Surfe(method)
892-
# logger.warning("No interpolator")
893-
# raise InterpolatorError("Could not create interpolator")
894-
895699
def create_and_add_foliation(
896700
self,
897701
series_surface_data: str,
@@ -1142,9 +946,7 @@ def create_and_add_folded_fold_frame(
1142946
fold_frame = self.features[-1]
1143947
assert type(fold_frame) == FoldFrame, "Please specify a FoldFrame"
1144948
fold = FoldEvent(fold_frame, name=f"Fold_{fold_frame_data}")
1145-
# fold_interpolator = self.get_interpolator("DFI", fold=fold, **kwargs)
1146-
# gy_fold_interpolator = self.get_interpolator("DFI", fold=fold, **kwargs)
1147-
# frame_interpolator = self.get_interpolator(**kwargs)
949+
1148950
interpolatortypes = [
1149951
"DFI",
1150952
"FDI",
@@ -1461,7 +1263,9 @@ def add_onlap_unconformity(
14611263

14621264
return uc_feature
14631265

1464-
def create_and_add_domain_fault(self, fault_surface_data, **kwargs):
1266+
def create_and_add_domain_fault(
1267+
self, fault_surface_data, nelements=10000, interpolatortype="FDI", **kwargs
1268+
):
14651269
"""
14661270
Parameters
14671271
----------
@@ -1478,10 +1282,14 @@ def create_and_add_domain_fault(self, fault_surface_data, **kwargs):
14781282
* :meth:`LoopStructural.GeologicalModel.get_interpolator`
14791283
14801284
"""
1481-
interpolator = self.get_interpolator(**kwargs)
14821285
domain_fault_feature_builder = GeologicalFeatureBuilder(
1483-
interpolator, name=fault_surface_data
1286+
bounding_box=self.bounding_box,
1287+
interpolatortype=interpolatortype,
1288+
nelements=nelements,
1289+
name=fault_surface_data,
1290+
**kwargs,
14841291
)
1292+
14851293
# add data
14861294
unconformity_data = self.data[self.data["feature_name"] == fault_surface_data]
14871295

@@ -1495,7 +1303,7 @@ def create_and_add_domain_fault(self, fault_surface_data, **kwargs):
14951303
# domain_fault = domain_fault_feature_builder.build(**kwargs)
14961304
domain_fault = domain_fault_feature_builder.feature
14971305
domain_fault_feature_builder.build_arguments = kwargs
1498-
domain_fault.type = "domain_fault"
1306+
domain_fault.type = FeatureType.DOMAINFAULT
14991307
self._add_feature(domain_fault)
15001308
self._add_domain_fault_below(domain_fault)
15011309

@@ -1800,7 +1608,6 @@ def regular_grid(self, nsteps=None, shuffle=True, rescale=False, order="C"):
18001608
def evaluate_model(self, xyz, scale=True):
18011609
"""Evaluate the stratigraphic id at each location
18021610
1803-
18041611
Parameters
18051612
----------
18061613
xyz : np.array((N,3),dtype=float)

LoopStructural/modelling/features/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class FeatureType(IntEnum):
2020
UNCONFORMITY = 7
2121
INTRUSION = 8
2222
FAULT = 9
23+
DOMAINFAULT = 10
2324

2425

2526
from ._base_geological_feature import BaseFeature

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
setup(
3333
name="LoopStructural",
3434
install_requires=[
35-
"numpy>=1.18", # need to fix numpy to 1.18 because we build against it
35+
"numpy>=1.18",
3636
"pandas",
3737
"scipy",
3838
"scikit-image",

0 commit comments

Comments
 (0)