Skip to content

Commit

Permalink
fix: variogram parameters now in set_sgs_parameters
Browse files Browse the repository at this point in the history
- set_c_GSLIBparameters now includes variogram parameters
and make_variogram functions only compute variogram
- general cleaning, remove of print() and unused instances.
  • Loading branch information
Fer071989 committed Mar 8, 2022
1 parent 2507b33 commit 26ca7b3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 95 deletions.
28 changes: 4 additions & 24 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,41 +1180,21 @@ def create_and_add_intrusion(
)

intrusion_frame = intrusion_frame_builder.frame

# -- create intrusion builder to simulate distance thresholds along frame coordinates
intrusion_builder = IntrusionBuilder(
intrusion_frame, model=self, name=f"{intrusion_frame_name}_feature"
intrusion_frame, model=self, name=f"{intrusion_name}_feature"
)
intrusion_builder.lateral_extent_model = intrusion_lateral_extent_model
intrusion_builder.vertical_extent_model = intrusion_vertical_extent_model

# # -- Create intrusion feature
# intrusion_feature = IntrusionFeature(
# intrusion_name, model=self
# )

# if intrusion_lateral_extent_model == None:
# logger.error(
# "Specify conceptual model function for intrusion lateral extent"
# )
# else:
# intrusion_feature.lateral_extent_model = intrusion_lateral_extent_model

# if intrusion_vertical_extent_model == None:
# logger.error(
# "Specify conceptual model function for intrusion vertical extent"
# )
# else:
# intrusion_feature.vertical_extent_model = intrusion_vertical_extent_model

# logger.info("setting data for thresholds simulation")
intrusion_builder.set_data_for_extent_simulation(intrusion_data)
intrusion_builder.build_arguments = {
"lateral_extent_sgs_parameters": lateral_extent_sgs_parameters,
"vertical_extent_sgs_parameters": vertical_extent_sgs_parameters,
}
# intrusion_builder.vertical_extent_sgs_parameters = vertical_extent_sgs_parameters
# intrusion_builder.lateral_extent_sgs_parameters = lateral_extent_sgs_parameters
# intrusion_builder.set_l_sgs_GSLIBparameters(lateral_extent_sgs_parameters)
# intrusion_builder.set_g_sgs_GSLIBparameters(vertical_extent_sgs_parameters)

intrusion_feature = intrusion_builder.feature
self._add_feature(intrusion_feature)

Expand Down
95 changes: 61 additions & 34 deletions LoopStructural/modelling/intrusions/intrusion_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def __init__(self, frame, model=None, name="intrusion"):
self.lateral_sgs_input_data = None
self.vertical_sgs_input_data = None

self.lateral_extent_sgs_parameters = None
self.vertical_extent_sgs_parameters = None
# grid points for simulation:
# self.lateral_extent_sgs_parameters = None
# self.vertical_extent_sgs_parameters = None

self.simulation_grid = None
self.data = None
self.data_prepared = False
Expand Down Expand Up @@ -235,6 +235,13 @@ def set_l_sgs_GSLIBparameters(self, lateral_simulation_parameters):
ndmin = lateral_simulation_parameters.get("ndmin", 0)
ndmax = lateral_simulation_parameters.get("ndmax", 3)
radius = lateral_simulation_parameters.get("radius", 500)
nugget = lateral_simulation_parameters.get("nugget", 0)
nst = lateral_simulation_parameters.get("nst", 1)
it1 = lateral_simulation_parameters.get("it1", 1)
cc1 = lateral_simulation_parameters.get("cc1", 1)
azi1 = lateral_simulation_parameters.get("azi1", 90)
hmaj1 = lateral_simulation_parameters.get("hmaj1", 999999)
hmin1 = lateral_simulation_parameters.get("hmin1", 999999)

l_parameters = {
"tmin": tmin,
Expand All @@ -254,6 +261,14 @@ def set_l_sgs_GSLIBparameters(self, lateral_simulation_parameters):
"ndmin": ndmin,
"ndmax": ndmax,
"radius": radius,
"nugget" : nugget,
"nst" : nst,
"it1" : it1,
"cc1" : cc1,
"azi1" : azi1,
"hmaj1" : hmaj1,
"hmin1" : hmin1

}

