def test_pile_geomodel_2(): ve = 3 extent = [451e3, 456e3, 6.7820e6, 6.7840e6, -2309 * ve, -1651 * ve] geo_model = gp.create_model('Topology-Gullfaks') gp.init_data(geo_model, extent, [30, 30, 30], path_o=input_path + "/filtered_orientations.csv", path_i=input_path + "/filtered_surface_points.csv", default_values=True) series_distribution = { "fault3": "fault3", "fault4": "fault4", "unconformity": "BCU", "sediments": ("tarbert", "ness", "etive"), } gp.map_series_to_surfaces(geo_model, series_distribution, remove_unused_series=True) geo_model.reorder_series( ["unconformity", "fault3", "fault4", "sediments", "Basement"]) geo_model.set_is_fault(["fault3"]) geo_model.set_is_fault(["fault4"]) rel_matrix = np.array([[0, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) geo_model.set_fault_relation(rel_matrix) surf_groups = pd.read_csv(input_path + "/filtered_surface_points.csv").group geo_model.surface_points.df["group"] = surf_groups orient_groups = pd.read_csv(input_path + "/filtered_orientations.csv").group geo_model.orientations.df["group"] = orient_groups geo_model.surface_points.df.reset_index(inplace=True, drop=True) geo_model.orientations.df.reset_index(inplace=True, drop=True) gp.set_interpolator(geo_model, verbose=['mask_matrix_loop', 'mask_e', 'nsle']) gp.compute_model(geo_model) gp.plot.plot_section(geo_model, cell_number=25, direction='y', show_data=True) from gempy.plot.plot_api import plot_2d p = plot_2d(geo_model, cell_number=[25]) plt.savefig(os.path.dirname(__file__) + '/../figs/test_pile_lith_block') return geo_model
def test_gravity(): geo_model = gp.create_model('2-layers') gp.init_data(geo_model, extent=[0, 12, -2, 2, 0, 4], resolution=[500, 1, 500]) geo_model.add_surfaces('surface 1') geo_model.add_surfaces('surface 2') geo_model.add_surfaces('basement') dz = geo_model.grid.regular_grid.dz geo_model.surfaces.add_surfaces_values([dz, 0, 0], ['dz']) geo_model.surfaces.add_surfaces_values([2.6, 2.4, 3.2], ['density']) geo_model.add_surface_points(3, 0, 3.05, 'surface 1') geo_model.add_surface_points(9, 0, 3.05, 'surface 1') geo_model.add_surface_points(3, 0, 1.02, 'surface 2') geo_model.add_surface_points(9, 0, 1.02, 'surface 2') geo_model.add_orientations(6, 0, 4, 'surface 1', [0, 0, 1]) device_loc = np.array([[6, 0, 4]]) geo_model.set_centered_grid(device_loc, resolution=[10, 10, 100], radius=16000) gp.set_interpolator(geo_model, output=['gravity'], pos_density=2, gradient=True, theano_optimizer='fast_compile') gp.compute_model(geo_model, set_solutions=True, compute_mesh=False) print(geo_model.solutions.fw_gravity) np.testing.assert_almost_equal(geo_model.solutions.fw_gravity, np.array([-9291.8003]), decimal=4)
def model(): geo_model = gp.create_model('test_map2Loop') gp.init_data( geo_model, extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top], resolution=[50, 50, 80], path_o=orientations_file, path_i=contacts_file) # Load Topology geo_model.set_topography(source='gdal', filepath=fp) # Stack Processing contents = np.genfromtxt(series_file, delimiter=',', dtype='U100')[1:, 4:-1] map_series_to_surfaces = {} for pair in contents: map_series_to_surfaces.setdefault(pair[1], []).append(pair[0]) gp.map_stack_to_surfaces(geo_model, map_series_to_surfaces, remove_unused_series=False) gp.plot_3d(geo_model, ve=None, show_topography=False, image=True, show_lith=False, kwargs_plot_data={'arrow_size': 300}) return geo_model
def test_gravity(interpolator_gravity): geo_model = gp.create_model('2-layers') gp.init_data(geo_model, extent=[0, 12, -2, 2, 0, 4], resolution=[500, 1, 500]) geo_model.add_surfaces('surface 1') geo_model.add_surfaces('surface 2') geo_model.add_surfaces('basement') dz = geo_model._grid.regular_grid.dz geo_model._surfaces.add_surfaces_values([dz, 0, 0], ['dz']) geo_model._surfaces.add_surfaces_values([2.6, 2.4, 3.2], ['density']) geo_model.add_surface_points(3, 0, 3.05, 'surface 1') geo_model.add_surface_points(9, 0, 3.05, 'surface 1') geo_model.add_surface_points(3, 0, 1.02, 'surface 2') geo_model.add_surface_points(9, 0, 1.02, 'surface 2') geo_model.add_orientations(6, 0, 4, 'surface 1', [0, 0, 1]) device_loc = np.array([[6, 0, 4]]) geo_model.set_centered_grid(device_loc, resolution=[10, 10, 100], radius=16000) geo_model.set_theano_function(interpolator_gravity) geo_model._interpolator.set_theano_shared_gravity(pos_density=2) print(geo_model._additional_data) gp.compute_model(geo_model, set_solutions=True, compute_mesh=False) print(geo_model.solutions.fw_gravity) np.testing.assert_almost_equal(geo_model.solutions.fw_gravity, np.array([-1624.1714]), decimal=4)
def test_magnetics_no_regular_grid(interpolator_magnetics): # TODO add the check geo_model = gp.create_model('test_center_grid_slicing') geo_model.set_default_surfaces() geo_model.add_surface_points(X=-1, Y=0, Z=0, surface='surface1') geo_model.add_surface_points(X=1, Y=0, Z=0, surface='surface1') geo_model.add_orientations(X=0, Y=0, Z=0, surface='surface1', pole_vector=(0, 0, 1)) geo_model._surfaces.add_surfaces_values([0.037289, 0.0297], ['susceptibility']) # needed constants mu_0 = 4.0 * np.pi * 10e-7 # magnetic permeability in free space [N/A^2] cm = mu_0 / (4.0 * np.pi) # constant for SI unit incl = 77.0653 # NOAA decl = 6.8116 B_ext = 52819.8506939139e-9 # T geo_model.set_centered_grid(np.array([0, 0, 0]), resolution=[10, 10, 15], radius=5000) Vmodel = MagneticsPreprocessing(geo_model._grid.centered_grid).set_Vs_kernel() # gp.set_interpolator(geo_model, output=['magnetics']) geo_model.set_theano_function(interpolator_magnetics) geo_model._interpolator.set_theano_shared_magnetics(V= Vmodel, pos_magnetics=1, incl= incl, decl=decl, B_ext=B_ext) # geo_model.interpolator.theano_graph.V.set_value(Vmodel) # geo_model.interpolator.theano_graph.incl.set_value(incl) # geo_model.interpolator.theano_graph.decl.set_value(decl) # geo_model.interpolator.theano_graph.B_ext.set_value(B_ext) gp.compute_model(geo_model) np.testing.assert_almost_equal(geo_model.solutions.fw_magnetics, np.array([473.7836]), decimal=4) gp.compute_model(geo_model) return geo_model
def test_magnetics_api(interpolator_magnetics): # TODO add the check geo_model = gp.create_model('test_center_grid_slicing') geo_model.set_default_surfaces() geo_model.add_surface_points(X=-1, Y=0, Z=0, surface='surface1') geo_model.add_surface_points(X=1, Y=0, Z=0, surface='surface1') geo_model.add_orientations(X=0, Y=0, Z=0, surface='surface1', pole_vector=(0, 0, 1)) geo_model._surfaces.add_surfaces_values([0.037289, 0.0297], ['susceptibility']) # needed constants mu_0 = 4.0 * np.pi * 10e-7 # magnetic permeability in free space [N/A^2] cm = mu_0 / (4.0 * np.pi) # constant for SI unit incl = 77.0653 # NOAA decl = 6.8116 B_ext = 52819.8506939139e-9 # T geo_model.set_regular_grid(extent=[-5, 5, -5, 5, -5, 5], resolution=[5, 5, 5]) geo_model.set_centered_grid(np.array([[0, 0, 0]]), resolution=[10, 10, 15], radius=5000) geo_model.set_theano_function(interpolator_magnetics) geo_model._interpolator.set_theano_shared_magnetics(V='auto', pos_magnetics=1, incl= incl, decl=decl, B_ext=B_ext) gp.compute_model(geo_model) print(geo_model._interpolator.theano_graph.lg0.get_value()) print(geo_model.solutions.fw_magnetics) np.testing.assert_almost_equal(geo_model.solutions.fw_magnetics, np.array([473.7836]), decimal=4) return geo_model
def test_magnetics_api(): # TODO add the check geo_model = gp.create_model('test_center_grid_slicing') geo_model.set_default_surfaces() geo_model.add_surface_points(X=-1, Y=0, Z=0, surface='surface1') geo_model.add_surface_points(X=1, Y=0, Z=0, surface='surface1') geo_model.add_orientations(X=0, Y=0, Z=0, surface='surface1', pole_vector=(0, 0, 1)) geo_model.surfaces.add_surfaces_values([0.037289, 0.0297], ['susceptibility']) # needed constants mu_0 = 4.0 * np.pi * 10e-7 # magnetic permeability in free space [N/A^2] cm = mu_0 / (4.0 * np.pi) # constant for SI unit incl = 77.0653 # NOAA decl = 6.8116 B_ext = 52819.8506939139e-9 # T geo_model.set_regular_grid(extent=[-5, 5, -5, 5, -5, 5], resolution=[5, 5, 5]) geo_model.set_centered_grid(np.array([0, 0, 0]), resolution=[10, 10, 15], radio=5000) gp.set_interpolator(geo_model, output=['magnetics'], incl=incl, decl=decl) gp.compute_model(geo_model) print(geo_model.interpolator.theano_graph.lg0.get_value()) return geo_model
def interpolator_islith_isfault(): geo_model = gp.create_model('interpolator_islith_isfault') # Importing the data from CSV-files and setting extent and resolution gp.init_data(geo_model, path_o=input_path + "/simple_fault_model_orientations.csv", path_i=input_path + "/simple_fault_model_points.csv", default_values=True) gp.map_series_to_surfaces(geo_model, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1', 'basement') }, remove_unused_series=True) geo_model.set_is_fault(['Fault_Series']) gp.set_interpolation_data(geo_model, compile_theano=True, theano_optimizer='fast_compile', verbose=[]) return geo_model.interpolator
def test_load_model_df(): verbose = True df_i = pn.DataFrame(np.random.randn(6,3), columns='X Y Z'.split()) df_i['formation'] = ['surface_1' for _ in range(3)] + ['surface_2' for _ in range(3)] df_o = pn.DataFrame(np.random.randn(6,6), columns='X Y Z azimuth dip polarity'.split()) df_o['formation'] = ['surface_1' for _ in range(3)] + ['surface_2' for _ in range(3)] geo_model = gp.create_model('test') # Importing the data directly from the dataframes gp.init_data(geo_model, [0, 2000., 0, 2000., 0, 2000.], [50, 50, 50], surface_points_df=df_i, orientations_df=df_o, default_values=True) df_cmp_i = gp.get_data(geo_model, 'surface_points') df_cmp_o = gp.get_data(geo_model, 'orientations') if verbose: print(df_cmp_i.head()) print(df_cmp_o.head()) assert not df_cmp_i.empty, 'data was not set to dataframe' assert not df_cmp_o.empty, 'data was not set to dataframe' assert df_cmp_i.shape[0] == 6, 'data was not set to dataframe' assert df_cmp_o.shape[0] == 6, 'data was not set to dataframe' # try without the default_values command geo_model = gp.create_model('test') # Importing the data directly from the dataframes gp.init_data(geo_model, [0, 2000., 0, 2000., 0, 2000.], [50 ,50 ,50], surface_points_df=df_i, orientations_df=df_o) df_cmp_i2 = gp.get_data(geo_model, 'surface_points') df_cmp_o2 = gp.get_data(geo_model, 'orientations') if verbose: print(df_cmp_i2.head()) print(df_cmp_o2.head()) assert not df_cmp_i2.empty, 'data was not set to dataframe' assert not df_cmp_o2.empty, 'data was not set to dataframe' assert df_cmp_i2.shape[0] == 6, 'data was not set to dataframe' assert df_cmp_o2.shape[0] == 6, 'data was not set to dataframe' return geo_model
def test_issue_569(data_path): surface_points_df = df = pd.read_csv(data_path + "/coordinates_mwe.csv") orientations_df = pd.read_csv(data_path + "/orientations_mwe.csv") geo_model = gp.create_model("Deltatest") gp.init_data(geo_model, [ df.X.min() - 50, df.X.max() + 50, df.Y.min() - 50, df.Y.max() + 50, df.Z.min() - 50, df.Z.max() + 50, ], [50, 50, 50], surface_points_df=surface_points_df, orientations_df=orientations_df, default_values=True) fault_list = [] series = { "Strat_Series": surface_points_df.loc[ ~surface_points_df["formation"].str.contains("fault"), "formation"].unique().tolist() } for fault in surface_points_df.loc[ surface_points_df["formation"].str.contains("fault"), "formation"].unique(): series[fault] = fault fault_list.append(fault) gp.map_stack_to_surfaces(geo_model, series, remove_unused_series=True) geo_model.set_is_fault(fault_list) geo_model.reorder_features(['fault_a', 'fault_b', 'Strat_Series']) geo_model.add_surfaces("basement") plot = gp.plot_2d(geo_model, show_lith=False, show_boundaries=True, direction=['z']) plt.show(block=False) gp.set_interpolator( geo_model, compile_theano=True, theano_optimizer='fast_compile', ) gp.get_data(geo_model, 'kriging') sol = gp.compute_model(geo_model, sort_surfaces=True) gp.plot_2d(geo_model, show_scalar=True, series_n=0) gp.plot_2d(geo_model, series_n=0) gp.plot_3d(geo_model, image=True)
def load_model(): geo_model = gp.create_model('Model_Tuto1-1') # Importing the data from CSV-files and setting extent and resolution gp.init_data(geo_model, [0, 2000., 0, 2000., 0, 2000.], [50 ,50 ,50], path_o = input_path+"/simple_fault_model_orientations.csv", path_i = input_path+"/simple_fault_model_points.csv", default_values=True) gp.get_data(geo_model, 'surface_points').head() return geo_model
def test_issue_566(): from pyvista import set_plot_theme set_plot_theme('document') geo_model = gp.create_model('Model1') geo_model = gp.init_data(geo_model, extent=[0, 791, 0, 200, -582, 0], resolution=[100, 10, 100]) geo_model.set_default_surfaces() geo_model.add_surface_points(X=223, Y=0.01, Z=-94, surface='surface1')
def interpolator_islith_nofault(): geo_model = gp.create_model('interpolator_islith_isfault') # Importing the data from csv files and settign extent and resolution gp.init_data(geo_model, #[0, 10, 0, 10, -10, 0], [50, 50, 50], path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv", path_i=input_path + "/GeoModeller/test_a/test_a_Points.csv") interpolator = gempy.set_interpolation_data(geo_model, grid=None, compile_theano=True) return interpolator
def model_horizontal_two_layers(interpolator): geo_model = gp.create_model('interpolator') # Importing the data from csv files and settign extent and resolution gp.init_data(geo_model, [0, 10, 0, 10, -10, 0], [50, 50, 50], path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv", path_i=input_path + "/GeoModeller/test_a/test_a_Points.csv") geo_model.set_theano_function(interpolator) return geo_model
def load_model(name=None, path=None, recompile=False): """ Loading model saved with model.save_model function. Args: name: name of folder with saved files path (str): path to folder directory or the zip file recompile (bool): if true, theano functions will be recompiled Returns: :class:`Project` """ # TODO: Divide each dataframe in its own function and move them as # method of the class # TODO: Include try except in case some of the datafiles is missing # # Default path is_compressed = False if path is None: path = f'./{name}' p = pathlib.Path(path) # If the path includes .zip if p.suffix == '.zip': is_compressed, path = _unpack_model_if_compressed_includes_zip( is_compressed, path) # if the path does not include .zip but exist elif os.path.isfile(f'{path}.zip'): is_compressed = _unpack_model_if_compressed_no_zip(is_compressed, path) # create model with extent and resolution from csv - check geo_model = create_model() init_data(geo_model, np.load(f'{path}/{name}_extent.npy'), np.load(f'{path}/{name}_resolution.npy')) _load_files_into_geo_model(geo_model, name, path) if recompile is True: from gempy.api_modules.setters import set_interpolator set_interpolator(geo_model, verbose=[0]) # Cleaning temp files if is_compressed: shutil.rmtree(path) return geo_model
def test_reorder_series(): geo_model = gp.create_model('Geological_Model1') geo_model = gp.init_data(geo_model, extent=[0, 4000, 0, 2775, 200, 1200], resolution=[100, 10, 100]) # Adding a fault geo_model.rename_features(['Cycle1']) geo_model.add_features(['Fault1']) geo_model.set_is_fault(['Fault1']) geo_model.reorder_features(['Fault1', 'Cycle1']) assert (geo_model._stack.df['BottomRelation'] == ['Fault', 'Erosion']).all() assert (geo_model._stack.df.index == ['Fault1', 'Cycle1']).all() print(geo_model._stack.df)
def test_add_point(): extend = [0.0, 1.0, 0.0, 1.0, 0.0, 1.1] discretization = [5, 20, 20] x, y, z, f = 0.0, 0.0, 0.5, 'surface2' # %% geo_model = gp.create_model('test') gp.init_data(geo_model, extend, discretization) geo_model.set_default_surfaces() geo_model.set_default_orientation() strats = ['surface1', 'surface2', 'basement'] gp.map_stack_to_surfaces(geo_model, {'Strat_Series': strats}) geo_model.add_surface_points(x, y, z, f) geo_model.add_orientations(x, y, z, f, pole_vector=(1,0,0))
def test_issue_564(data_path): geo_model = gp.create_model('SBPM') gp.init_data(geo_model, [550, 730, -200, 1000, 20, 55], [50, 50, 50], path_i=data_path + "/564_Points.csv", path_o=data_path + "/564_Orientations_.csv", default_values=True) gp.map_stack_to_surfaces(geo_model, { "Q": 'Quartaer', "vK": 'verwKeuper', "Sa": 'Sandstein', "Sc": 'Schluffstein', "b": 'basement' }, remove_unused_series=True) gp.set_interpolator(geo_model, compile_theano=True, theano_optimizer='fast_compile') sol = gp.compute_model(geo_model) gp.plot_2d(geo_model) gpv = gp.plot_3d(geo_model, image=True, plotter_type='basic', ve=5, show_lith=False) geo_model.set_bottom_relation( ["Q", "vK", "Sa", "Sc", "b"], ["Onlap", "Onlap", "Onlap", "Onlap", "Onlap"]) sol = gp.compute_model(geo_model) gp.plot_2d(geo_model) gpv = gp.plot_3d(geo_model, image=True, plotter_type='basic', ve=5, show_lith=True)
def geo_model(interpolator): geo_model = gp.create_model('Test_uncomformities') # Importing the data from CSV-files and setting extent and resolution gp.init_data( geo_model, [0, 10., 0, 2., 0, 5.], [100, 3, 100], path_o=input_path + '/05_toy_fold_unconformity_orientations.csv', path_i=input_path + '/05_toy_fold_unconformity_interfaces.csv', default_values=True) gp.map_stack_to_surfaces( geo_model, { "Flat_Series": 'Flat', "Inclined_Series": 'Inclined', "Fold_Series": ('Basefold', 'Topfold', 'basement') }) # Create the theano model geo_model.set_theano_function(interpolator) return geo_model
def test_map2loop_model_import_data(): geo_model = gp.create_model('test_map2Loop') gp.init_data( geo_model, extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top], resolution=[50, 50, 50], path_o=orientations_file, path_i=contacts_file ) # Load Topology geo_model.set_topography(source='gdal', filepath=fp) gp.plot_2d(geo_model, ve=10, show_topography=True) plt.show() # Plot in 3D gp.plot_3d(geo_model, ve=None, show_topography=False, image=True, kwargs_plot_data={'arrow_size': 400} ) print(geo_model.orientations)
def test_map2loop_model_import_aus(): geo_model = gp.create_model('test_map2Loop') gp.init_data( geo_model, extent=extent_g, resolution=[50, 50, 50], path_o=orientations_file2, path_i=contacts_file2 ) # Load Topology geo_model.set_topography(source='gdal', array=fp2) gp.plot_2d(geo_model, ve=10, show_topography=True) plt.show() # Plot in 3D gp.plot_3d(geo_model, ve=None, show_topography=False, image=False, kwargs_plot_data={'arrow_size': 40} ) print(geo_model.orientations)
def load_model(): verbose = False geo_model = gp.create_model('Model_Tuto1-1') # Importing the data from CSV-files and setting extent and resolution gp.init_data(geo_model, [0, 2000., 0, 2000., 0, 2000.], [50 ,50 ,50], path_o=input_path+"/simple_fault_model_orientations.csv", path_i=input_path+"/simple_fault_model_points.csv", default_values=True) df_cmp_i = gp.get_data(geo_model, 'surface_points') df_cmp_o = gp.get_data(geo_model, 'orientations') df_o = pn.read_csv(input_path + "/simple_fault_model_orientations.csv") df_i = pn.read_csv(input_path + "/simple_fault_model_points.csv") assert not df_cmp_i.empty, 'data was not set to dataframe' assert not df_cmp_o.empty, 'data was not set to dataframe' assert df_cmp_i.shape[0] == df_i.shape[0], 'data was not set to dataframe' assert df_cmp_o.shape[0] == df_o.shape[0], 'data was not set to dataframe' if verbose: gp.get_data(geo_model, 'surface_points').head() return geo_model
# %% # Data initialization: # ~~~~~~~~~~~~~~~~~~~~ # # Suggested size of the axis-aligned modeling box: Origin: 548800 7816600 # -8400 Maximum: 552500 7822000 -11010 # # Suggested resolution: 100m x 100m x -90m (grid size 38 x 55 x 30) # # %% # Number of voxels: np.array([38, 55, 30]).prod() # %% geo_model = gp.create_model('Claudius') # Importing the data from csv files and settign extent and resolution geo_model = gp.init_data(geo_model, extent=[548800, 552500, 7816600, 7822000, -11010, -8400], resolution=[38, 55, 30], surface_points_df=surface_points[::5], orientations_df=orientations, surface_name='surface', add_basement=True) # %% # We are going to increase the smoothness (nugget) of the data to increase # the conditional number of the matrix: # # %% geo_model.modify_surface_points(geo_model.surface_points.df.index, smooth=0.1).df.tail() # %%
# %% cwd = os.getcwd() if 'examples' not in cwd: data_path = os.getcwd() + '/examples' else: data_path = cwd + '/../..' path_interf = data_path + "/data/input_data/AlesModel/2018_interf.csv" path_orient = data_path + "/data/input_data/AlesModel/2018_orient_clust_n_init5_0.csv" path_dem = data_path + "/data/input_data/AlesModel/_cropped_DEM_coarse.tif" # %% resolution = [100, 100, 100] extent = np.array([729550.0, 751500.0, 1913500.0, 1923650.0, -1800.0, 800.0]) geo_model = gp.create_model('Alesmodel') gp.init_data(geo_model, extent=extent, resolution=resolution, path_i=path_interf, path_o=path_orient) # %% sdict = {'section1': ([732000, 1916000], [745000, 1916000], [200, 150])} geo_model.set_section_grid(sdict) # %% # sorting of lithologies gp.map_stack_to_surfaces(geo_model, { 'fault_left': ('fault_left'), 'fault_right': ('fault_right'),
# Drop unecesary data point orientations.drop([1, 3, 4], inplace=True) orientations # %% # Data initialization: # ~~~~~~~~~~~~~~~~~~~~ # # Suggested size of the axis-aligned modeling box: Origin: 0 -0.5 0 # Maximum: 16 0.5 4.5 # # Suggested resolution: 0.05m (grid size 321 x 21 x 91) # # %% geo_model = gp.create_model('Moureze') geo_model = gp.init_data(geo_model, extent=[0, 16, -0.5, 0.5, 0, 4.5], resolution=[321, 21, 91], surface_points_df=surface_points, orientations_df=orientations, surface_name='surface', add_basement=True) # %% geo_model.orientations.df.at[5, 'surface'] # %% geo_model.orientations.df # %%
def test_complex_model(): geo_model = gp.create_model('Geological_Model1') geo_model = gp.init_data(geo_model, extent=[0, 4000, 0, 2775, 200, 1500], resolution=[100, 10, 100]) gp.set_interpolator(geo_model, theano_optimizer='fast_run', verbose=[]) geo_model.add_features(['Fault2', 'Cycle2', 'Fault1', 'Cycle1']) geo_model.delete_features('Default series') geo_model.add_surfaces(['F2', 'H', 'G', 'F1', 'D', 'C', 'B', 'A']) gp.map_stack_to_surfaces(geo_model, { 'Fault1': 'F1', 'Fault2': 'F2', 'Cycle2': ['G', 'H'] }) geo_model.set_is_fault(['Fault1', 'Fault2']) ###Cycle 1 # surface B - before F1 geo_model.add_surface_points(X=584, Y=285, Z=500, surface='B') geo_model.add_surface_points(X=494, Y=696, Z=500, surface='B') geo_model.add_surface_points(X=197, Y=1898, Z=500, surface='B') geo_model.add_surface_points(X=473, Y=2180, Z=400, surface='B') geo_model.add_surface_points(X=435, Y=2453, Z=400, surface='B') # surface C - before F1 geo_model.add_surface_points(X=946, Y=188, Z=600, surface='C') geo_model.add_surface_points(X=853, Y=661, Z=600, surface='C') geo_model.add_surface_points(X=570, Y=1845, Z=600, surface='C') geo_model.add_surface_points(X=832, Y=2132, Z=500, surface='C') geo_model.add_surface_points(X=767, Y=2495, Z=500, surface='C') # Surface D - Before F1 geo_model.add_surface_points(X=967, Y=1638, Z=800, surface='D') geo_model.add_surface_points(X=1095, Y=996, Z=800, surface='D') # Adding orientation to Cycle 1 geo_model.add_orientations(X=832, Y=2132, Z=500, surface='C', orientation=[76, 17.88, 1]) # surface B - After F1 geo_model.add_surface_points(X=1447, Y=2554, Z=500, surface='B') geo_model.add_surface_points(X=1511, Y=2200, Z=500, surface='B') geo_model.add_surface_points(X=1549, Y=629, Z=600, surface='B') geo_model.add_surface_points(X=1630, Y=287, Z=600, surface='B') # surface C - After F1 geo_model.add_surface_points(X=1891, Y=2063, Z=600, surface='C') geo_model.add_surface_points(X=1605, Y=1846, Z=700, surface='C') geo_model.add_surface_points(X=1306, Y=1641, Z=800, surface='C') geo_model.add_surface_points(X=1476, Y=979, Z=800, surface='C') geo_model.add_surface_points(X=1839, Y=962, Z=700, surface='C') geo_model.add_surface_points(X=2185, Y=893, Z=600, surface='C') geo_model.add_surface_points(X=2245, Y=547, Z=600, surface='C') # Surface D - After F1 geo_model.add_surface_points(X=2809, Y=2567, Z=600, surface='D') geo_model.add_surface_points(X=2843, Y=2448, Z=600, surface='D') geo_model.add_surface_points(X=2873, Y=876, Z=700, surface='D') # Surface D - After F2 geo_model.add_surface_points(X=3056, Y=2439, Z=650, surface='D') geo_model.add_surface_points(X=3151, Y=1292, Z=700, surface='D') ### Fault 1 # Surface F1 geo_model.add_surface_points(X=1203, Y=138, Z=600, surface='F1') geo_model.add_surface_points(X=1250, Y=1653, Z=800, surface='F1') # orientation to Fault 1 geo_model.add_orientations(X=1280, Y=2525, Z=500, surface='F1', orientation=[272, 90, 1]) ### Cycle 2 # Surface G - Before F2 geo_model.add_surface_points(X=1012, Y=1493, Z=900, surface='G') geo_model.add_surface_points(X=1002, Y=1224, Z=900, surface='G') geo_model.add_surface_points(X=1579, Y=1376, Z=850, surface='G') geo_model.add_surface_points(X=2489, Y=336, Z=750, surface='G') geo_model.add_surface_points(X=2814, Y=1848, Z=750, surface='G') # Surface H - Before F2 geo_model.add_surface_points(X=2567, Y=129, Z=850, surface='H') geo_model.add_surface_points(X=3012, Y=726, Z=800, surface='H') # Orientation to cycle 2 geo_model.add_orientations(X=1996, Y=47, Z=800, surface='G', orientation=[92, 5.54, 1]) # Surface G - After F2 geo_model.add_surface_points(X=3031, Y=2725, Z=800, surface='G') geo_model.add_surface_points(X=3281, Y=2314, Z=750, surface='G') geo_model.add_surface_points(X=3311, Y=1357, Z=750, surface='G') geo_model.add_surface_points(X=3336, Y=898, Z=750, surface='G') # Surface H - After F2 geo_model.add_surface_points(X=3218, Y=1818, Z=890, surface='H') geo_model.add_surface_points(X=3934, Y=1207, Z=810, surface='H') geo_model.add_surface_points(X=3336, Y=704, Z=850, surface='H') ### Fault 2 geo_model.add_surface_points(X=3232, Y=178, Z=1000, surface='F2') geo_model.add_surface_points(X=2912, Y=2653, Z=700, surface='F2') # Add orientation to Fault 2 geo_model.add_orientations(X=3132, Y=951, Z=700, surface='F2', orientation=[85, 90, 1]) gp.compute_model(geo_model, sort_surfaces=False) module = GemPyModule(geo_model=geo_model, extent=extent, box=[1000, 800], load_examples=False) module.show_boundary = True module.show_lith = True module.show_hillshades = True module.show_contour = True module.show_fill_contour = False sb_params = module.update(pytest.sb_params) sb_params['fig'].show()
def test_map2loop_model_no_faults(): # Location box bbox = (500000, 7490000, 545000, 7520000) model_base = -3200 # Original 3200 model_top = 800 # Input files geo_model = gp.create_model('test_map2Loop') gp.init_data( geo_model, extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top], resolution=[50, 50, 80], path_o=orientations_file, path_i=contacts_file ) gp.set_interpolator(geo_model) # Load Topology geo_model.set_topography(source='gdal', filepath=fp) # Stack Processing contents = np.genfromtxt(series_file, delimiter=',', dtype='U100')[1:, 4:-1] map_series_to_surfaces = {} for pair in contents: map_series_to_surfaces.setdefault(pair[1], []).append(pair[0]) gp.map_stack_to_surfaces(geo_model, map_series_to_surfaces, remove_unused_series=False) gp.plot_2d(geo_model, ve=10, show_topography=False) plt.show() # Plot in 3D gp.plot_3d(geo_model, ve=10, show_topography=False, image=True) # Stack Processing contents = np.genfromtxt(series_file, delimiter=',', dtype='U100')[1:, 4:-1] map_series_to_surfaces = {} for pair in contents: map_series_to_surfaces.setdefault(pair[1], []).append(pair[0]) gp.map_stack_to_surfaces(geo_model, map_series_to_surfaces, remove_unused_series=False) # Adding axial rescale #geo_model._rescaling.toggle_axial_anisotropy() # Increasing nugget effect geo_model.modify_surface_points( geo_model.surface_points.df.index, smooth=0.001 ) geo_model.modify_kriging_parameters('drift equations', [9, 9, 9, 9, 9]) gp.compute_model(geo_model) gp.plot_2d(geo_model, section_names=['topography'], show_topography=True, ) plt.show() gp.plot_3d(geo_model, ve=10, show_topography=True, image=True, show_lith=False, )
============ """ import os # Importing GemPy import gempy as gp # Importing auxiliary libraries import matplotlib matplotlib.rcParams['figure.figsize'] = (20.0, 10.0) os.environ["THEANO_FLAGS"] = "mode=FAST_RUN,device=cuda" # %% data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' geo_model = gp.create_model('Perth_Basin') # %% gp.init_data( geo_model, extent=[337000, 400000, 6640000, 6710000, -18000, 1000], resolution=[100, 100, 100], path_i=data_path + "/data/input_data/Perth_basin/Paper_GU2F_sc_faults_topo_Points.csv", path_o=data_path + "/data/input_data/Perth_basin/Paper_GU2F_sc_faults_topo_Foliations.csv") # %% geo_model.surfaces # %%
""" # %% # Importing import gempy as gp import numpy as np import matplotlib.pyplot as plt np.random.seed(1234) # %% # Setup the model # --------------- # # %% geo_model = gp.create_model('Tutorial_ch1-1_Basics') # Importing the data from CSV-files and setting extent and resolution data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' gp.init_data( geo_model, [0, 2000., 0, 2000., 0, 2000.], [5, 5, 5], path_o=data_path + "/data/input_data/tut_chapter1/simple_fault_model_orientations.csv", path_i=data_path + "/data/input_data/tut_chapter1/simple_fault_model_points.csv", default_values=True) gp.map_stack_to_surfaces(geo_model, { "Fault_Series": 'Main_Fault', "Strat_Series":
def test_colors_101_surfaces(): """Tests if GemPy Colors class works with at least 101 surfaces.""" geomodel = gp.create_model("ColorfulModel") for n in range(101): geomodel.add_surfaces(f"Surface {n}") assert np.all(geomodel.surfaces.df.color.values != np.nan)