diff --git a/examples/1_basic/plot_3_model_visualisation.py b/examples/1_basic/plot_3_model_visualisation.py index e7eb9b94..fdbc2393 100644 --- a/examples/1_basic/plot_3_model_visualisation.py +++ b/examples/1_basic/plot_3_model_visualisation.py @@ -119,17 +119,10 @@ viewer.plot_surface(strati, value=vals, cmap="prism", paint_with=strati) -# viewer.add_section( -# strati, -# axis="x", -# value=0.0, -# boundary_points=model.bounding_box, -# nsteps=np.array([30, 30, 30]), -# cmap="prism", -# ) -viewer.plot_scalar_field(strati, cmap="prism") -viewer.plot_block_model(cmap="tab20") +viewer.plot_scalar_field(strati, cmap="prism") +print(viewer._build_stratigraphic_cmap(model)) +viewer.plot_block_model() # Add the data addgrad/addvalue arguments are optional viewer.plot_data(strati, vector=True, value=True) viewer.display() # to add an interactive display diff --git a/examples/1_basic/plot_5_unconformities.py b/examples/1_basic/plot_5_unconformities.py new file mode 100644 index 00000000..031b132d --- /dev/null +++ b/examples/1_basic/plot_5_unconformities.py @@ -0,0 +1,78 @@ +""" +============================ +1h. Unconformities and fault +============================ +This tutorial will demonstrate how to add unconformities to a mode using LoopStructural. + +""" + +from matplotlib.cm import cmaps_listed +import numpy as np +import pandas as pd +from LoopStructural import GeologicalModel +import matplotlib.pyplot as plt + +data = pd.DataFrame( + [ + [100, 100, 150, 0.17, 0, 0.98, 0, "strati"], + [100, 100, 170, 0, 0, 0.86, 0, "strati3"], + [100, 100, 100, 0, 0, 1, 0, "strati2"], + [100, 100, 50, 0, 0, 1, 0, "nconf"], + [100, 100, 50, 0, 0, 1, 0, "strati4"], + [700, 100, 190, 1, 0, 0, np.nan, "fault"], + ], + columns=["X", "Y", "Z", "nx", "ny", "nz", "val", "feature_name"], +) + +model = GeologicalModel(np.zeros(3), np.array([1000, 1000, 200])) +model.data = data +model.create_and_add_foliation("strati2", buffer=0.0) +model.add_unconformity(model["strati2"], 0) +model.create_and_add_fault( + "fault", + 50, + minor_axis=300, + major_axis=500, + intermediate_axis=300, + fault_center=[700, 500, 0], +) + +model.create_and_add_foliation("strati", buffer=0.0) +model.add_unconformity(model["strati"], 0) +model.create_and_add_foliation("strati3", buffer=0.0) +model.create_and_add_foliation("nconf", buffer=0.0) +model.add_onlap_unconformity(model["nconf"], 0) +model.create_and_add_foliation("strati4") + + +stratigraphic_columns = { + "strati4": {"series4": {"min": -np.inf, "max": np.inf, "id": 5}}, + "strati2": { + "series1": {"min": 0.0, "max": 2.0, "id": 0, "colour": "red"}, + "series2": {"min": 2.0, "max": 5.0, "id": 1, "colour": "red"}, + "series1": {"min": 5.0, "max": 10.0, "id": 2, "colour": "red"}, + }, + "strati": { + "series2": {"min": -np.inf, "max": -100, "id": 3, "colour": "blue"}, + "series3": {"min": -100, "max": np.inf, "id": 4, "colour": "blue"}, + }, +} + + +model.set_stratigraphic_column(stratigraphic_columns) + +xx, zz = np.meshgrid(np.linspace(0, 1000, 100), np.linspace(0, 200, 100)) +yy = np.zeros_like(xx) + 500 +points = np.array([xx.flatten(), yy.flatten(), zz.flatten()]).T +val = model["strati"].evaluate_value(points) +val2 = model["strati2"].evaluate_value(points) +val3 = model["strati3"].evaluate_value(points) +val4 = model["strati4"].evaluate_value(points) +uf = model["strati4"].regions[0](points) +fval = model['fault'].evaluate_value(points) + +plt.contourf(val.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='viridis') +plt.contourf(val2.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Reds') +plt.contourf(val3.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Blues') +plt.contourf(val4.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Greens') +plt.contour(fval.reshape((100, 100)), [0], extent=(0, 1000, 0, 200)) diff --git a/examples/1_basic/plot_6_fault_parameters.py b/examples/1_basic/plot_6_fault_parameters.py new file mode 100644 index 00000000..064bf5ed --- /dev/null +++ b/examples/1_basic/plot_6_fault_parameters.py @@ -0,0 +1,108 @@ +""" +============================ +1i. Fault parameters +============================ +This tutorial will demonstrate how to add unconformities to a mode using LoopStructural. + +""" + +from matplotlib.cm import cmaps_listed +import numpy as np +import pandas as pd +from LoopStructural import GeologicalModel +import matplotlib.pyplot as plt + +data = pd.DataFrame( + [ + [100, 100, 150, 0.17, 0, 0.98, 0, "strati"], + [100, 100, 170, 0, 0, 0.86, 0, "strati3"], + [100, 100, 100, 0, 0, 1, 0, "strati2"], + [100, 100, 50, 0, 0, 1, 0, "nconf"], + [100, 100, 50, 0, 0, 1, 0, "strati4"], + [700, 100, 190, 1, 0, 0, np.nan, "fault"], + ], + columns=["X", "Y", "Z", "nx", "ny", "nz", "val", "feature_name"], +) + + +def build_model_and_plot( + displacement=50, + minor_axis=300, + major_axis=500, + intermediate_axis=300, + fault_center=[700, 500, 0], +): + model = GeologicalModel(np.zeros(3), np.array([1000, 1000, 200])) + model.data = data + model.create_and_add_foliation("strati2", buffer=0.0) + model.add_unconformity(model["strati2"], 0) + model.create_and_add_fault( + "fault", + displacement, + minor_axis=minor_axis, + major_axis=major_axis, + intermediate_axis=intermediate_axis, + fault_center=fault_center, + ) + + model.create_and_add_foliation("strati", buffer=0.0) + model.add_unconformity(model["strati"], 0) + model.create_and_add_foliation("strati3", buffer=0.0) + model.create_and_add_foliation("nconf", buffer=0.0) + model.add_onlap_unconformity(model["nconf"], 0) + model.create_and_add_foliation("strati4") + + stratigraphic_columns = { + "strati4": {"series4": {"min": -np.inf, "max": np.inf, "id": 5}}, + "strati2": { + "series1": {"min": 0.0, "max": 2.0, "id": 0, "colour": "red"}, + "series2": {"min": 2.0, "max": 5.0, "id": 1, "colour": "red"}, + "series1": {"min": 5.0, "max": 10.0, "id": 2, "colour": "red"}, + }, + "strati": { + "series2": {"min": -np.inf, "max": -100, "id": 3, "colour": "blue"}, + "series3": {"min": -100, "max": np.inf, "id": 4, "colour": "blue"}, + }, + } + + model.set_stratigraphic_column(stratigraphic_columns) + + xx, zz = np.meshgrid(np.linspace(0, 1000, 100), np.linspace(0, 200, 100)) + yy = np.zeros_like(xx) + 500 + points = np.array([xx.flatten(), yy.flatten(), zz.flatten()]).T + val = model["strati"].evaluate_value(points) + val2 = model["strati2"].evaluate_value(points) + val3 = model["strati3"].evaluate_value(points) + val4 = model["strati4"].evaluate_value(points) + uf = model["strati4"].regions[0](points) + fval = model['fault'].evaluate_value(points) + fig, ax = plt.subplots() + + ax.contourf(val.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='viridis') + ax.contourf(val2.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Reds') + ax.contourf(val3.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Blues') + ax.contourf(val4.reshape((100, 100)), extent=(0, 1000, 0, 200), cmap='Greens') + ax.contour(fval.reshape((100, 100)), [0], extent=(0, 1000, 0, 200)) + + +######################################################################### +# Plot the model with a displacement of 50 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +build_model_and_plot(50) + +######################################################################### +# Plot the model with a displacement of 100 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +build_model_and_plot(100) + +######################################################################### +# Plot the model with a displacement of 50 and minor axis 100 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +build_model_and_plot(displacement=50, minor_axis=100) + + +######################################################################### +# Plot the model with a displacement of 50 and minor axis 500 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +build_model_and_plot(displacement=50, minor_axis=500) diff --git a/examples/1_basic/plot_6_unconformities.py b/examples/1_basic/plot_6_unconformities.py deleted file mode 100644 index 6ebff11d..00000000 --- a/examples/1_basic/plot_6_unconformities.py +++ /dev/null @@ -1,113 +0,0 @@ -""" -============================ -1f. Unconformities -============================ -This tutorial will demonstrate how to add unconformities to a mode using LoopStructural. - -""" - -from LoopStructural import GeologicalModel -import pandas as pd -import numpy as np -from LoopStructural.visualisation import Loop3DView - -################################################################################################## -# Generate synthetic data -# ~~~~~~~~~~~~~~~~~~~~~~~~ -# Model 3 scalar fields where the top is horizontal, the middle is dipping and the bottom is horizontal. -data = pd.DataFrame( - [ - [0, 0, 3, 0, 0, 0, 1, "unit_a"], - [0, 0, 1, 1, 0, 0.7, 0.7, "unit_b"], - [0, 0, 0, 0, 0, 0.7, 0.7, "unit_b"], - [0, 0, -3, 0, 0, 0, -1, "unit_c"], - ], - columns=["X", "Y", "Z", "val", "nx", "ny", "nz", "feature_name"], -) - -model = GeologicalModel(np.ones(3) * -5, np.ones(3) * 7) -model.data = data -model.create_and_add_foliation("unit_a") -model.create_and_add_foliation("unit_b") -model.create_and_add_foliation("unit_c") - -model.update() -################################################################################################## -# Visualise the model without unconformities -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# - -view = Loop3DView(model) -view.plot_surface(model["unit_a"], value=5) -view.plot_surface(model["unit_b"], value=5) -view.plot_surface(model["unit_c"], value=5) -view.display() - -################################################################################################## -# Add unconformities -# ~~~~~~~~~~~~~~~~~~ -# We add two unconformities to the model -# 1. the isovalue of 0 of unit_a is an unconformity -# 2. the isovalue of 0 of unit_b is an unconformity -# -# This means unit_a should not occur below isovalue of 0, -# unit_b should truncate at unit_a isovalue 0 and -# unit_b should not occur below isovalue of 0 -# and unit_c should not occur below unit_b isovalue of 0 - -model = GeologicalModel(np.ones(3) * -5, np.ones(3) * 7) -model.data = data -model.create_and_add_foliation("unit_a") -model.add_unconformity(model["unit_a"], 0) -model.create_and_add_foliation("unit_b") -model.add_unconformity(model["unit_b"], 0) -model.create_and_add_foliation("unit_c") - -################################################################################################## -# We can examine the model by printing the object -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -print(model) - -model.update() - -################################################################################################## -# Visualise the model without unconformities -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# - -view = Loop3DView(model) -view.plot_surface(model["unit_a"], value=5) -view.plot_surface(model["unit_b"], value=5) -view.plot_surface(model["unit_c"], value=5) -view.display() - - -################################################################################################## -# Adding onlap unconformity -# ~~~~~~~~~~~~~~~~~~~~~~~~~ -# We can also add onlap unconformities to the model, using the previous example lets change the unconformity -# between b and c to be an onlap. This means the geometry of c truncates b - - -model = GeologicalModel(np.ones(3) * -5, np.ones(3) * 7) -model.data = data -model.create_and_add_foliation("unit_a") -model.add_unconformity(model["unit_a"], 0) -model.create_and_add_foliation("unit_b") -model.create_and_add_foliation("unit_c") -model.add_onlap_unconformity(model["unit_c"], 0) - -model.update() - -################################################################################################## -# Visualise the model with onlap -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -view = Loop3DView(model) -view.plot_surface(model["unit_a"], value=5) -view.plot_surface(model["unit_b"], value=5) -view.plot_surface(model["unit_c"], value=5) - - -view.display()