def test_masked_marching_cubes(unconformity_model_topo): geo_model = unconformity_model_topo gp.plot_2d(geo_model) plt.show() gp.plot_2d(geo_model, regular_grid=geo_model.solutions.mask_matrix_pad[0], kwargs_regular_grid={ 'cmap': 'viridis', 'norm': None }) print(geo_model.solutions.mask_matrix_pad[0]) plt.show() gp.plot_2d(geo_model, regular_grid=geo_model.solutions.mask_matrix_pad[1], kwargs_regular_grid={ 'cmap': 'viridis', 'norm': None }) print(geo_model.solutions.mask_matrix_pad[1]) plt.show() gp.plot_2d(geo_model, regular_grid=geo_model.solutions.mask_matrix[0], kwargs_regular_grid={ 'cmap': 'viridis', 'norm': None }) print(geo_model.solutions.mask_matrix[0]) plt.show()
def test_plot_3d_structure_topo2(unconformity_model_topo, artificial_grid): geo_model = unconformity_model_topo with pytest.raises(AssertionError): geo_model._grid.regular_grid.set_topography_mask(artificial_grid) # geo_model._grid.regular_grid.set_topography_mask(geo_model._grid.topography) p2d = gp.plot_2d(geo_model, section_names=['topography'], show_topography=True, show_lith=False, kwargs_topography={'hillshade': True}) plt.show() gpv = gp.plot.plot_3d(unconformity_model_topo, plotter_type='basic', off_screen=True, show_topography=True, show_scalar=False, show_lith=True, show_surfaces=True, kwargs_plot_structured_grid={ 'opacity': .5, 'show_edges': True }, image=True, kwargs_plot_topography={'scalars': 'topography'})
def show_geological_map(self): """Show the geological map from the gempy package""" self.im_geo_map = gempy.plot_2d(self.geo_model, section_names=['topography'], show_data=False, show_topography=True, show=False) self.panel_geo_map.object = self.im_geo_map.fig self.panel_geo_map.param.trigger('object') return self.im_geo_map.fig
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_simple_model_gempy_engine(): import numpy numpy.set_printoptions(precision=3, linewidth=200) g = gempy.create_data("test_engine", extent=[-4, 4, -4, 4, -4, 4], resolution=[4, 1, 4]) sp = np.array([[-3, 0, 0], [0, 0, 0], [2, 0, 0.5], [2.5, 0, 1.2], [3, 0, 2], [1, 0, .2], [2.8, 0, 1.5]]) g.set_default_surfaces() for i in sp: g.add_surface_points(*i, surface="surface1") g.add_orientations(-3, 0, 2, pole_vector=(0, 0, 1), surface="surface1") g.add_orientations(2, 0, 3, pole_vector=(-.2, 0, .8), surface="surface1") g.modify_orientations([0, 1], smooth=0.000000000001) g.modify_surface_points(g._surface_points.df.index, smooth=0.0000000001) gempy.set_interpolator(g, verbose=[ "n_surface_op_float_sigmoid", "scalar_field_iter", "compare", "sigma" ]) g.modify_kriging_parameters("range", 50) # g.modify_kriging_parameters("$C_o$", 5 ** 2 / 14 / 3) g.modify_kriging_parameters("drift equations", [0]) import theano dtype = "float32" g._interpolator.theano_graph.i_reescale.set_value(np.cast[dtype](1.)) g._interpolator.theano_graph.gi_reescale.set_value(np.cast[dtype](1.)) gempy.compute_model(g) print(g.additional_data) print(g.solutions.scalar_field_matrix) gempy.plot_2d(g) print(g.grid.values) print(g.solutions.weights_vector)
def test_masked_marching_cubes(): cwd = os.path.dirname(__file__) data_path = cwd + '/../../../examples/' geo_model = gp.load_model( r'Tutorial_ch1-8_Onlap_relations', path=data_path + 'data/gempy_models/Tutorial_ch1-8_Onlap_relations', recompile=True) geo_model.set_regular_grid([-200, 1000, -500, 500, -1000, 0], [50, 50, 50]) # geo_model.set_topography(d_z=np.array([-600, -100])) s = gp.compute_model(geo_model, compute_mesh=True, debug=False) gp.plot.plot_2d(geo_model, cell_number=2) gp.plot_2d(geo_model, cell_number=[2], regular_grid=geo_model.solutions.mask_matrix_pad[0], show_data=True, kwargs_regular_grid={ 'cmap': 'gray', 'norm': None }) gp.plot_2d(geo_model, cell_number=[2], regular_grid=geo_model.solutions.mask_matrix_pad[1], show_data=True, kwargs_regular_grid={ 'cmap': 'gray', 'norm': None }) gp.plot_2d(geo_model, cell_number=[2], regular_grid=geo_model.solutions.mask_matrix_pad[2], show_data=True, kwargs_regular_grid={ 'cmap': 'gray', 'norm': None }) gp.plot_2d(geo_model, cell_number=[2], regular_grid=geo_model.solutions.mask_matrix_pad[3], show_data=True, kwargs_regular_grid={ 'cmap': 'gray', 'norm': None }) p3d = gp.plot_3d(geo_model, show_surfaces=True, show_data=True, image=True, kwargs_plot_structured_grid={'opacity': .2})
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 test_sort_surfaces_by_solution(one_fault_model_topo_solution): geo_model = one_fault_model_topo_solution section_dict = { 'section_SW-NE': ([250, 250], [1750, 1750], [100, 100]), 'section_NW-SE': ([250, 1750], [1750, 250], [100, 100]) } geo_model.set_section_grid(section_dict) geo_model.set_active_grid('sections', reset=True) s1 = geo_model.solutions.scalar_field_at_surface_points geo_model.update_additional_data() geo_model.update_to_interpolator() gp.compute_model(geo_model, sort_surfaces=True) gp.plot_2d(geo_model, section_names=['section_NW-SE'], show_topography=True) plt.show() s2 = geo_model.solutions.scalar_field_at_surface_points gp.compute_model(geo_model, sort_surfaces=True) gp.plot_2d(geo_model, section_names=['section_NW-SE'], show_topography=True) plt.show() s3 = geo_model.solutions.scalar_field_at_surface_points np.testing.assert_array_equal(s2, s3) gp.compute_model(geo_model, sort_surfaces=True) gp.plot_2d(geo_model, section_names=['section_NW-SE'], show_topography=True) plt.show() return geo_model
def show_actual_model(self): """Show a cross_section of the actual gempy model""" # Get a cross_section in the middle of the model self.set_actual_dict() self.im_actual_model = gempy.plot_2d(self.geo_model, section_names=['Model: ' + self.geo_model.meta.project_name], show_data=False, show=False, show_topography=False) # self.im_actual_model.axes[0].set_ylim(self.frame.min(), self.frame.max()) self.im_actual_model.axes[0].set_aspect(aspect=0.5) self.panel_actual_model.object = self.im_actual_model.fig self.panel_actual_model.param.trigger('object') return self.im_actual_model.fig
def test_plot_2d_topography(one_fault_model_no_interp, artificial_grid): geo_model = one_fault_model_no_interp #geo_model._grid.topography = artificial_grid geo_model.set_topography() p2d = gp.plot_2d(geo_model, section_names=['topography'], show_topography=True, kwargs_topography={'hillshade': False}) plt.show() p2d = gp.plot_2d(geo_model, section_names=['topography'], show_topography=True, kwargs_topography={ 'hillshade': True, 'fill_contour': False }) plt.show() p2d = gp.plot_2d(geo_model, section_names=['topography'], show_topography=True, kwargs_topography={'hillshade': True}) plt.show()
def show_cross_section(self, name: str): """ Show the 2d cross_section or geological map Args: name: Show the cross section of the Returns: """ if name in self.section_dict.keys(): self.im_plot_2d = gempy.plot_2d(self.geo_model, section_names=[name], show_data=False, show_topography=True, show=False) # self.im_plot_2d.axes[0].set_ylim(self.frame.min(), self.frame.max()) self.im_plot_2d.axes[0].set_aspect(aspect=0.5) self.panel_plot_2d.object = self.im_plot_2d.fig self.panel_plot_2d.param.trigger('object') return self.im_plot_2d.fig else: logger.warning("no key in section_dict have the name: %s" %name)