self.lateral_sgs_parameters = l_parameters
Expand Down Expand Up @@ -306,6 +321,13 @@ def set_g_sgs_GSLIBparameters(self, vertical_simulation_parameters):
ndmin = vertical_simulation_parameters.get("ndmin", 0)
ndmax = vertical_simulation_parameters.get("ndmax", 3)
radius = vertical_simulation_parameters.get("radius", 500)
nugget = vertical_simulation_parameters.get("nugget", 0)
nst = vertical_simulation_parameters.get("nst", 1)
it1 = vertical_simulation_parameters.get("it1", 1)
cc1 = vertical_simulation_parameters.get("cc1", 1)
azi1 = vertical_simulation_parameters.get("azi1", 90)
hmaj1 = vertical_simulation_parameters.get("hmaj1", 999999)
hmin1 = vertical_simulation_parameters.get("hmin1", 999999)

g_parameters = {
"tmin": tmin,
Expand All @@ -327,11 +349,18 @@ def set_g_sgs_GSLIBparameters(self, vertical_simulation_parameters):
"ndmin": ndmin,
"ndmax": ndmax,
"radius": radius,
"nugget" : nugget,
"nst" : nst,
"it1" : it1,
"cc1" : cc1,
"azi1" : azi1,
"hmaj1" : hmaj1,
"hmin1" : hmin1
}

self.vertical_sgs_parameters = g_parameters

def make_l_sgs_variogram(self, lateral_simulation_parameters):
def make_l_sgs_variogram(self):
"""
Make variogram for lateral extent simulation
By default: variogram with no nugget effect, 1 spherical nested structure, isotropic and infinite range
Expand All @@ -350,18 +379,19 @@ def make_l_sgs_variogram(self, lateral_simulation_parameters):
----
"""

nugget = lateral_simulation_parameters.get("nugget", 0)
nst = lateral_simulation_parameters.get("nst", 1)
it1 = lateral_simulation_parameters.get("it1", 1)
cc1 = lateral_simulation_parameters.get("cc1", 1)
azi1 = lateral_simulation_parameters.get("azi1", 90)
hmaj1 = lateral_simulation_parameters.get("hmaj1", 999999)
hmin1 = lateral_simulation_parameters.get("hmin1", 999999)
nugget = self.lateral_sgs_parameters.get("nugget")
nst = self.lateral_sgs_parameters.get("nst")
it1 = self.lateral_sgs_parameters.get("it1")
cc1 = self.lateral_sgs_parameters.get("cc1")
azi1 = self.lateral_sgs_parameters.get("azi1")
hmaj1 = self.lateral_sgs_parameters.get("hmaj1")
hmin1 = self.lateral_sgs_parameters.get("hmin1")

self.lateral_sgs_variogram = GSLIB.make_variogram(
nugget, nst, it1, cc1, azi1, hmaj1, hmin1
)

def make_g_sgs_variogram(self, vertical_simulation_parameters):
def make_g_sgs_variogram(self):
"""
Make variogram for vertical extent simulation
By default: variogram with no nugget effect, 1 spherical nested structure, isotropic and infinite range
Expand All @@ -378,13 +408,13 @@ def make_g_sgs_variogram(self, vertical_simulation_parameters):
----
"""

nugget = vertical_simulation_parameters.get("nugget", 0)
nst = vertical_simulation_parameters.get("nst", 1)
it1 = vertical_simulation_parameters.get("it1", 1)
cc1 = vertical_simulation_parameters.get("cc1", 1)
azi1 = vertical_simulation_parameters.get("azi1", 90)
hmaj1 = vertical_simulation_parameters.get("hmaj1", 999999)
hmin1 = vertical_simulation_parameters.get("hmin1", 999999)
nugget = self.vertical_sgs_parameters.get("nugget")
nst = self.vertical_sgs_parameters.get("nst")
it1 = self.vertical_sgs_parameters.get("it1")
cc1 = self.vertical_sgs_parameters.get("cc1")
azi1 = self.vertical_sgs_parameters.get("azi1")
hmaj1 = self.vertical_sgs_parameters.get("hmaj1")
hmin1 = self.vertical_sgs_parameters.get("hmin1")

