From 3f59a758238f834874d50ab4fbd44ecdbe072680 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Fri, 1 Nov 2024 15:10:06 +1100 Subject: [PATCH] updating docs --- .../plot_1_adding_folds_to_surfaces.py | 2 +- .../plot_2_refolded_folds.py | 2 +- .../plot_3_define_fault_displacement.py | 2 +- .../plot_3_faulted_intrusion.py | 100 +++++++++--------- .../plot_6_fault_network.py | 4 - .../4_performance/plot_1_solver_iterations.py | 40 ++++++- 6 files changed, 89 insertions(+), 61 deletions(-) diff --git a/examples/2_modelling_workflow/plot_1_adding_folds_to_surfaces.py b/examples/2_modelling_workflow/plot_1_adding_folds_to_surfaces.py index 2c12d6cf..2f4144e1 100644 --- a/examples/2_modelling_workflow/plot_1_adding_folds_to_surfaces.py +++ b/examples/2_modelling_workflow/plot_1_adding_folds_to_surfaces.py @@ -1,5 +1,5 @@ """ -2a. Modelling folds +Modelling folds ==================== This tutorial will show how Loop Structural improves the modelling of diff --git a/examples/2_modelling_workflow/plot_2_refolded_folds.py b/examples/2_modelling_workflow/plot_2_refolded_folds.py index e4eee08b..92c4bf7c 100644 --- a/examples/2_modelling_workflow/plot_2_refolded_folds.py +++ b/examples/2_modelling_workflow/plot_2_refolded_folds.py @@ -1,5 +1,5 @@ """ -2b. Refolded folds +Refolded folds =================== diff --git a/examples/2_modelling_workflow/plot_3_define_fault_displacement.py b/examples/2_modelling_workflow/plot_3_define_fault_displacement.py index 76591061..717a89b6 100644 --- a/examples/2_modelling_workflow/plot_3_define_fault_displacement.py +++ b/examples/2_modelling_workflow/plot_3_define_fault_displacement.py @@ -1,5 +1,5 @@ """ -3c. Defining the fault displacement function +Defining the fault displacement function ============================================ """ diff --git a/examples/2_modelling_workflow/plot_3_faulted_intrusion.py b/examples/2_modelling_workflow/plot_3_faulted_intrusion.py index e4589759..ca6608ee 100644 --- a/examples/2_modelling_workflow/plot_3_faulted_intrusion.py +++ b/examples/2_modelling_workflow/plot_3_faulted_intrusion.py @@ -1,11 +1,11 @@ """ -3a. Modelling faults using structural frames +Modelling faults using structural frames ======================================== """ -# from LoopStructural import GeologicalModel -# from LoopStructural.visualisation import Loop3DView +from LoopStructural import GeologicalModel +from LoopStructural.visualisation import Loop3DView from LoopStructural.datasets import load_intrusion import numpy as np import matplotlib.pyplot as plt @@ -51,54 +51,54 @@ # # fault frame and an expected displacement model. # # -# model = GeologicalModel(bb[0, :], bb[1, :]) -# model.set_model_data(data) -# fault = model.create_and_add_fault( -# "fault", 500, nelements=10000, steps=4, interpolatortype="FDI", buffer=0.3 -# ) +model = GeologicalModel(bb[0, :], bb[1, :]) +model.set_model_data(data) +fault = model.create_and_add_fault( + "fault", 500, nelements=10000, steps=4, interpolatortype="FDI", buffer=0.3 +) -# viewer = Loop3DView(model) -# viewer.plot_surface( -# fault, -# 0.0, -# # slices=[0,1]#nslices=10 -# ) -# xyz = model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]].to_numpy() -# xyz = xyz[fault.evaluate(xyz).astype(bool), :] -# viewer.plot_vector_field(fault) -# viewer.add_points( -# model.rescale( -# model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]], -# inplace=False, -# ), -# name="prefault", -# ) -# viewer.show() +viewer = Loop3DView(model) +viewer.plot_surface( + fault, + 0.0, + # slices=[0,1]#nslices=10 +) +xyz = model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]].to_numpy() +xyz = xyz[fault.evaluate(xyz).astype(bool), :] +viewer.plot_vector_field(fault) +viewer.add_points( + model.rescale( + model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]].values, + inplace=False, + ), + name="prefault", +) +viewer.show() -# displacement = 400 # INSERT YOUR DISPLACEMENT NUMBER HERE BEFORE # +displacement = 400 # INSERT YOUR DISPLACEMENT NUMBER HERE BEFORE # -# model = GeologicalModel(bb[0, :], bb[1, :]) -# model.set_model_data(data) -# fault = model.create_and_add_fault( -# "fault", displacement, nelements=2000, steps=4, interpolatortype="PLI", buffer=2 -# ) -# strati = model.create_and_add_foliation("strati", nelements=30000, interpolatortype="PLI", cgw=0.03) -# model.update() -# viewer = Loop3DView(model) -# viewer.plot_surface(strati, 0.0) -# # viewer.add_data(model.features[0][0]) -# viewer.plot_data(strati) -# viewer.plot_surface( -# fault, -# value=0.0, -# # slices=[0,1]#nslices=10 -# ) -# viewer.add_points( -# model.rescale( -# model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]], -# inplace=False, -# ), -# name="prefault", -# ) -# viewer.show() +model = GeologicalModel(bb[0, :], bb[1, :]) +model.set_model_data(data) +fault = model.create_and_add_fault( + "fault", displacement, nelements=2000, steps=4, interpolatortype="PLI", buffer=2 +) +strati = model.create_and_add_foliation("strati", nelements=30000, interpolatortype="PLI", cgw=0.03) +model.update() +viewer = Loop3DView(model) +viewer.plot_surface(strati, 0.0) +# viewer.add_data(model.features[0][0]) +viewer.plot_data(strati) +viewer.plot_surface( + fault, + value=0.0, + # slices=[0,1]#nslices=10 +) +viewer.add_points( + model.rescale( + model.data[model.data["feature_name"] == "strati"][["X", "Y", "Z"]].values, + inplace=False, + ), + name="prefault", +) +viewer.show() diff --git a/examples/2_modelling_workflow/plot_6_fault_network.py b/examples/2_modelling_workflow/plot_6_fault_network.py index 0c0a7d99..6534ea5c 100644 --- a/examples/2_modelling_workflow/plot_6_fault_network.py +++ b/examples/2_modelling_workflow/plot_6_fault_network.py @@ -1,7 +1,3 @@ -""" -Fault network -""" - """ Modelling a fault network in LoopStructural =============================================== diff --git a/examples/4_performance/plot_1_solver_iterations.py b/examples/4_performance/plot_1_solver_iterations.py index d2876301..b2216151 100644 --- a/examples/4_performance/plot_1_solver_iterations.py +++ b/examples/4_performance/plot_1_solver_iterations.py @@ -15,6 +15,8 @@ In some cases a satisfactory solution can be found with a small number of iterations. In the example below we show the time taken to solve the problem for different numbers of iterations and show the resulting model. +We can see that for a lower number of iterations the solution is not satisfactory but as the number of +iterations increases the solution beocmes satisfactory. """ from LoopStructural import GeologicalModel @@ -25,7 +27,10 @@ data, bb = load_claudius() model = GeologicalModel(bb[0, :], bb[1, :]) model.data = data -isovalue = 220 +isovalue = 0 +images = {} +view = Loop3DView(model, off_screen=True) + for maxiter in [10, 100, 500, 1000, 10000]: start = time.time() model.create_and_add_foliation( @@ -34,7 +39,34 @@ model.update() end = time.time() print(f"maxiter: {maxiter} time: {end-start} seconds") - view = Loop3DView(model) - view.plot_surface(model["strati"], [220]) - view.show() + view.plot_surface(model["strati"], [0, 60, 250, 330]) + view.plot_data(model["strati"]) + + images[maxiter] = view.screenshot() view.clear() + +data = data.drop(data.index[data["val"] == 250]) +data = data.drop(data.index[data["val"] == 330]) +images2 = {} +model = GeologicalModel(bb[0, :], bb[1, :]) +model.data = data +for maxiter in [10, 100, 500, 1000, 10000]: + start = time.time() + model.create_and_add_foliation( + "strati", interpolatortype="FDI", solver_kwargs={"maxiter": maxiter} + ) + model.update() + end = time.time() + print(f"maxiter: {maxiter} time: {end-start} seconds") + view.plot_surface(model["strati"], [0, 60], name='surface') + view.plot_data(model["strati"], name='data') + images2[maxiter] = view.screenshot() + view.clear() +import matplotlib.pyplot as plt + +fig, ax = plt.subplots(len(images), 2, figsize=(10, 20)) +for i, (maxiter) in enumerate(images.keys()): + ax[i, 0].imshow(images[maxiter]) + ax[i, 0].set_title(f"maxiter: {maxiter}") + ax[i, 1].imshow(images2[maxiter]) + ax[i, 1].set_title(f"maxiter: {maxiter}")