From 3c7243e1c87adb18ef76c4ac84c44e35cbe74f05 Mon Sep 17 00:00:00 2001 From: javoha Date: Wed, 26 Mar 2025 15:42:32 +0100 Subject: [PATCH 1/4] Added test as example for outliers in gempy v3. --- test/test_modules/test_outliers.py | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/test_modules/test_outliers.py diff --git a/test/test_modules/test_outliers.py b/test/test_modules/test_outliers.py new file mode 100644 index 00000000..03847f7f --- /dev/null +++ b/test/test_modules/test_outliers.py @@ -0,0 +1,53 @@ +import gempy as gp +from gempy.optional_dependencies import require_gempy_viewer +from gempy.core.data.enumerators import ExampleModel +from gempy.core.data.grid_modules import RegularGrid +import numpy as np + +PLOT = True + + +def test_outliers_model_1(): + # Path to input data + data_path = "https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/" + path_to_data = data_path + "/data/input_data/video_tutorials_v3/" + + # Create instance of geomodel + model = gp.create_geomodel( + project_name='tutorial_model_onlap_1', + extent=[0, 2000, 0, 1000, 0, 1000], + resolution=[100, 50, 50], + importer_helper=gp.data.ImporterHelper( + path_to_orientations=path_to_data + "tutorial_model_onlap_1_orientations.csv?cache=", + path_to_surface_points=path_to_data + "tutorial_model_onlap_1_surface_points.csv?cache=" + ) + ) + + # Map geological series to surfaces + gp.map_stack_to_surfaces( + gempy_model=model, + mapping_object={ + "Young_Series": ("basin_fill_2", "basin_fill_1"), + "Old_Series": ("basin_top", "basin_bottom") + } + ) + + # Set the relation of the youngest group to Onlap + from gempy_engine.core.data.stack_relation_type import StackRelationType + model.structural_frame.structural_groups[0].structural_relation = StackRelationType.ONLAP + + # Compute a solution for the model + gp.compute_model(model) + + # Assert + arrays = model.solutions.raw_arrays # * arrays is equivalent to gempy v2 solutions + assert arrays.scalar_field_matrix.shape == (2, 250_000) # * 2 groups, 250000 points + + if PLOT: + gpv = require_gempy_viewer() + gpv.plot_2d( + model=model, + show_data=False, + show_boundaries=False, + show=True + ) From b0072c3cb1affaac152b290aeed9d7d03863fd2e Mon Sep 17 00:00:00 2001 From: MigueldelaVarga Date: Fri, 2 May 2025 08:54:25 +0100 Subject: [PATCH 2/4] [TEST] Cleaning a bit the test --- test/test_modules/test_outliers.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/test/test_modules/test_outliers.py b/test/test_modules/test_outliers.py index 03847f7f..d71c2b19 100644 --- a/test/test_modules/test_outliers.py +++ b/test/test_modules/test_outliers.py @@ -27,8 +27,8 @@ def test_outliers_model_1(): gp.map_stack_to_surfaces( gempy_model=model, mapping_object={ - "Young_Series": ("basin_fill_2", "basin_fill_1"), - "Old_Series": ("basin_top", "basin_bottom") + "Young_Series": ("basin_fill_2", "basin_fill_1"), + "Old_Series" : ("basin_top", "basin_bottom") } ) @@ -37,7 +37,12 @@ def test_outliers_model_1(): model.structural_frame.structural_groups[0].structural_relation = StackRelationType.ONLAP # Compute a solution for the model - gp.compute_model(model) + gp.compute_model( + gempy_model=model, + engine_config=gp.data.GemPyEngineConfig( + backend=gp.data.AvailableBackends.PYTORCH + ) + ) # Assert arrays = model.solutions.raw_arrays # * arrays is equivalent to gempy v2 solutions @@ -51,3 +56,21 @@ def test_outliers_model_1(): show_boundaries=False, show=True ) + + gpv.plot_2d( + model=model, + show_data=False, + show_boundaries=False, + show_scalar=True, + show=True + ) + + + gpv.plot_2d( + model=model, + show_data=False, + show_boundaries=False, + show_scalar=True, + series_n=1, + show=True + ) From 12fa40d2c8b8842164b5a63cb316915395c3e3b9 Mon Sep 17 00:00:00 2001 From: MigueldelaVarga Date: Fri, 2 May 2025 09:27:34 +0100 Subject: [PATCH 3/4] [TEST] Manually cranking the sigmoid slope --- test/test_modules/test_outliers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_modules/test_outliers.py b/test/test_modules/test_outliers.py index d71c2b19..50a6334d 100644 --- a/test/test_modules/test_outliers.py +++ b/test/test_modules/test_outliers.py @@ -35,12 +35,14 @@ def test_outliers_model_1(): # Set the relation of the youngest group to Onlap from gempy_engine.core.data.stack_relation_type import StackRelationType model.structural_frame.structural_groups[0].structural_relation = StackRelationType.ONLAP + + model.interpolation_options.sigmoid_slope = 5_000_000 # Compute a solution for the model gp.compute_model( gempy_model=model, engine_config=gp.data.GemPyEngineConfig( - backend=gp.data.AvailableBackends.PYTORCH + backend=gp.data.AvailableBackends.numpy ) ) @@ -52,7 +54,7 @@ def test_outliers_model_1(): gpv = require_gempy_viewer() gpv.plot_2d( model=model, - show_data=False, + show_data=True, show_boundaries=False, show=True ) From a33628c438c9d0934a5d9a2041b1c2148f30699d Mon Sep 17 00:00:00 2001 From: MigueldelaVarga Date: Fri, 2 May 2025 09:30:27 +0100 Subject: [PATCH 4/4] Adding testj --- test/test_QA/__init__.py | 0 test/test_QA/test_chuncking.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/test_QA/__init__.py create mode 100644 test/test_QA/test_chuncking.py diff --git a/test/test_QA/__init__.py b/test/test_QA/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_QA/test_chuncking.py b/test/test_QA/test_chuncking.py new file mode 100644 index 00000000..e69de29b