def test_e(self, theano_f_1f): """ Two layers a bit curvy, 1 fault """ data_interp = theano_f_1f[0] compiled_f = theano_f_1f[1] # Importing the data from csv files and settign extent and resolution geo_data = gempy.import_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_f="./GeoModeller/test_e/test_e_Foliations.csv", path_i="./GeoModeller/test_e/test_e_Points.csv") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series']) geo_data.n_faults = 1 data_interp.set_interpolator(geo_data) i = data_interp.get_input_data(u_grade=[3, 3]) sol = compiled_f(*i) # print(data_interp.rescale_factor, 'rescale') real_sol = np.load('test_e_sol.npy') np.testing.assert_array_almost_equal(sol[:, :2, :], real_sol, decimal=3)
def test_e(self, interpolator): """ Two layers a bit curvy, 1 fault """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_o=input_path+"/GeoModeller/test_e/test_e_Foliations.csv", path_i=input_path+"/GeoModeller/test_e/test_e_Points.csv") gempy.set_series(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) if update_sol: np.save(input_path + '/test_e_sol.npy', sol.lith_block[test_values]) gempy.plot.plot_section(geo_data, 25, direction='y', show_data=True) plt.savefig(os.path.dirname(__file__)+'/../figs/test_e.png', dpi=200) # Load model real_sol = np.load(input_path + '/test_e_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 test_e(self, theano_f_1f): """ Two layers a bit curvy, 1 fault """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_o=input_path+"/GeoModeller/test_e/test_e_Foliations.csv", path_i=input_path+"/GeoModeller/test_e/test_e_Points.csv") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series'], order_formations=['f1','A','B'], verbose=0) interp_data = theano_f_1f # Updating the interp data which has theano compiled interp_data.update_interpolator(geo_data, u_grade=[1, 1]) # Compute model sol = gempy.compute_model(interp_data) if False: np.save(input_path + '/test_e_sol.npy', sol) gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True) plt.savefig(os.path.dirname(__file__)+'/figs/test_e.png', dpi=200) # Load model real_sol = np.load(input_path + '/test_e_sol.npy') # We only compare the block because the absolute pot field I changed it np.testing.assert_array_almost_equal(np.round(sol[0][0, :]), real_sol[0][0, :], decimal=0)
def test_set_orientations(): # Importing the data from CSV-files and setting extent and resolution geo_data = gp.create_data( [0, 2000, 0, 2000, 0, 2000], [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.set_series( geo_data, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1') }, order_series=["Fault_Series", 'Strat_Series'], order_formations=[ 'Main_Fault', 'Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1', ], verbose=0) gp.set_orientation_from_interfaces(geo_data, [0, 1, 2])
def theano_f_1f(self): # Importing the data from csv files and settign extent and resolution geo_data = gempy.import_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_f="./GeoModeller/test_d/test_d_Foliations.csv", path_i="./GeoModeller/test_d/test_d_Points.csv") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series']) # data_interp = gempy.set_interpolator(geo_data, # dtype="float64", # verbose=['solve_kriging', # 'faults block' # ]) # # Set all the theano shared parameters and return the symbolic variables (the input of the theano function) # input_data_T = data_interp.interpolator.tg.input_parameters_list() # # # Prepare the input data (interfaces, foliations data) to call the theano function. # # Also set a few theano shared variables with the len of formations series and so on # input_data_P = data_interp.interpolator.data_prep(u_grade=[3, 3]) # # # Compile the theano function. # compiled_f = theano.function(input_data_T, data_interp.interpolator.tg.whole_block_model(1), # allow_input_downcast=True, profile=True) # data_interp.interpolator.get_kriging_parameters() geo_data.n_faults = 1 data_interp = gempy.InterpolatorInput(geo_data, dtype='float64') compiled_f = data_interp.compile_th_fn() return data_interp, compiled_f
def vista_obj(self) -> vs.Vista: """Return a GemPy Vista instance with basic geomodel attached.""" from gempy.plot import vista as vs geo_model = gp.create_data( [0, 2000, 0, 2000, 0, 2000], [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.set_series( geo_model, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1') }) geo_model.set_is_fault(['Fault_Series']) gp.set_interpolator(geo_model) gp.compute_model(geo_model) # with open(os.path.dirname(__file__)+"input_data/geomodel_fabian_sol.p", "rb") as f: # geo_model.solutions = load(f) return vs.Vista(geo_model)
def theano_f_1f(self): # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_o=os.path.dirname(__file__)+"/GeoModeller/test_d/test_d_Foliations.csv", path_i=os.path.dirname(__file__)+"/GeoModeller/test_d/test_d_Points.csv") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series']) interp_data = gempy.InterpolatorData(geo_data, dtype='float64', compile_theano=True) return interp_data
def test_ch2(theano_f): # Importing the data from csv files and settign extent and resolution geo_data = gp.create_data([696000,747000,6863000,6930000,-20000, 200], [50, 50, 50], path_o=input_path+"/input_data/tut_SandStone/SandStone_Foliations.csv", path_i=input_path+"/input_data/tut_SandStone/SandStone_Points.csv") gp.plotting.plot_data(geo_data, direction='z') # Assigning series to formations as well as their order (timewise) gp.set_series(geo_data, {"EarlyGranite_Series": 'EarlyGranite', "BIF_Series":('SimpleMafic2', 'SimpleBIF'), "SimpleMafic_Series":'SimpleMafic1'}, order_series = ["EarlyGranite_Series", "BIF_Series", "SimpleMafic_Series"], order_formations= ['EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1'], verbose=1) # interp_data = gp.InterpolatorData(geo_data, theano_optimizer='fast_run', # compile_theano=True, verbose=[]) interp_data = theano_f interp_data.update_interpolator(geo_data) lith_block, fault_block = gp.compute_model(interp_data) import matplotlib.pyplot as plt gp.plot_section(geo_data, lith_block[0], -2, plot_data=True, direction='z') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) gp.plot_section(geo_data, lith_block[0],25, plot_data=True, direction='x') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) # In[14]: gp.plot_scalar_field(geo_data, lith_block[1], 11, cmap='viridis', N=100) import matplotlib.pyplot as plt plt.colorbar(orientation='horizontal') vertices, simplices = gp.get_surfaces(interp_data, lith_block[1], None, original_scale=False) pyevtk = pytest.importorskip("pyevtk") gp.export_to_vtk(geo_data, path=os.path.dirname(__file__)+'/vtk_files', lith_block=lith_block[0], vertices=vertices, simplices=simplices)
def theano_f_grav(): # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data([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") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series']) interp_data = gempy.InterpolatorData(geo_data, dtype='float64', compile_theano=True, output='gravity', verbose=[]) return interp_data
def test_f(self, theano_f_1f): """ Two layers a bit curvy, 1 fault. Checked with geomodeller """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data( [0, 2000, 0, 2000, -2000, 0], [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.set_series(geo_data, { 'series': ('Reservoir', 'Seal', 'SecondaryReservoir', 'NonReservoirDeep'), 'fault1': 'MainFault' }, order_series=['fault1', 'series'], order_formations=[ 'MainFault', 'SecondaryReservoir', 'Seal', 'Reservoir', 'NonReservoirDeep' ], verbose=0) interp_data = theano_f_1f # Updating the interp data which has theano compiled interp_data.update_interpolator(geo_data, u_grade=[1, 1]) # Compute model sol = gempy.compute_model(interp_data) if False: np.save(input_path + '/test_f_sol.npy', sol) real_sol = np.load(input_path + '/test_f_sol.npy') gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True) plt.savefig(os.path.dirname(__file__) + '/figs/test_f.png', dpi=200) # We only compare the block because the absolute pot field I changed it np.testing.assert_array_almost_equal(np.round(sol[0][0, :]), real_sol[0][0, :], decimal=0) ver, sim = gempy.get_surfaces(interp_data, sol[0][1], sol[1][1], original_scale=True)
def test_series_front(self, test_model_init): model = test_model_init # Assigning series to surface as well as their order (timewise) gp.set_series(model, {"Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1')}, order_series=["Fault_Series", 'Strat_Series'], order_formations=['Main_Fault', 'Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1', 'basement' ], verbose=0) print(model.series) return model
def test_ch6(theano_f_1f): # initialize geo_data object geo_data = gp.create_data([0, 3000, 0, 20, 0, 2000], resolution=[50, 3, 67]) # import data points geo_data.import_data_csv( input_path + "/input_data/tut_chapter6/ch6_data_interf.csv", input_path + "/input_data/tut_chapter6/ch6_data_fol.csv") gp.set_series( geo_data, { "fault": geo_data.get_formations()[np.where( geo_data.get_formations() == "Fault")[0][0]], "Rest": np.delete(geo_data.get_formations(), np.where(geo_data.get_formations() == "Fault")[0][0]) }, order_series=["fault", "Rest"], verbose=0, order_formations=['Fault', 'Layer 2', 'Layer 3', 'Layer 4', 'Layer 5']) gp.plot_data(geo_data) plt.xlim(0, 3000) plt.ylim(0, 2000) interp_data = gp.InterpolatorData(geo_data, u_grade=[0, 1]) lith_block, fault_block = gp.compute_model(interp_data) gp.plot_section(geo_data, lith_block[0], 0) G, centroids, labels_unique, lith_to_labels_lot, labels_to_lith_lot = gp.topology_compute( geo_data, lith_block[0], fault_block) gp.plot_section(geo_data, lith_block[0], 0, direction='y') gp.plot_topology(geo_data, G, centroids) lith_to_labels_lot["4"].keys() gp.topology.check_adjacency(G, 8, 3) G.adj[8] G.adj[8][2]["edge_type"]
def test_f_sort_surfaces(self, interpolator): """ Two layers a bit curvy, 1 fault. Checked with geomodeller """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data( [0, 2000, 0, 2000, -2000, 0], [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.set_series( geo_data, { 'fault1': 'MainFault', 'series': ('Reservoir', 'Seal', 'SecondaryReservoir', 'NonReservoirDeep'), }, ) geo_data.set_theano_function(interpolator) geo_data.set_is_fault('fault1') # Compute model sol = gempy.compute_model(geo_data, sort_surfaces=True) if update_sol: np.save(input_path + '/test_f_sol.npy', sol.lith_block[test_values]) real_sol = np.load(input_path + '/test_f_sol.npy') gempy.plot.plot_section(geo_data, 25, direction='y', show_data=True) plt.savefig(os.path.dirname(__file__) + '/../figs/test_f.png', dpi=200) # 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) ver, sim = gempy.get_surfaces(geo_data) print(ver, sim)
def geo_model(self): model = gp.create_data( [0, 2000, 0, 2000, 0, 2000], [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') # Assigning series to surface as well as their order (timewise) gp.set_series( model, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1') }, ) return model
def theano_f_grav(): # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data( [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") gempy.set_series(geo_data, { 'series': ('A', 'B'), 'fault1': 'f1' }, order_series=['fault1', 'series']) interp_data = gempy.InterpolatorData(geo_data, dtype='float64', compile_theano=True, output='gravity', verbose=[]) return interp_data
def test_d(self, theano_f_1f): """ Two layers 1 fault """ data_interp = theano_f_1f[0] compiled_f = theano_f_1f[1] # Importing the data from csv files and settign extent and resolution geo_data = gempy.import_data([0, 10, 0, 10, -10, 0], [50, 50, 50], path_f="./GeoModeller/test_d/test_d_Foliations.csv", path_i="./GeoModeller/test_d/test_d_Points.csv") gempy.set_series(geo_data, {'series': ('A', 'B'), 'fault1': 'f1'}, order_series=['fault1', 'series']) # rescaled_data = gempy.rescale_data(geo_data) # # # data_interp = gempy.set_interpolator(geo_data, dtype="float64",) # data_interp.interpolator._data_scaled = rescaled_data # data_interp.interpolator._grid_scaled = rescaled_data.grid # data_interp.interpolator.order_table() # data_interp.interpolator.set_theano_shared_parameteres() # # # Prepare the input data (interfaces, foliations data) to call the theano function. # # Also set a few theano shared variables with the len of formations series and so on # input_data_P = data_interp.interpolator.data_prep(u_grade=[3, 3]) # # data_interp.interpolator.get_kriging_parameters() # # sol = compiled_f(input_data_P[0], input_data_P[1], input_data_P[2], input_data_P[3], input_data_P[4], # input_data_P[5]) geo_data.n_faults = 1 data_interp.set_interpolator(geo_data) i = data_interp.get_input_data(u_grade=[3, 3]) sol = compiled_f(*i) # print(data_interp.rescale_factor, 'rescale') real_sol = np.load('test_d_sol.npy') np.testing.assert_array_almost_equal(sol[:, :2, :], real_sol, decimal=3)
def test_f(self, theano_f_1f): """ Two layers a bit curvy, 1 fault. Checked with geomodeller """ # Importing the data from csv files and settign extent and resolution geo_data = gempy.create_data([0, 2000, 0, 2000, -2000, 0], [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.set_series(geo_data, {'series': ('Reservoir', 'Seal', 'SecondaryReservoir', 'NonReservoirDeep' ), 'fault1': 'MainFault'}, order_series=['fault1', 'series'], order_formations=['MainFault', 'SecondaryReservoir', 'Seal', 'Reservoir', 'NonReservoirDeep'], verbose=0) interp_data = theano_f_1f # Updating the interp data which has theano compiled interp_data.update_interpolator(geo_data, u_grade=[1, 1]) # Compute model sol = gempy.compute_model(interp_data) if False: np.save(input_path + '/test_f_sol.npy', sol) real_sol = np.load(input_path + '/test_f_sol.npy') gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True) plt.savefig(os.path.dirname(__file__)+'/figs/test_f.png', dpi=200) # We only compare the block because the absolute pot field I changed it np.testing.assert_array_almost_equal(np.round(sol[0][0, :]), real_sol[0][0, :], decimal=0) ver, sim = gempy.get_surfaces(interp_data, sol[0][1], sol[1][1], original_scale=True)
def test_f(self, theano_f_1f): """ Two layers a bit curvy, 1 fault """ data_interp = theano_f_1f[0] compiled_f = theano_f_1f[1] # Importing the data from csv files and settign extent and resolution geo_data = gempy.import_data([0, 2000, 0, 2000, -2000, 0], [50, 50, 50], path_f="./GeoModeller/test_f/test_f_Foliations.csv", path_i="./GeoModeller/test_f/test_f_Points.csv") geo_data.set_formation_number(geo_data.formations[[3, 2, 1, 0, 4]]) gempy.set_series(geo_data, {'series': ('Reservoir' , 'Seal', 'SecondaryReservoir', 'NonReservoirDeep' ), 'fault1': 'MainFault'}, order_series=['fault1', 'series']) geo_data.n_faults = 1 data_interp.set_interpolator(geo_data) i = data_interp.get_input_data(u_grade=[3, 3]) sol = compiled_f(*i) real_sol = np.load('test_f_sol.npy') # np.testing.assert_array_almost_equal(sol[:, :2, :], real_sol, decimal=2) mismatch = ~np.isclose(sol[:, :2, :], real_sol, rtol=0.01).sum()/np.product(sol.shape) assert mismatch * 100 < 1 GeoMod_sol = geo_data.read_vox('./GeoModeller/test_f/test_f.vox') similarity = ((GeoMod_sol - sol[0, 0, :]) != 0).sum() / sol[0, 0].shape[0] print('The mismatch geomodeller-gempy is ', similarity*100, '%') assert similarity < 0.05, 'The mismatch with geomodeller is too high'
def topology_fabian(): """Return a GemPy Vista instance with basic geomodel attached.""" geo_model = gp.create_data( [0, 2000, 0, 2000, 0, 2000], [50, 50, 50], path_o=data_path / 'tut_chapter1/simple_fault_model_orientations.csv', path_i=data_path / 'tut_chapter1/simple_fault_model_points.csv') gp.set_series( geo_model, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1') }) geo_model.set_is_fault(['Fault_Series']) gp.set_interpolator(geo_model) gp.compute_model(geo_model) # with open("input_data/geomodel_fabian_sol.p", "rb") as f: # geo_model.solutions = load(f) edges, centroids = tp.compute_topology(geo_model, voxel_threshold=1) return edges, centroids
def test_ch6(theano_f_1f): # initialize geo_data object geo_data = gp.create_data([0, 3000, 0, 20, 0, 2000], resolution=[50, 3, 67]) # import data points geo_data.import_data_csv(input_path+"/input_data/tut_chapter6/ch6_data_interf.csv", input_path+"/input_data/tut_chapter6/ch6_data_fol.csv") gp.set_series(geo_data, {"fault":geo_data.get_formations()[np.where(geo_data.get_formations()=="Fault")[0][0]], "Rest":np.delete(geo_data.get_formations(), np.where(geo_data.get_formations()=="Fault")[0][0])}, order_series = ["fault", "Rest"], verbose=0, order_formations=['Fault','Layer 2', 'Layer 3', 'Layer 4', 'Layer 5']) gp.plot_data(geo_data) plt.xlim(0,3000) plt.ylim(0,2000); interp_data = gp.InterpolatorData(geo_data, u_grade=[0,1]) lith_block, fault_block = gp.compute_model(interp_data) gp.plot_section(geo_data, lith_block[0], 0) G, centroids, labels_unique, lith_to_labels_lot, labels_to_lith_lot = gp.topology_compute( geo_data, lith_block[0], fault_block) gp.plot_section(geo_data, lith_block[0], 0, direction='y') gp.plot_topology(geo_data, G, centroids) lith_to_labels_lot["4"].keys() gp.topology.check_adjacency(G, 8, 3) G.adj[8] G.adj[8][2]["edge_type"]
# get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: geo_data=gp.create_data(extent=[612000, 622000, 2472000, 2480000, -1000, 1000], resolution=[50, 50, 50], path_f = "../data/gempy_foliations.csv", path_i = "../data/gempy_interfaces.csv") # In[3]: gp.set_series(geo_data, {"Default series": np.unique(geo_data.interfaces["formation"].values)}, order_formations = np.unique(geo_data.interfaces["formation"].values)) gp.set_order_formations(geo_data, np.unique(geo_data.interfaces["formation"].values)) # ## 3.2 - Data visualization # In[4]: gp.plot_data(geo_data, direction="z") # In[5]:
import vtk import evtk from scipy.interpolate import griddata import decision_making as dm # Importing the data from csv files and setting extent and resolution geo_data = gp.create_data([0,2000,0,2000,0,2000],[50,50,50], path_o = "./reservoir_model_orientations.csv", path_i = "./reservoir_model_interfaces.csv") geo_data.n_faults = 1 gp.set_series(geo_data, {"fault":'MainFault', "Rest":('Base_Top', 'Res_Top', 'Seal_Top', 'SecRes_Top')}, order_series = ["fault","Rest",], order_formations=['MainFault', 'SecRes_Top', 'Seal_Top', 'Res_Top','Base_Top', ]) # DECLARING SOME MODEL VARIABLES resolution = geo_data.resolution[1] #resolution, standard: 50 model_size = geo_data.extent[:2][1] # 'real' model extent, here: 2000 m - cubic (what if not cubic?) scale_factor = (model_size/resolution) # scale factor used for calculating voxel volumes in [m] # here: 2000/50 = 40 #rescale_f = interp_data.rescaling_factor # rescaling factor from geo_data to interp_data minmax_buffer = True # buffer around local min and max values [on/off] - not used atm SSF_c = 3 # Creating a row label 'fault side' to distinguish between footwall (FW) and hanging wall (HW)
def test_ch5(theano_f_grav, theano_f): # Importing the data from csv files and settign extent and resolution geo_data = gp.create_data([696000,747000,6863000,6950000,-20000, 200],[50, 50, 50], path_o = input_path+"/input_data/tut_SandStone/SandStone_Foliations.csv", path_i = input_path+"/input_data/tut_SandStone/SandStone_Points.csv") # Assigning series to formations as well as their order (timewise) gp.set_series(geo_data, {"EarlyGranite_Series": 'EarlyGranite', "BIF_Series":('SimpleMafic2', 'SimpleBIF'), "SimpleMafic_Series":'SimpleMafic1'}, order_series = ["EarlyGranite_Series", "BIF_Series", "SimpleMafic_Series"], order_formations= ['EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1'], verbose=1) gp.plot_data(geo_data) #interp_data = gp.InterpolatorData(geo_data, compile_theano=True) interp_data = theano_f interp_data.update_interpolator(geo_data) lith_block, fault_block = gp.compute_model(interp_data) import matplotlib.pyplot as plt gp.plot_section(geo_data, lith_block[0], 10, plot_data=True, direction='y') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) from matplotlib.patches import Rectangle currentAxis = plt.gca() currentAxis.add_patch(Rectangle((7.050000e+05, 6863000), 747000 - 7.050000e+05, 6925000 - 6863000, alpha=0.3, fill='none', color ='green' )) ver_s, sim_s = gp.get_surfaces(interp_data, lith_block[1], None, original_scale=True) # gp.plot_surfaces_3D_real_time(interp_data, ver_s, sim_s) # Importing the data from csv files and settign extent and resolution geo_data_extended = gp.create_data([696000-10000, 747000 + 20600, 6863000 - 20600,6950000 + 20600, -20000, 600], [50, 50, 50], path_o=input_path + "/input_data/tut_SandStone/SandStone_Foliations.csv", path_i=input_path + "/input_data/tut_SandStone/SandStone_Points.csv") # Assigning series to formations as well as their order (timewise) gp.set_series(geo_data_extended, {"EarlyGranite_Series": 'EarlyGranite', "BIF_Series":('SimpleMafic2', 'SimpleBIF'), "SimpleMafic_Series":'SimpleMafic1'}, order_series = ["EarlyGranite_Series", "BIF_Series", "SimpleMafic_Series"], order_formations= ['EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1'], verbose=1) # interp_data_extended = gp.InterpolatorData(geo_data_extended, output='geology', # compile_theano=True) interp_data_extended = interp_data interp_data_extended.update_interpolator(geo_data_extended) geo_data_extended.set_formations(formation_values=[2.61,2.92,3.1,2.92,2.61], formation_order=['EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1', 'basement']) lith_ext, fautl = gp.compute_model(interp_data_extended) import matplotlib.pyplot as plt gp.plot_section(geo_data_extended, lith_ext[0], -1, plot_data=True, direction='z') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) from matplotlib.patches import Rectangle currentAxis = plt.gca() currentAxis.add_patch(Rectangle((7.050000e+05, 6863000), 747000 - 7.050000e+05, 6925000 - 6863000, alpha=0.3, fill='none', color ='green' )) interp_data_grav = theano_f_grav interp_data_grav.update_interpolator(geo_data_extended) gp.set_geophysics_obj(interp_data_grav, [7.050000e+05,747000,6863000,6925000,-20000, 200], [10, 10],) gp.precomputations_gravity(interp_data_grav, 10) lith, fault, grav = gp.compute_model(interp_data_grav, 'gravity') import matplotlib.pyplot as plt plt.imshow(grav.reshape(10, 10), cmap='viridis', origin='lower', extent=[7.050000e+05,747000,6863000,6950000] ) plt.colorbar()
def test_ch1(theano_f_1f): # Importing the data from CSV-files and setting extent and resolution geo_data = gp.create_data([0, 2000, 0, 2000, 0, 2000], [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.set_series(geo_data, {"Fault_Series":'Main_Fault', "Strat_Series": ('Sandstone_2','Siltstone', 'Shale', 'Sandstone_1')}, order_series = ["Fault_Series", 'Strat_Series'], order_formations=['Main_Fault', 'Sandstone_2','Siltstone', 'Shale', 'Sandstone_1', ], verbose=0) gp.get_sequential_pile(geo_data) print(gp.get_grid(geo_data)) gp.get_data(geo_data, 'interfaces').head() gp.get_data(geo_data, 'orientations') gp.plot_data(geo_data, direction='y') # interp_data = gp.InterpolatorData(geo_data, u_grade=[1,1], # output='geology', compile_theano=True, # theano_optimizer='fast_compile', # verbose=[]) interp_data = theano_f_1f interp_data.update_interpolator(geo_data) gp.get_kriging_parameters(interp_data) # Maybe move this to an extra part? lith_block, fault_block = gp.compute_model(interp_data) gp.plot_section(geo_data, lith_block[0], cell_number=25, direction='y', plot_data=True) gp.plot_scalar_field(geo_data, lith_block[1], cell_number=25, N=15, direction='y', plot_data=False) gp.plot_scalar_field(geo_data, lith_block[1], cell_number=25, N=15, direction='z', plot_data=False) gp.plot_section(geo_data, fault_block[0], cell_number=25, plot_data=True, direction='y') gp.plot_scalar_field(geo_data, fault_block[1], cell_number=25, N=20, direction='y', plot_data=False) ver, sim = gp.get_surfaces(interp_data,lith_block[1], fault_block[1], original_scale=True) # Cropping a cross-section to visualize in 2D #REDO this part? bool_b = np.array(ver[1][:,1] > 999)* np.array(ver[1][:,1] < 1001) bool_r = np.array(ver[1][:,1] > 1039)* np.array(ver[1][:,1] < 1041) # Plotting section gp.plot_section(geo_data, lith_block[0], 25, plot_data=True) ax = plt.gca() # Adding grid ax.set_xticks(np.linspace(0, 2000, 100, endpoint=False)) ax.set_yticks(np.linspace(0, 2000, 100, endpoint=False)) plt.grid() plt.ylim(1000,1600) plt.xlim(500,1100) # Plotting vertices ax.plot(ver[1][bool_r][:, 0], ver[1][bool_r][:, 2], '.', color='b', alpha=.9) ax.get_xaxis().set_ticklabels([]) ver_s, sim_s = gp.get_surfaces(interp_data,lith_block[1], fault_block[1], original_scale=True)
import decision_making as dm # Importing the data from csv files and setting extent and resolution geo_data = gp.create_data([0, 2000, 0, 2000, 0, 2000], [50, 50, 50], path_o="./reservoir_model_orientations.csv", path_i="./reservoir_model_interfaces.csv") geo_data.n_faults = 1 gp.set_series(geo_data, { "fault": 'MainFault', "Rest": ('Base_Top', 'Res_Top', 'Seal_Top', 'SecRes_Top') }, order_series=[ "fault", "Rest", ], order_formations=[ 'MainFault', 'SecRes_Top', 'Seal_Top', 'Res_Top', 'Base_Top', ]) # DECLARING SOME MODEL VARIABLES resolution = geo_data.resolution[1] #resolution, standard: 50 model_size = geo_data.extent[:2][ 1] # 'real' model extent, here: 2000 m - cubic (what if not cubic?) scale_factor = (model_size / resolution ) # scale factor used for calculating voxel volumes in [m] # here: 2000/50 = 40
def test_ch1(theano_f_1f): # Importing the data from CSV-files and setting extent and resolution geo_data = gp.create_data( [0, 2000, 0, 2000, 0, 2000], [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.set_series( geo_data, { "Fault_Series": 'Main_Fault', "Strat_Series": ('Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1') }, order_series=["Fault_Series", 'Strat_Series'], order_formations=[ 'Main_Fault', 'Sandstone_2', 'Siltstone', 'Shale', 'Sandstone_1', ], verbose=0) gp.get_sequential_pile(geo_data) print(gp.get_grid(geo_data)) gp.get_data(geo_data, 'interfaces').head() gp.get_data(geo_data, 'orientations') gp.plot_data(geo_data, direction='y') # interp_data = gp.InterpolatorData(geo_data, u_grade=[1,1], # output='geology', compile_theano=True, # theano_optimizer='fast_compile', # verbose=[]) interp_data = theano_f_1f interp_data.update_interpolator(geo_data) gp.get_kriging_parameters(interp_data) # Maybe move this to an extra part? lith_block, fault_block = gp.compute_model(interp_data) gp.plot_section(geo_data, lith_block[0], cell_number=25, direction='y', plot_data=True) gp.plot_scalar_field(geo_data, lith_block[1], cell_number=25, N=15, direction='y', plot_data=False) gp.plot_scalar_field(geo_data, lith_block[1], cell_number=25, N=15, direction='z', plot_data=False) gp.plot_section(geo_data, fault_block[0], cell_number=25, plot_data=True, direction='y') gp.plot_scalar_field(geo_data, fault_block[1], cell_number=25, N=20, direction='y', plot_data=False) ver, sim = gp.get_surfaces(interp_data, lith_block[1], fault_block[1], original_scale=True) # Cropping a cross-section to visualize in 2D #REDO this part? bool_b = np.array(ver[1][:, 1] > 999) * np.array(ver[1][:, 1] < 1001) bool_r = np.array(ver[1][:, 1] > 1039) * np.array(ver[1][:, 1] < 1041) # Plotting section gp.plot_section(geo_data, lith_block[0], 25, plot_data=True) ax = plt.gca() # Adding grid ax.set_xticks(np.linspace(0, 2000, 100, endpoint=False)) ax.set_yticks(np.linspace(0, 2000, 100, endpoint=False)) plt.grid() plt.ylim(1000, 1600) plt.xlim(500, 1100) # Plotting vertices ax.plot(ver[1][bool_r][:, 0], ver[1][bool_r][:, 2], '.', color='b', alpha=.9) ax.get_xaxis().set_ticklabels([]) ver_s, sim_s = gp.get_surfaces(interp_data, lith_block[1], fault_block[1], original_scale=True)
def test_rgeomod_integration(theano_f): geo_data=gp.create_data(extent=[612000, 622000, 2472000, 2480000, -1000, 1000], resolution=[50, 50, 50], path_f=input_path+"/gempy_foliations.csv", path_i=input_path+"/gempy_interfaces.csv") formation_order = ["Unit4", "Unit3", "Unit2", "Unit1"] gp.set_series(geo_data, {"Default series": formation_order}, order_formations = formation_order, verbose=1) gp.plot_data(geo_data, direction="z") #interp_data = gp.InterpolatorData(geo_data, compile_theano=True) interp_data = theano_f interp_data.update_interpolator(geo_data) lith_block, fault_block = gp.compute_model(interp_data) print("3-D geological model calculated.") gp.plot_section(geo_data, lith_block[0], 25, direction='y', plot_data=False) #plt.savefig("../data/cross_section_NS_25.pdf", bbox_inches="tight") gp.plot_section(geo_data, lith_block[0], 25, direction='x', plot_data=False) #plt.savefig("../data/cross_section_EW_25.pdf", bbox_inches="tight") vertices, simplices = gp.get_surfaces(interp_data, potential_lith=lith_block[1], step_size=2) fig = plt.figure(figsize=(13,10)) ax = fig.add_subplot(111, projection='3d') cs = ["lightblue", "pink", "lightgreen", "orange"] for i in range(4): surf = ax.plot_trisurf(vertices[i][:,0], vertices[i][:,1], vertices[i][:,2], color=cs[i], linewidth=0, alpha=0.65, shade=False) #plt.savefig("../data/surfaces_3D.pdf", bbox_inches="tight") # try: # gp.plot_surfaces_3D(geo_data, vertices, simplices) # except NameError: # print("3-D visualization library vtk not installed.") # load the digital elevation model geotiff_filepath = input_path+"/dome_sub_sub_utm.tif" raster = gdal.Open(geotiff_filepath) dtm = raster.ReadAsArray() dtmp = plt.imshow(dtm, origin='upper', cmap="viridis"); plt.title("Digital elevation model"); plt.colorbar(dtmp, label="Elevation [m]"); plt.savefig(input_path+"/DTM.pdf") # To be able to use gempy plotting functionality we need to create a dummy geo_data object with the # resoluion we want. In this case resolution=[339, 271, 1] import copy geo_data_dummy = copy.deepcopy(geo_data) geo_data_dummy.resolution = [339, 271, 1] # convert the dtm to a gempy-suitable raveled grid points = rgeomod.convert_dtm_to_gempy_grid(raster, dtm) # Now we can use the function `compute_model_at` to get the lithology values at a specific location: # In[17]: # interp_data_geomap = gp.InterpolatorInput(geo_data, dtype="float64") lith_block, fault_block = gp.compute_model_at(points, interp_data) # <div class="alert alert-info"> # **Your task:** Create a visual representation of the geological map in a 2-D plot (note: result is also again saved to the `../data`-folder): # </div> # # And here **the geological map**: # In[18]: gp.plot_section(geo_data_dummy, lith_block[0], 0, direction='z', plot_data=False) plt.title("Geological map"); #plt.savefig("../geological_map.pdf") # ### Export the map for visualization in GoogleEarth # <div class="alert alert-info"> # **Your task:** Execute the following code to export a GeoTiff of the generated geological map, as well as `kml`-files with your picked points inside the data folder. Open these files in GoogleEarth and inspect the generated map: # </div> # # # <div class="alert alert-warning"> # **Note (1)**: Use the normal `File -> Open..` dialog in GoogleEarth to open the data - no need to use the `Import` method, as the GeoTiff contains the correct coordinates in the file. # </div> # # # <div class="alert alert-warning"> # **Note (2)**: For a better interpretation of the generated map, use the transparency feature (directly after opening the map, or using `right-click -> Get Info` on the file). # </div> # In[19]: geo_map = lith_block[0].copy().reshape((339,271)) geo_map = geo_map.astype('int16') # change to int for later use # In[20]: rgeomod.export_geotiff(input_path+"/geomap.tif", geo_map, gp.plotting.colors.cmap, geotiff_filepath) # Export the interface data points: # In[21]: t = input_path+"/templates/ge_template_raw_interf.xml" pt = input_path+"/templates/ge_placemark_template_interf.xml" rgeomod.gempy_export_points_to_kml(input_path, geo_data, pt, t, gp.plotting.colors.cmap) # Export the foliation data: t = input_path+"/templates/ge_template_raw_fol.xml" pt = input_path+"/templates/ge_placemark_template_fol.xml" rgeomod.gempy_export_fol_to_kml(input_path+"/dips.kml", geo_data, pt, t)
def test_ch5(theano_f_grav, theano_f): # Importing the data from csv files and settign extent and resolution geo_data = gp.create_data( [696000, 747000, 6863000, 6950000, -20000, 200], [50, 50, 50], path_o=input_path + "/input_data/tut_SandStone/SandStone_Foliations.csv", path_i=input_path + "/input_data/tut_SandStone/SandStone_Points.csv") # Assigning series to formations as well as their order (timewise) gp.set_series(geo_data, { "EarlyGranite_Series": 'EarlyGranite', "BIF_Series": ('SimpleMafic2', 'SimpleBIF'), "SimpleMafic_Series": 'SimpleMafic1' }, order_series=[ "EarlyGranite_Series", "BIF_Series", "SimpleMafic_Series" ], order_formations=[ 'EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1' ], verbose=1) gp.plot_data(geo_data) #interp_data = gp.InterpolatorData(geo_data, compile_theano=True) interp_data = theano_f interp_data.update_interpolator(geo_data) lith_block, fault_block = gp.compute_model(interp_data) import matplotlib.pyplot as plt gp.plot_section(geo_data, lith_block[0], 10, plot_data=True, direction='y') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) from matplotlib.patches import Rectangle currentAxis = plt.gca() currentAxis.add_patch( Rectangle((7.050000e+05, 6863000), 747000 - 7.050000e+05, 6925000 - 6863000, alpha=0.3, fill='none', color='green')) ver_s, sim_s = gp.get_surfaces(interp_data, lith_block[1], None, original_scale=True) # gp.plot_surfaces_3D_real_time(interp_data, ver_s, sim_s) # Importing the data from csv files and settign extent and resolution geo_data_extended = gp.create_data( [ 696000 - 10000, 747000 + 20600, 6863000 - 20600, 6950000 + 20600, -20000, 600 ], [50, 50, 50], path_o=input_path + "/input_data/tut_SandStone/SandStone_Foliations.csv", path_i=input_path + "/input_data/tut_SandStone/SandStone_Points.csv") # Assigning series to formations as well as their order (timewise) gp.set_series(geo_data_extended, { "EarlyGranite_Series": 'EarlyGranite', "BIF_Series": ('SimpleMafic2', 'SimpleBIF'), "SimpleMafic_Series": 'SimpleMafic1' }, order_series=[ "EarlyGranite_Series", "BIF_Series", "SimpleMafic_Series" ], order_formations=[ 'EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1' ], verbose=1) # interp_data_extended = gp.InterpolatorData(geo_data_extended, output='geology', # compile_theano=True) interp_data_extended = interp_data interp_data_extended.update_interpolator(geo_data_extended) geo_data_extended.set_formations( formation_values=[2.61, 2.92, 3.1, 2.92, 2.61], formation_order=[ 'EarlyGranite', 'SimpleMafic2', 'SimpleBIF', 'SimpleMafic1', 'basement' ]) lith_ext, fautl = gp.compute_model(interp_data_extended) import matplotlib.pyplot as plt gp.plot_section(geo_data_extended, lith_ext[0], -1, plot_data=True, direction='z') fig = plt.gcf() fig.set_size_inches(18.5, 10.5) from matplotlib.patches import Rectangle currentAxis = plt.gca() currentAxis.add_patch( Rectangle((7.050000e+05, 6863000), 747000 - 7.050000e+05, 6925000 - 6863000, alpha=0.3, fill='none', color='green')) interp_data_grav = theano_f_grav interp_data_grav.update_interpolator(geo_data_extended) gp.set_geophysics_obj( interp_data_grav, [7.050000e+05, 747000, 6863000, 6925000, -20000, 200], [10, 10], ) gp.precomputations_gravity(interp_data_grav, 10) lith, fault, grav = gp.compute_model(interp_data_grav, 'gravity') import matplotlib.pyplot as plt plt.imshow(grav.reshape(10, 10), cmap='viridis', origin='lower', extent=[7.050000e+05, 747000, 6863000, 6950000]) plt.colorbar()