self.vertical_sgs_variogram = GSLIB.make_variogram(
nugget, nst, it1, cc1, azi1, hmaj1, hmin1
Expand All @@ -408,7 +438,7 @@ def simulate_lateral_thresholds(self):
grid_points_coord1 = self.simulation_grid[2]
# grid_points_coord2 = self.simulation_grid[3]

# generate data frame containing input data for simulation
# -- generate data frame containing input data for simulation
data_sides = self.lateral_contact_data[0]

minP = min(
Expand Down Expand Up @@ -464,7 +494,7 @@ def simulate_lateral_thresholds(self):

self.lateral_sgs_input_data = [inputsimdata_minL, inputsimdata_maxL]

# Compute simulation parameters if not defined
# -- Compute simulation parameters if not defined
if self.lateral_sgs_parameters.get("zmin") == None:
self.lateral_sgs_parameters["zmin"] = min(
inputsimdata_maxL["l_residual"].min(),
Expand All @@ -483,7 +513,7 @@ def simulate_lateral_thresholds(self):
maxC0 = np.nanmax(grid_points_coord1)
self.lateral_sgs_parameters["xsiz"] = (maxC0 - minC0) / nx

# Simulation of lateral extent
# -- Simulation of lateral extent
tmin = self.lateral_sgs_parameters.get("tmin")
tmax = self.lateral_sgs_parameters.get("tmax")
itrans = self.lateral_sgs_parameters.get("itrans")
Expand Down Expand Up @@ -596,7 +626,7 @@ def simulate_lateral_thresholds(self):

# self.simulationGSLIB_s_outcome = [s_min_simulation, s_max_simulation]

# Create dataframe containing S threshold for each grid point
# -- Create dataframe containing S threshold for each grid point

propagation_grid_model = np.linspace(xmn, xmn + (nx * xsiz), nx)

Expand Down Expand Up @@ -652,13 +682,13 @@ def simulate_growth_thresholds(self):
-------
"""

# Get grid points and evaluated values in the intrusion frame
# -- Get grid points and evaluated values in the intrusion frame
grid_points = self.simulation_grid
grid_points_coord0 = self.simulation_grid[1]
grid_points_coord1 = self.simulation_grid[2]
grid_points_coord2 = self.simulation_grid[3]

# Generate data frame containing input data for simulation
# -- Generate data frame containing input data for simulation
inet_data = self.vertical_contact_data[0]
other_contact_data = self.vertical_contact_data[1]

Expand Down Expand Up @@ -734,9 +764,6 @@ def simulate_growth_thresholds(self):
if self.vertical_sgs_parameters.get("zmax2") == None:
self.vertical_sgs_parameters["zmax2"] = inputsimdata_inetG["coord0"].max()

# --- make variogram
# self.make_g_simulation_variogram()

# --- get parameters for simulation
tmin = self.vertical_sgs_parameters.get("tmin")
tmax = self.vertical_sgs_parameters.get("tmax")
Expand Down Expand Up @@ -851,7 +878,7 @@ def simulate_growth_thresholds(self):
)

# self.simulationGSLIB_g_outcome = [g_min_simulation, g_max_simulation]
# Create dataframe containing S threshold for each grid point
# -- Create dataframe containing S threshold for each grid point
lower_extent_gpl = [0, xmn, ymn]
upper_extent_gpl = [0, xmn + xsiz * nx, ymn + ysiz * ny]

Expand Down Expand Up @@ -899,7 +926,7 @@ def build(
lateral_extent_sgs_parameters={},
**kwargs,
):
"""Main building function for intrusion. Calculates variogram and thresholds
"""Main building function for intrusion. Calculates variogram and simulate thresholds along frame axes
Parameters
----------
Expand All @@ -909,16 +936,16 @@ def build(
parameters for the vertical sequential gaussian simulation, by default {}
"""
self.prepare_data()
# self.set_data_for_extent_simulation(intrusion_data)
self.create_grid_for_simulation()
self.set_l_sgs_GSLIBparameters(lateral_extent_sgs_parameters)
self.set_g_sgs_GSLIBparameters(vertical_extent_sgs_parameters)
self.make_l_sgs_variogram(lateral_extent_sgs_parameters)
self.make_g_sgs_variogram(vertical_extent_sgs_parameters)
self.make_l_sgs_variogram()
self.make_g_sgs_variogram()
self.simulate_lateral_thresholds()
self.simulate_growth_thresholds()
self.feature.growth_simulated_threshold = self.growth_simulated_thresholds
self.feature.growth_simulated_thresholds = self.growth_simulated_thresholds
self.feature.lateral_simulated_thresholds = self.lateral_simulated_thresholds


def update(self):
self.build(**self.build_arguments)
Expand Down
25 changes: 11 additions & 14 deletions LoopStructural/modelling/intrusions/intrusion_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, frame, builder, name="UnnamedIntrusion", model=None):
@property
def lateral_simulated_thresholds(self):
self.builder.up_to_date()

return self._lateral_simulated_thresholds

@lateral_simulated_thresholds.setter
Expand All @@ -51,25 +51,22 @@ def lateral_simulated_thresholds(self, lateral_simulated_thresholds):
self._lateral_simulated_thresholds = lateral_simulated_thresholds

@property
def growth_simulated_threshold(self):
def growth_simulated_thresholds(self):
self.builder.up_to_date()

return self._growth_simulated_thresholds

@growth_simulated_threshold.setter
def growth_simulated_threshold(self, growth_simulated_threshold):
@growth_simulated_thresholds.setter
def growth_simulated_thresholds(self, growth_simulated_threshold):
# TODO check type is correct and will work?
self._growth_simulated_thresholds = growth_simulated_threshold


@property
def lateral_sgs_input_data(self):
self.builder.up_to_date()
return self.builder.lateral_sgs_input_data

@property
def growth_simulated_thresholds(self):
self.builder.up_to_date()
return self.builder.growth_simulated_thresholds


@property
def vertical_sgs_input_data(self):
self.builder.up_to_date()
Expand Down Expand Up @@ -114,7 +111,7 @@ def evaluate_value(self, points):
Returns
------------
intrusion_sf : numpy array, constains distance to intrusion contact
intrusion_sf : numpy array, contains distance to intrusion contact
"""
self.builder.up_to_date()
Expand All @@ -133,9 +130,9 @@ def evaluate_value(self, points):

# if lateral extent values were simulated
if simulation_s_data is None:
print("No simultion for lateral extent")
print("No simulation for lateral extent")
else:
print("Assigning lateral thresholds")
# print("Assigning lateral thresholds")
simulation_s_data.sort_values(["coord1"], ascending=[True], inplace=True)

# containers for thresholds
Expand Down Expand Up @@ -167,7 +164,7 @@ def evaluate_value(self, points):
print("No simulation for vertical extent")
else:
# containers for thresholds
print("Assigning vertical thresholds")
# print("Assigning vertical thresholds")
g_minside_threshold = np.zeros(len(intrusion_coord1_pts))
g_maxside_threshold = np.zeros(len(intrusion_coord1_pts))

Expand Down
26 changes: 3 additions & 23 deletions LoopStructural/modelling/intrusions/intrusion_frame_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def __init__(self, interpolator=None, interpolators=None, model=None, **kwargs):
self.intrusion_network_points = None

self.velocity_field_arrays = None
self.IFf = None # delete?
self.IFc = None # delete?
self.IFf = None
self.IFc = None

def update_geometry(self, points):
self.origin = np.nanmin(np.array([np.min(points, axis=0), self.origin]), axis=0)
Expand Down Expand Up @@ -282,7 +282,7 @@ def set_intrusion_network_parameters(

if self.intrusion_network_type == "shortest path":

# set the sequence of anisotropies to follor by the shortest path algorithm
# set the sequence of anisotropies to follow by the shortest path algorithm
self.anisotropies_sequence = intrusion_network_input.get(
"shortest_path_sequence", None
)
Expand Down Expand Up @@ -348,9 +348,6 @@ def indicator_function_contacts(self, delta=None):

delta_list = delta

# for i in range(len(delta)):
# for j in range(len(self.anisotropies_series_parameters)):
# delta_list.append(delta[i])

for i, contact_id in enumerate(sorted(self.anisotropies_series_parameters)):
series_id = self.anisotropies_series_parameters[contact_id][0]
Expand Down Expand Up @@ -507,23 +504,6 @@ def create_intrusion_network(self, **kwargs):

elif self.intrusion_network_type == "shortest path":

# if "number_contacts" in kwargs:
# print('number contact ok')
# n_clusters = kwargs["number_contacts"]
# else:
# n_clusters = 1

# if "delta_c" in kwargs:
# print('delta_c ok')
# delta_c = kwargs["delta_c"]
# else:
# delta_c = [1] * len(self.anisotropies_series_list)

# if "delta_f" in kwargs:
# print('delta f ok')
# delta_f = kwargs["delta_f"]
# else:
# delta_f = [1] * len(self.anisotropies_fault_list)

grid_points, spacing = self.create_grid_for_indicator_fxs()

Expand Down

0 comments on commit 26ca7b3

Please sign in to comment.