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_compute_model_multiple_ranges(self, interpolator): # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data( extent=[0, 2000, 0, 2000, -2000, 0], resolution=[50, 50, 50], path_o=input_path + "/GeoModeller/test_f/test_f_Foliations.csv", path_i=input_path + "/GeoModeller/test_f/test_f_Points.csv") gempy.map_stack_to_surfaces( geo_data, { 'fault1': 'MainFault', 'series': ('Reservoir', 'Seal', 'SecondaryReservoir', 'NonReservoirDeep'), }, ) geo_data.set_theano_function(interpolator) geo_data.set_is_fault('fault1') geo_data.modify_kriging_parameters('range', [3000, 3500, 0]) geo_data._additional_data.kriging_data.set_default_c_o() # Compute model sol = gempy.compute_model(geo_data, sort_surfaces=True) gempy.plot.plot_2d(geo_data, cell_number=25, direction='y', show_data=True) plt.show()
def create_model(resolution=[50, 50, 50]): geo_data = gp.create_data( 'fault', extent=[0, 1000, 0, 1000, 0, 1000], resolution=resolution, path_o=path_to_data + "model5_orientations.csv", path_i=path_to_data + "model5_surface_points.csv") geo_data.get_data() gp.map_stack_to_surfaces(geo_data, { "Fault_Series": 'fault', "Strat_Series": ('rock2', 'rock1') }) geo_data.set_is_fault(['Fault_Series']) interp_data = gp.set_interpolator(geo_data, theano_optimizer='fast_compile') sol = gp.compute_model(geo_data) geo = gp.plot_2d(geo_data, direction='y', show_data=True, show_lith=True, show_boundaries=False) geo.axes[0].set_title("") plt.tight_layout() plt.close() return geo.axes[0].figure
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 test_pile_geomodel_2(interpolator): 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_stack_to_surfaces(geo_model, series_distribution, remove_unused_series=True) geo_model.reorder_features( ["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) geo_model.set_theano_function(interpolator) gp.compute_model(geo_model) gp.plot.plot_2d(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 map_sequential_pile(load_model): geo_model = load_model # TODO decide what I do with the layer order gp.map_stack_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']) return geo_model
def one_fault_model_no_interp(): """This only makes sense for running small test fast""" model = gp.create_data('one_fault_model', [0, 2000, 0, 2000, 0, 2000], [50, 50, 50], path_o=input_path2 + 'tut_chapter1/simple_fault_model_orientations.csv', path_i=input_path2 + 'tut_chapter1/simple_fault_model_points.csv') # Assigning series to surface as well as their order (timewise) gp.map_stack_to_surfaces(model, {"Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1')}, ) model.set_is_fault(['Fault_Series']) return model
def model_complex(interpolator): model = gempy.create_data(extent=[0, 2500, 0, 1000, 0, 1000], resolution = [50, 20, 20], path_o=input_path2 + "jan_models/fixture_model_orientations.csv", path_i=input_path2 + "jan_models/fixture_model_surfaces.csv") # Assigning series to surface as well as their order (timewise) gp.map_stack_to_surfaces(model, {"Fault_Series": ('fault'), "Strat_Series1": ('rock3'), "Strat_Series2": ('rock2', 'rock1'), "Basement_Series": ('basement')}) model.set_is_fault(['Fault_Series']) model.set_theano_function(interpolator) return model
def unconformity_model(interpolator): geo_model = gp.create_data( 'unconformity_model', [0, 1000, 0, 1000, 0, 1000], resolution=[50, 42, 33], path_o=input_path2 + "jan_models/model6_orientations.csv", path_i=input_path2 + "jan_models/model6_surface_points.csv") gp.map_stack_to_surfaces( geo_model, { "Strat_Series1": ('rock3'), "Strat_Series2": ('rock2', 'rock1'), "Basement_Series": ('basement') }) # with open("input_data/geomodel_jan_sol.p", "rb") as f: # geo_model.solutions = load(f) geo_model.set_theano_function(interpolator) gp.compute_model(geo_model) return geo_model
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 test_d(self, interpolator): """ Two layers 1 fault """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data( extent=[0, 10, 0, 10, -10, 0], resolution=[50, 50, 50], path_o=input_path + "/GeoModeller/test_d/test_d_Foliations.csv", path_i=input_path + "/GeoModeller/test_d/test_d_Points.csv") gempy.map_stack_to_surfaces(geo_data, { 'fault1': 'f1', 'series': ('A', 'B') }) geo_data.set_is_fault('fault1') geo_data.set_theano_function(interpolator) # Compute model sol = gempy.compute_model(geo_data) gempy.plot.plot_2d(geo_data, cell_number=25, direction='y', show_data=True) plt.savefig(os.path.dirname(__file__) + '/../figs/test_d.png', dpi=200) if update_sol: np.save(input_path + '/test_d_sol.npy', sol.lith_block[test_values]) # Load model real_sol = np.load(input_path + '/test_d_sol.npy') # We only compare the block because the absolute pot field I changed it np.testing.assert_array_almost_equal(np.round( sol.lith_block[test_values]), real_sol, decimal=0)
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 create_gempy_model(resolution=[20, 20, 20], type=2): if type == 1: data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' path_to_data = data_path + "/data/input_data/jan_models/" geo_data = gp.create_data( 'fold', extent=[0, 1000, 0, 1000, 0, 1000], resolution=resolution, path_o=path_to_data + "model2_orientations.csv", path_i=path_to_data + "model2_surface_points.csv") gp.map_stack_to_surfaces(geo_data, { "Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement') }) interp_data = gp.set_interpolator(geo_data, theano_optimizer='fast_compile') sol = gp.compute_model(geo_data) elif type == 2: data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' path_to_data = data_path + "/data/input_data/jan_models/" geo_data = gp.create_data( 'unconformity', extent=[0, 1000, 0, 1000, 0, 1000], resolution=[50, 50, 50], path_o=path_to_data + "model6_orientations.csv", path_i=path_to_data + "model6_surface_points.csv") gp.map_stack_to_surfaces( geo_data, { "Strat_Series1": ('rock3'), "Strat_Series2": ('rock2', 'rock1'), "Basement_Series": ('basement') }) interp_data = gp.set_interpolator(geo_data, theano_optimizer='fast_compile') sol = gp.compute_model(geo_data) return geo_data
def test_set_orientations(): # Importing the data from CSV-files and setting extent and resolution geo_data = gp.create_data( extent=[0, 2000, 0, 2000, 0, 2000], resolution=[50, 50, 50], path_o=input_path + '/input_data/tut_chapter1/simple_fault_model_orientations.csv', path_i=input_path + '/input_data/tut_chapter1/simple_fault_model_points.csv') gp.get_data(geo_data) # Assigning series to formations as well as their order (timewise) gp.map_stack_to_surfaces(geo_data, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone') }) geo_data._orientations.create_orientation_from_surface_points( geo_data.surface_points, [0, 1, 2]) gp.set_orientation_from_surface_points(geo_data, [0, 1, 2])
def test_select_nearest_surface_points(): data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' path_to_data = data_path + "/data/input_data/jan_models/" geo_data = gp.create_data('fault', extent=[0, 1000, 0, 1000, 0, 1000], resolution=[50, 50, 50], path_o=path_to_data + "model5_orientations.csv", path_i=path_to_data + "model5_surface_points.csv") # Assigning series to formations as well as their order (timewise) gp.map_stack_to_surfaces(geo_data, { "Fault_Series": 'fault', "Strat_Series": ('rock2', 'rock1') }) geo_data.set_is_fault(['Fault_Series']) # detect fault names f_id = geo_data._faults.df.index.categories[ geo_data._faults.df.isFault.values] # find fault points fault_poi = geo_data._surface_points.df[ geo_data._surface_points.df.series.isin(f_id)] # find neighbours knn = gp.select_nearest_surfaces_points(geo_data, fault_poi, 1) radius = gp.select_nearest_surfaces_points(geo_data, fault_poi, 200.) # sort neighbours, necessary for equal testing knn = [k.sort_values() for k in knn] radius = [r.sort_values() for r in radius] # define reference reference = [[16, 17], [16, 17], [18, 19], [18, 19], [20, 21], [20, 21]] assert np.array_equal(reference, knn) and np.array_equal(reference, radius)
def test_set_orientation_from_neighbours(): data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' path_to_data = data_path + "/data/input_data/jan_models/" geo_data = gp.create_data('fault', extent=[0, 1000, 0, 1000, 0, 1000], resolution=[50, 50, 50], path_o=path_to_data + "model5_orientations.csv", path_i=path_to_data + "model5_surface_points.csv") # Assigning series to formations as well as their order (timewise) gp.map_stack_to_surfaces(geo_data, { "Fault_Series": 'fault', "Strat_Series": ('rock2', 'rock1') }) geo_data.set_is_fault(['Fault_Series']) # detect fault names f_id = geo_data._faults.df.index.categories[ geo_data._faults.df.isFault.values] # find fault points fault_poi = geo_data._surface_points.df[ geo_data._surface_points.df.series.isin(f_id)] # find neighbours neighbours = gp.select_nearest_surfaces_points(geo_data, fault_poi, 5) # calculate one fault orientation gp.set_orientation_from_neighbours(geo_data, neighbours[1]) # find the calculated orientation test = geo_data._orientations.df.sort_index().iloc[-1][['dip', 'azimuth']].values # calculate reference reference = [90 - np.arctan(0.5) / np.pi * 180, 90] assert np.array_equal(reference, test)
# %% data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/' geo_model = gp.create_data( 'viz_3d', [0, 2000, 0, 2000, 0, 1600], [50, 50, 50], path_o=data_path + "data/input_data/lisa_models/foliations" + str(7) + ".csv", path_i=data_path + "data/input_data/lisa_models/interfaces" + str(7) + ".csv") gp.map_stack_to_surfaces( geo_model, { "Fault_1": 'Fault_1', "Fault_2": 'Fault_2', "Strat_Series": ('Sandstone', 'Siltstone', 'Shale', 'Sandstone_2', 'Schist', 'Gneiss') }) geo_model.set_is_fault(['Fault_1', 'Fault_2']) geo_model.set_topography() gp.set_interpolator(geo_model) gp.compute_model(geo_model, compute_mesh=True) # %% # Basic plotting API # ------------------ #
# # %% geo_model.surfaces # %% geo_model.orientations.df.dtypes # %% # We will need to separate with surface belong to each series: # # %% gp.map_stack_to_surfaces(geo_model, { 'Fault1': 'f1', 'Fault2': 'f2', 'Fault3': 'f3' }) # %% # However if we want the faults to offset the “Default series”, they will # need to be more recent (higher on the pile). We can modify the order by: # # %% geo_model.modify_order_series(4, 'Default series') # %% # Lastly, so far we did not specify which series/faults are actula faults: #
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, )
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()
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": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1', 'basement') }, remove_unused_series=True) geo_model.set_is_fault(['Fault_Series']) # %% # Add sections # ~~~~~~~~~~~~ # # %% # pass section dictionary with startpoint, endpoint and resolution for # every section: #
geo_model.delete_surfaces(del_surfaces, remove_data=True) # %% # %debug # %% geo_model.stack # %% gp.map_stack_to_surfaces( geo_model, { "fault_Abrolhos_Transfer": ["Abrolhos_Transfer"], "fault_Coomallo": ["Coomallo"], "fault_Eneabba_South": ["Eneabba_South"], "fault_Hypo_fault_W": ["Hypo_fault_W"], "fault_Hypo_fault_E": ["Hypo_fault_E"], "fault_Urella_North": ["Urella_North"], "fault_Urella_South": ["Urella_South"], "fault_Darling": ["Darling"], "Sedimentary_Series": ['Cretaceous', 'Yarragadee', 'Eneabba', 'Lesueur', 'Permian'] }) # %% geo_model.series # %% order_series = [ "fault_Abrolhos_Transfer", "fault_Coomallo", "fault_Eneabba_South", "fault_Hypo_fault_W", "fault_Hypo_fault_E", "fault_Urella_North", "fault_Darling", "fault_Urella_South", "Sedimentary_Series", 'Basement'
resolution=[125, 50, 50], path_o=path_to_data + "model7_orientations.csv", path_i=path_to_data + "model7_surface_points.csv") # %% geo_data.get_data() # %% # Setting and ordering the units and series: # # %% gp.map_stack_to_surfaces( geo_data, { "Fault_Series": ('fault'), "Strat_Series1": ('rock3'), "Strat_Series2": ('rock2', 'rock1'), "Basement_Series": ('basement') }) geo_data.set_is_fault(['Fault_Series']) # %% gp.plot_2d(geo_data, direction='y') # %% # Calculating the model: # # %% interp_data = gp.set_interpolator(geo_data, theano_optimizer='fast_compile')
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'), 'fault_lr': ('fault_lr'), 'Trias_Series': ('TRIAS', 'LIAS'), 'Carbon_Series': ('CARBO'), 'Basement_Series': ('basement') }, remove_unused_series=True) # %% colordict = { 'LIAS': '#015482', 'TRIAS': '#9f0052', 'CARBO': '#ffbe00', 'basement': '#728f02', 'fault_left': '#2a2a2a', 'fault_right': '#545454', 'fault_lr': '#a5a391' }
path_to_data = data_path + "/data/input_data/jan_models/" geo_data = gp.create_data('pinchout', extent=[0, 1000, 0, 1000, 0, 1000], resolution=[50, 50, 50], path_o=path_to_data + "model4_orientations.csv", path_i=path_to_data + "model4_surface_points.csv") # %% geo_data.get_data() # %% # Setting and ordering the units and series: # # %% gp.map_stack_to_surfaces(geo_data, {"Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement')}) # %% gp.plot_2d(geo_data, direction=['y']) # %% # Calculating the model: # # %% interp_data = gp.set_interpolator(geo_data, theano_optimizer='fast_compile') # %% sol = gp.compute_model(geo_data)
def create_example_model(name, extent=[0, 1000, 0, 1000, 0, 1800], do_sections=False, change_color=False, data_path=path_to_data, resolution=[20, 20, 20], theano_optimizer='fast_compile'): # _test_data['gempy_data'], theano_optimizer='fast_compile'): """ Create all the example models Args: name: Name of the model to create extent: extent of the model in model units do_sections: False change_color: False data_path: Path to the .csv files storing the information theano_optimizer: 'fast_compile' Returns: geo_model """ assert name in all_models, 'possible model names are ' + str(all_models) if name == 'Horizontal_layers': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model1_orientations.csv", path_i=data_path + "model1_surface_points.csv") gp.map_stack_to_surfaces(geo_model, { "Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement') }) if change_color: geo_model.surfaces.colors.change_colors({ "rock2": '#9f0052', 'rock1': '#e36746', 'basement': '#f9f871' }) elif name == 'Anticline': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model2_orientations.csv", path_i=data_path + "model2_surface_points.csv") gp.map_stack_to_surfaces(geo_model, { "Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement') }) elif name == 'Recumbent_fold': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model3_orientations.csv", path_i=data_path + "model3_surface_points.csv") gp.map_stack_to_surfaces(geo_model, { "Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement') }) if change_color: geo_model.surfaces.colors.change_colors({ "rock2": '#e36746', 'rock1': '#c0539f', 'basement': '#006fa8' }) elif name == 'Pinchout': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model4_orientations.csv", path_i=data_path + "model4_surface_points.csv") gp.map_stack_to_surfaces(geo_model, { "Strat_Series": ('rock2', 'rock1'), "Basement_Series": ('basement') }) if change_color: geo_model.surfaces.colors.change_colors({ "rock2": '#a1b455', 'rock1': '#ffbe00', 'basement': '#006471' }) elif name == 'Fault': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model5_orientations.csv", path_i=data_path + "model5_surface_points.csv") gp.map_stack_to_surfaces(geo_model, { "Fault_Series": 'fault', "Strat_Series": ('rock2', 'rock1') }) geo_model.set_is_fault(['Fault_Series'], change_color=False) if change_color: geo_model.surfaces.colors.change_colors({ "rock2": '#00c2d0', 'rock1': '#a43d00', 'basement': '#76a237', 'fault': '#000000' }) elif name == 'Unconformity': geo_model = gp.create_data( name, extent=extent, resolution=resolution, path_o=data_path + "model6_orientations.csv", path_i=data_path + "model6_surface_points.csv") gp.map_stack_to_surfaces( geo_model, { "Strat_Series1": ('rock3'), "Strat_Series2": ('rock2', 'rock1'), "Basement_Series": ('basement') }) else: raise NotImplementedError(name, "Not available in example models") if do_sections: geo_model.set_section_grid( {'section' + ' ' + name: ([0, 500], [1000, 500], [30, 30])}) interp_data = gp.set_interpolator( geo_model, # compile_theano=True, theano_optimizer=theano_optimizer) sol = gp.compute_model(geo_model, compute_mesh=False) if do_sections: gp.plot_2d(geo_model, section_names=['section' + ' ' + name], show_data=False) return geo_model
def extract_borehole(geo_model: gp.core.model.Project, geo_data: gemgis.GemPyData, loc: List[Union[int, float]], **kwargs): """ Extracting a borehole at a provided location from a recalculated GemPy Model Args: geo_model: gp.core.model.Project - previously calculated GemPy Model geo_data: gemgis.GemPyData - GemGIS GemPy Data class used to calculate the previous model loc: list of x and y point pair representing the well location Kwargs: zmax: int/float indicating the maximum depth of the well, default is minz of the previous model res: int indicating the resolution of the model in z-direction Returns: """ # Checking if geo_model is a GemPy geo_model if not isinstance(geo_model, gp.core.model.Project): raise TypeError('geo_model must be a GemPy geo_model') # Checking if geo_data is a GemGIS GemPy Data Class if not isinstance(geo_data, gemgis.GemPyData): raise TypeError('geo_data must be a GemPy Data object') # Checking if loc is of type list if not isinstance(loc, list): raise TypeError( 'Borehole location must be provided as a list of a x- and y- coordinate' ) # Checking if elements of loc are of type int or float if not all(isinstance(n, (int, float)) for n in loc): raise TypeError( 'Location values must be provided as integers or floats') # Selecting DataFrame columns and create deep copy of DataFrame orientations_df = geo_model.orientations.df[[ 'X', 'Y', 'Z', 'surface', 'dip', 'azimuth', 'polarity' ]].copy(deep=True) interfaces_df = geo_model.surface_points.df[['X', 'Y', 'Z', 'surface']].copy(deep=True) # Creating formation column orientations_df['formation'] = orientations_df['surface'] interfaces_df['formation'] = interfaces_df['surface'] # Deleting surface column del orientations_df['surface'] del interfaces_df['surface'] # Getting maximum depth and resolution zmax = kwargs.get('zmax', geo_model.grid.regular_grid.extent[5]) res = kwargs.get('res', geo_model.grid.regular_grid.resolution[2]) # Checking if zmax is of type int or float if not isinstance(zmax, (int, float)): raise TypeError('Maximum depth must be of type int or float') # Checking if res is of type int if not isinstance(res, (int, float, np.int32)): raise TypeError('Resolution must be of type int') # Creating variable for maximum depth z = geo_model.grid.regular_grid.extent[5] - zmax # Prevent printing # sys.stdout = open(os.devnull, 'w') # Create GemPy Model well_model = gp.create_model('Well_Model') # Initiate Data for GemPy Model gp.init_data(well_model, extent=[ loc[0] - 5, loc[0] + 5, loc[1] - 5, loc[1] + 5, geo_model.grid.regular_grid.extent[4], geo_model.grid.regular_grid.extent[5] - z ], resolution=[5, 5, res], orientations_df=orientations_df.dropna(), surface_points_df=interfaces_df.dropna(), default_values=False) # Map Stack to surfaces gp.map_stack_to_surfaces(well_model, geo_data.stack, remove_unused_series=True) # Add Basement surface well_model.add_surfaces('basement') # Change colors of surfaces well_model.surfaces.colors.change_colors(geo_data.surface_colors) # Set Interpolator gp.set_interpolator(well_model, compile_theano=True, theano_optimizer='fast_run', dtype='float64', update_kriging=False, verbose=[]) # Set faults active for i in geo_model.surfaces.df[geo_model.surfaces.df['isFault'] == True]['surface'].values.tolist(): well_model.set_is_fault([i]) # Compute Model sol = gp.compute_model(well_model, compute_mesh=False) # Reshape lith_block well = sol.lith_block.reshape(well_model.grid.regular_grid.resolution[0], well_model.grid.regular_grid.resolution[1], well_model.grid.regular_grid.resolution[2]) # Select colors for plotting color_dict = well_model.surfaces.colors.colordict surface = well_model.surfaces.df.copy(deep=True) surfaces = surface[~surface['id'].isin(np.unique(np.round(sol.lith_block)) )] for key in surfaces['surface'].values.tolist(): color_dict.pop(key) cols = list(color_dict.values()) # Calculate boundaries boundaries = np.where( np.round(well.T[:, 1])[:-1] != np.round(well.T[:, 1])[1:] )[0][::well_model.grid.regular_grid.resolution[0]] # Create Plot plt.figure(figsize=(3, 10)) plt.imshow( np.rot90(np.round(well.T[:, 1]), 2), cmap=ListedColormap(cols), extent=(0, (well_model.grid.regular_grid.extent[5] - well_model.grid.regular_grid.extent[4]) / 8, well_model.grid.regular_grid.extent[4], well_model.grid.regular_grid.extent[5]), ) list_values = np.unique(np.round(well.T[:, 1])[:, 0]).tolist() # Display depths of layer boundaries for i in boundaries: plt.text((well_model.grid.regular_grid.extent[5] - well_model.grid.regular_grid.extent[4]) / 7, i * geo_model.grid.regular_grid.dz + geo_model.grid.regular_grid.extent[4] + geo_model.grid.regular_grid.dz, '%d m' % (i * geo_model.grid.regular_grid.dz + geo_model.grid.regular_grid.extent[4]), fontsize=14) del list_values[list_values.index(np.round(well.T[:, 1])[:, 0][i + 1])] # Plot last depth plt.text( (well_model.grid.regular_grid.extent[5] - well_model.grid.regular_grid.extent[4]) / 7, geo_model.grid.regular_grid.extent[4] + geo_model.grid.regular_grid.dz, '%d m' % (geo_model.grid.regular_grid.extent[4]), fontsize=14) list_values = np.unique(np.round(well.T[:, 1])[:, 0]).tolist() # Display lithology IDs for i in boundaries: plt.text((well_model.grid.regular_grid.extent[5] - well_model.grid.regular_grid.extent[4]) / 24, i * geo_model.grid.regular_grid.dz + geo_model.grid.regular_grid.extent[4] + 2 * geo_model.grid.regular_grid.dz, 'ID: %d' % (np.round(well.T[:, 1])[:, 0][i + 1]), fontsize=14) del list_values[list_values.index(np.round(well.T[:, 1])[:, 0][i + 1])] # Plot last ID plt.text((well_model.grid.regular_grid.extent[5] - well_model.grid.regular_grid.extent[4]) / 24, geo_model.grid.regular_grid.extent[4] + 1 * geo_model.grid.regular_grid.dz, 'ID: %d' % (list_values[0]), fontsize=14) # Set legend handles patches = [ mpatches.Patch( color=cols[i], label="{formation}".format(formation=surface[surface['id'].isin( np.unique(np.round(sol.lith_block)))].surface.to_list()[i])) for i in range( len(surface[surface['id'].isin(np.unique(np.round( sol.lith_block)))].surface.to_list())) ] # Remove xticks plt.tick_params(axis='x', labelsize=0, length=0) # Set ylabel plt.ylabel('Depth [m]') # Set legend plt.legend(handles=patches, bbox_to_anchor=(3, 1)) # Create depth dict depth_dict = { int(np.round(well.T[:, 1])[:, 0][i + 1]): i * geo_model.grid.regular_grid.dz + geo_model.grid.regular_grid.extent[4] for i in boundaries } depth_dict[int(list_values[0])] = geo_model.grid.regular_grid.extent[4] depth_dict = dict(sorted(depth_dict.items())) return sol, well_model, depth_dict
# # %% geo_model.surfaces # %% # We will need to separate with surface belong to each series: # # %% stratigraphy = 'fixed' # %% if stratigraphy == 'original': gp.map_stack_to_surfaces(geo_model, {'Fault': 'Claudius_fault', 'Default series': ('0', '60', '250', '330'), }) # Ordering the events from younger to older: geo_model.reorder_series(['Fault', 'Default series', 'Basement']) elif stratigraphy == 'fixed': gp.map_stack_to_surfaces(geo_model, {'Default series': ('0', '60', '250'), 'Fault': 'Claudius_fault', 'Uncomformity': '330', }) # Ordering the events from younger to older: geo_model.reorder_series(['Default series', 'Fault', 'Uncomformity', 'Basement']) # %% # So far we did not specify which series/faults are actula faults:
# %% geo_model.set_is_fault('Fault1') # %% # But we also need to add a new surface: # # %% geo_model.add_surfaces('fault1') # %% # And finally assign the new surface to the new series/fault # # %% gp.map_stack_to_surfaces(geo_model, {'Fault1': 'fault1'}) # %% # Now we can just add input data as before (remember the minimum amount of # input data to compute a model): # # %% # Add input data of the fault geo_model.add_surface_points(X=550, Y=0, Z=-30, surface='fault1') geo_model.add_surface_points(X=650, Y=0, Z=-200, surface='fault1') geo_model.add_orientations(X=600, Y=0, Z=-100, surface='fault1', pole_vector=(.3, 0, .3))