コード例 #1
0
ファイル: test_anisotropies.py プロジェクト: sklgp2016/gempy
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
コード例 #2
0
ファイル: test_anisotropies.py プロジェクト: sklgp2016/gempy
def test_axial_anisotropy_type_extent(model):
    geo_model = model

    geo_model._rescaling.toggle_axial_anisotropy(type='extent')
    # gp.compute_model(geo_model, compute_mesh_options={'mask_topography': False})

    geo_model.surface_points.df[['X', 'Y',
                                 'Z']] = geo_model.surface_points.df[[
                                     'X_c', 'Y_c', 'Z_c'
                                 ]]
    geo_model.orientations.df[['X', 'Y', 'Z']] = geo_model.orientations.df[[
        'X_c', 'Y_c', 'Z_c'
    ]]

    # This is a hack
    geo_model._grid.topography.extent = geo_model._grid.extent_c

    geo_model.set_regular_grid(geo_model._grid.extent_c, [50, 50, 50])

    gp.plot_3d(geo_model,
               ve=None,
               show_topography=False,
               image=True,
               show_lith=False,
               kwargs_plot_data={'arrow_size': 10})
コード例 #3
0
ファイル: test_io.py プロジェクト: sklgp2016/gempy
def test_load_model_compressed_remote2():
    model_file = pooch.retrieve(url="https://github.com/cgre-aachen/gempy_data/raw/master/"
                                    "data/gempy_models/Onlap_relations.zip",
                                known_hash=None)

    geo_model = gp.load_model(name='Onlap_relations', path=model_file, recompile=True)
    gp.compute_model(geo_model)
    gp.plot_3d(geo_model, image=True)
コード例 #4
0
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)
コード例 #5
0
ファイル: test_anisotropies.py プロジェクト: sklgp2016/gempy
def test_axial_anisotropy(model):
    # Location box

    geo_model = model
    geo_model._rescaling.toggle_axial_anisotropy()
    # gp.compute_model(geo_model, compute_mesh_options={'mask_topography': False})

    geo_model.surface_points.df[['X', 'Y',
                                 'Z']] = geo_model.surface_points.df[[
                                     'X_c', 'Y_c', 'Z_c'
                                 ]]
    geo_model.orientations.df[['X', 'Y', 'Z']] = geo_model.orientations.df[[
        'X_c', 'Y_c', 'Z_c'
    ]]

    # This is a hack
    geo_model._grid.topography.extent = geo_model._grid.extent_c

    geo_model.set_regular_grid(geo_model._grid.extent_c, [50, 50, 50])
    geo_model.modify_kriging_parameters('range', 0.1)
    geo_model.modify_kriging_parameters('drift equations', [9, 9, 9, 9, 9])

    geo_model.modify_surface_points(geo_model.surface_points.df.index,
                                    smooth=0.001)

    gp.set_interpolator(geo_model,
                        theano_optimizer='fast_run',
                        dtype='float64')
    gp.compute_model(geo_model,
                     compute_mesh_options={
                         'mask_topography': False,
                         'masked_marching_cubes': False
                     })

    gp.plot_2d(
        geo_model,
        section_names=['topography'],
        show_topography=True,
    )
    plt.show()

    gp.plot_3d(geo_model,
               ve=None,
               show_topography=False,
               image=True,
               show_lith=False,
               kwargs_plot_data={'arrow_size': 10})
コード例 #6
0
ファイル: test_io.py プロジェクト: sklgp2016/gempy
def test_load_model(recompute=False):
    """Load model from disk"""
    cwd = os.path.dirname(__file__)
    data_path = cwd + '/../../examples/'

    if recompute:
        geo_model = gp.load_model(r'Tutorial_ch1-8_Onlap_relations',
                                  path=data_path + 'data/gempy_models/Tutorial_ch1'
                                                   '-8_Onlap_relations',
                                  recompile=True)
        gp.compute_model(geo_model)
        gp.plot_3d(geo_model, image=True)

    else:
        geo_model = gp.load_model(r'Tutorial_ch1-8_Onlap_relations',
                                  path=data_path + 'data/gempy_models/Tutorial_ch1'
                                                   '-8_Onlap_relations',
                                  recompile=False)
コード例 #7
0
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})
コード例 #8
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)
コード例 #9
0
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)
コード例 #10
0
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)
コード例 #11
0
ファイル: test_unconformities.py プロジェクト: rmaciver/gempy
def test_two_onlap(geo_model):
    geo_model.set_bottom_relation(['Flat_Series', 'Inclined_Series'],
                                  bottom_relation='Onlap')
    sol = gp.compute_model(geo_model, compute_mesh=True)
    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
               })

    p3d = gp.plot_3d(geo_model,
                     show_surfaces=True,
                     show_data=True,
                     image=True,
                     kwargs_plot_structured_grid={'opacity': .2})

    if save:
        np.save(os.path.dirname(__file__) + '/two_onlap', sol.lith_block)

    check = np.load(os.path.dirname(__file__) + '/two_onlap.npy')
    np.testing.assert_allclose(sol.lith_block, check)

    plt.savefig(os.path.dirname(__file__) + '/two_onlap')
    print(sol)
コード例 #12
0
 def plot_3d_model(self):
     """Generate a 3D gempy model and return a the pyvista object"""
     self.geo_3d = gempy.plot_3d(
         self.geo_model,
         plotter_type=self._plotter_type,
         show_data=self._param_3d_model['show_data'],
         show_results=self._param_3d_model['show_results'],
         show_surfaces=self._param_3d_model['show_surfaces'],
         show_lith=self._param_3d_model['show_lith'],
         show_scalar=self._param_3d_model['show_scalar'],
         show_boundaries=self._param_3d_model['show_boundaries'],
         show_topography=self._param_3d_model['show_topography'],
         notebook=self._notebook,
         image=False,
         off_screen=False,
         ve=self._ve)
     return self.geo_3d
コード例 #13
0
ファイル: test_unconformities.py プロジェクト: rmaciver/gempy
def test_all_erosion(geo_model):
    sol = gp.compute_model(geo_model, compute_mesh=True)
    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
               })

    if save:
        np.save(os.path.dirname(__file__) + '/all_ero', sol.lith_block)

    check = np.load(os.path.dirname(__file__) + '/all_ero.npy')
    np.testing.assert_allclose(sol.lith_block, check)
    # plt.savefig(os.path.dirname(__file__)+'/all_ero')

    p3d = gp.plot_3d(geo_model,
                     show_surfaces=True,
                     show_data=True,
                     image=True,
                     kwargs_plot_structured_grid={'opacity': .2})

    print(sol)
コード例 #14
0
ファイル: Hecho.py プロジェクト: sklgp2016/gempy
# Time
# ~~~~
#
# -  GTX 2080 164 ms ± 2.03 ms per loop (mean ± std. dev. of 7 runs, 1
#    loop each)
#

# %%
gp.plot_2d(geo_model, cell_number=[10], series_n=3, show_scalar=True)

# %%
gp.plot_2d(geo_model, cell_number=[10], show_data=True)

# %%
# sphinx_gallery_thumbnail_number = 3
gp.plot_3d(geo_model, kwargs_plot_structured_grid={'opacity': 8})

# %%
# Export data:
# ~~~~~~~~~~~~
#
# The solution is stored in a numpy array of the following shape. Axis 0
# are the scalar fields of each correspondent series/faults in the
# following order (except basement):
#

# %%
geo_model.series

# %%
# For the surfaces, there are two numpy arrays, one with vertices and the
コード例 #15
0
ファイル: map2gempy.py プロジェクト: snowmanman/gempy
def loop2gempy(
        contacts_file: str,
        orientations_file: str,
        bbox: Iterable,
        groups_file: str,
        model_base: float,
        model_top: float, dtm_reproj_file: str = None,
        faults_contact: str = None,
        faults_orientations: str = None,
        faults_faults_rel: str = None,
        faults_groups_rel: str = None,
        faults_rel_matrix = None,
        model_name: str = None,
        compute: bool = True,
        vtk: bool = False,
        vtk_path: str = None,
        image_2d: bool = False,
        plot_3d_kwargs=None
):
    """ Calculate the model using gempy as backend.

        At the moment there is not support for finite faults since gempy does not
         accept passing the ellipsoid parameters directly.

        :param contacts_file (str): path of contacts file
        :param orientations_file: path of orientations file
        :param bbox: model bounding box
        :param groups_file: path of groups file
        :param model_base: z value of base of model
        :param model_top: z value of top of model
        :param dtm_reproj_file: path of dtm file
        :param faults_contact: path of contacts file with fault data
        :param faults_orientations: path of orientations file with fault data
        :param faults_rel_matrix: bool matrix describing the interaction between groups. Rows offset columns
        :param faults_groups_rel: bool matrix describing the interaction between faults and features
        :param faults_faults_rel: bool matrix describing the interaction between faults and faults
        :param model_name: name of the model
        :param compute (bool): Default True. Whether or not compute the model
        :param vtk (bool): Default False. Whether or not visualize the model
        :param vtk_path (str): Default None. Path of vtk output directory
        :param plot_3d_kwargs (dict): kwargs for `gempy.plot_3d`
        :return: gempy.Project
    """
    if plot_3d_kwargs is None:
        plot_3d_kwargs = {}

    contacts = []
    orientations = []

    contacts.append(
        pd.read_csv(
            contacts_file,
            sep=',',
            names=['X', 'Y', 'Z', 'formation'],
            header=1
        )
    )

    if faults_contact is not None:
        contacts.append(
            pd.read_csv(
                faults_contact,
                sep=',',
                names=['X', 'Y', 'Z', 'formation'],
                header=1
            )
        )

    orientations.append(
        pd.read_csv(
            orientations_file,
            sep=',',
            names=['X', 'Y', 'Z', 'azimuth', 'dip', 'polarity', 'formation'],
            header=1
        )
    )

    if faults_orientations is not None:
        orientations.append(
            pd.read_csv(
                faults_orientations,
                sep=',',
                names=['X', 'Y', 'Z', 'azimuth', 'dip', 'polarity', 'formation'],
                header=1
            )
        )

    if faults_faults_rel is not None and faults_groups_rel is not None:
        ff_ = pd.read_csv(faults_faults_rel).set_index('fault_id')
        fg_ = pd.read_csv(faults_groups_rel).set_index('group')
        p_ = pd.concat((ff_, fg_), axis=0, sort=True)
        faults_rel_matrix = pd.concat((p_, fg_.T), axis=1, sort=True).fillna(0).values

    surface_points_ready = pd.concat(contacts, sort=True)
    surface_points_ready.reset_index(inplace=True, drop=False)
    orientation_ready = pd.concat(orientations, sort=True)
    orientation_ready.reset_index(inplace=True, drop=False)

    if model_name is None:
        model_name = 'loop2gempy'

    geo_model = gp.create_model(model_name)
    gp.init_data(
        geo_model,
        extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base, model_top],
        resolution=[50, 50, 50],
        orientations_df=orientation_ready,
        surface_points_df=surface_points_ready
    )

    # Load Topology
    if dtm_reproj_file is not None:
        if type(dtm_reproj_file) is str:
            source = 'gdal'
            topo_kwarg = {'filepath': dtm_reproj_file}
        elif type(dtm_reproj_file) is np.ndarray:
            source = 'numpy'
            topo_kwarg = {'array': dtm_reproj_file}
        else:
            raise AttributeError('dtm_proj_file must be either a path to gdal or a'
                                 'numpy array with values')
        geo_model.set_topography(source=source, **topo_kwarg)

    # Stack Processing
    contents = np.genfromtxt(groups_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)

    order_formations = geo_model.stack.df.index.drop('Default series')

    # Get the unassigned series as faults
    if faults_contact is not None and faults_orientations is not None:
        faults_pair = geo_model._surfaces.df.groupby('series').get_group('Default series')[[
            'surface']].values[:, 0]
        faults_pair_dict = dict(zip(faults_pair, faults_pair))
        gp.map_stack_to_surfaces(geo_model, faults_pair_dict, remove_unused_series=True)
        # Grabbing the order of faults and Formations
        ordered_features = np.append(faults_pair, order_formations)
        # Sorting series
        geo_model.reorder_features(ordered_features)
        geo_model.set_is_fault(faults_pair)

        # Faults relation
        geo_model.set_fault_relation(faults_rel_matrix)

    geo_model.add_surfaces('basement')

    # Check if there is features without data and delete it
    try:
        f_ = geo_model.surfaces.df.groupby('isActive').get_group(False)
        features_without_data = f_['series']
        geo_model.delete_features(features_without_data, remove_surfaces=True, remove_data=True)
    except KeyError:
        pass

    if faults_contact is not None and faults_orientations is not None:
        get_fault_names = geo_model.stack.df.groupby(['isActive', 'isFault']).get_group(
            (True, True)).index
        geo_model._surfaces.colors.make_faults_black(get_fault_names)

    try:
        colours = pd.read_csv(groups_file).set_index('code')['colour']
        # Drop formations that do not exist in surfaces
        colours = colours.loc[colours.index.isin(geo_model.surfaces.df['surface'])].to_dict()

        geo_model._surfaces.colors.change_colors(colours)
    except KeyError:
        pass

    if compute is True:
        gp.set_interpolator(geo_model, dtype='float64',
                            # verbose=['solve_kriging']
                            )

        # Increasing nugget effect
        geo_model.modify_surface_points(
            geo_model.surface_points.df.index,
            smooth=0.1
        )

        geo_model.modify_orientations(
            geo_model.orientations.df.index,
            smooth=0.01
        )

        new_range = geo_model.get_additional_data().loc[('Kriging', 'range'), 'values'] * 0.5
        geo_model.modify_kriging_parameters('range', new_range)

        gp.compute_model(geo_model)

    if vtk is True:
        gp.plot_3d(geo_model, show_topography=True,
                   image=image_2d,
                   show_lith=True,
                   **plot_3d_kwargs
                   )

    if vtk_path is not None:
        gp._plot.export_to_vtk(geo_model, path=vtk_path, name=model_name + '.vtk',
                               voxels=False, block=None, surfaces=True)

    return geo_model
コード例 #16
0
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,
               )
コード例 #17
0
ファイル: ch1_1_basics.py プロジェクト: RichardScottOZ/gempy
# Using ``plot_data_3D``\ , we can also visualize this data in 3D. Note that
# direct 3D visualization in GemPy requires `the Visualization
# Toolkit <https://www.vtk.org/>`__ (VTK) to be installed.
#
# All 3D plots in GemPy are interactive. This means that we can drag
# and drop any data point and measurement. The perpendicular axis views in
# VTK are particularly useful to move points solely on a desired 2D plane.
# Any changes will then be stored permanently in the "InputData"
# dataframe. If we want to reset our data points, we will then need to
# reload our original input data.
#
# Executing the cell below will open a new window with a 3D interactive
# plot of our data.

# %%
gpv = gp.plot_3d(geo_model, image=False, plotter_type='basic')

# %%
# Model generation
# ~~~~~~~~~~~~~~~~
#
# Once we have made sure that we have defined all our primary information
# as desired in our object ``DataManagement.InputData`` (named
# ``geo_data`` in these tutorials), we can continue with the next step
# towards creating our geological model: preparing the input data for
# interpolation.
#
# This is done by generating an ``InterpolatorData`` object (named
# ``interp_data`` in these tutorials) from our ``InputData`` object via
# the following function:
#
コード例 #18
0
ファイル: Perth_basin.py プロジェクト: snowmanman/gempy
# %%
fr[:, :-2] = False
fr

# %%
geo_model.set_fault_relation(fr)

# %%
# %matplotlib inline
gp.plot_2d(geo_model, direction=['z'])

# %%
geo_model.set_topography(source='random')

# %%
gp.plot_3d(geo_model)

# %%
interp_data = gp.set_interpolator(geo_model,
                                  compile_theano=True,
                                  theano_optimizer='fast_run',
                                  gradient=False,
                                  dtype='float32')

# %%
gp.compute_model(geo_model)

# %%
gp.plot_2d(geo_model, cell_number=[25])

# %%
コード例 #19
0
               'norm': None
           })

gp.plot_2d(geo_model,
           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,
           2,
           regular_grid=geo_model.solutions.mask_matrix_pad[3],
           show_data=True,
           kwargs_regular_grid={
               'cmap': 'gray',
               'norm': None
           })

# %%
# sphinx_gallery_thumbnail_number = 7
p3d = gp.plot_3d(geo_model,
                 show_surfaces=True,
                 show_data=True,
                 image=False,
                 show_topography=True,
                 kwargs_plot_structured_grid={'opacity': .2})

gp.save_model(geo_model)
コード例 #20
0
# %%
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)

# %%
# Displaying the result in x and y direction:
#

# %%
gp.plot_2d(geo_data,
           cell_number=5,
           direction='y',
           show_data=False,
           show_boundaries=True)

# %%
# sphinx_gallery_thumbnail_number = 2
gp.plot_2d(geo_data, cell_number=5, direction='x', show_data=True)

# %%
gp.plot_3d(geo_data)
gp.save_model(geo_data)
コード例 #21
0
#

# %%
# Reading image
img = mpimg.imread('wells.png')
# Plotting it inplace
p2d = gp.plot_2d(geo_model, show=False)
p2d.axes[0].imshow(img, origin='upper', alpha=.8, extent=(0, 791, -582, 0))
plt.show()

# %%
# We can do the same in 3D through pyvista and vtk rendering:
#

# %%
p3d = gp.plot_3d(geo_model)

# %%
# Building the model
# ------------------
#
# Now that we have everything initialize we can start the construction of
# the geological model.
#
# Surfaces
# ~~~~~~~~
#
# GemPy is a surface based interpolator. This means that all the input
# data we add has to be refered to a surface. The surfaces always mark the
# bottom of a unit. By default GemPy surfaces are empty:
#
コード例 #22
0
ファイル: more_examples.py プロジェクト: rmaciver/gempy
def create_example(name_model,
                   interpolator=None,
                   save_pickle=False,
                   plot_section=True):
    """
    Create an inter_data from one of the examples data_set
    
    Attr:
        name_model (str): name of the model that you want to generate. It has to be in ['Model 1' ,'Model 2', 'Model 3', 'Model 4','Model 5' 'Model 6','Model 7',
                          'Model 8', 'Model 9']
        save_pickle (bool, str): Save to a pickle the interp_data object. You can pass the path as a string otherwse
                                the default name will be given
        plot_section (bool)
    
    """
    name_list = np.array([
        'Model 1', 'Model 2', 'Model 3', 'Model 4', 'Model 5', 'Model 6',
        'Model 7', 'Model 8', 'Model 9'
    ])
    assert name_model in name_list, 'Name model must be in the following list: ' + str(
        name_list)
    # Extract number of the model
    n_model = name_model[-1]

    # Load right gempy geodata
    geo_data = gp.create_data(
        name_model,
        extent=[0, 2000, 0, 2000, 0, 1600],
        resolution=[50, 50, 50],
        path_o=data_path + "/data/input_data/lisa_models/foliations" +
        n_model + ".csv",
        path_i=data_path + "/data/input_data/lisa_models/interfaces" +
        n_model + ".csv")

    # Set the right sequential pile
    subset_list_1 = np.array(['Model 1'])
    subset_list_2 = np.array(['Model 5', 'Model 8'])
    subset_list_3 = np.array(['Model 2', 'Model 3', 'Model 9', 'Model 6'])
    subset_list_4 = np.array(['Model 7'])
    ### Model 1 - Discordant layering ###
    if name_model in subset_list_1:
        gp.map_series_to_surfaces(
            geo_data,
            {
                "Strat_Series_1": ('Sandstone', 'Siltstone', 'Shale'),
                "Strat_Series_2": ('Sandstone2', 'Siltstone2', 'Shale2')
            },
        )
    ### Model 5 - One normal Fault ###
    ### Model 8 - ###
    elif name_model in subset_list_2:
        gp.map_series_to_surfaces(
            geo_data,
            {
                "Fault_Series":
                'Main_Fault',
                "Strat_Series": ('Sandstone', 'Siltstone', 'Shale',
                                 'Sandstone_2', 'Schist', 'Gneiss')
            },
        )
        geo_data.set_is_fault(['Fault_Series'])
    elif name_model in subset_list_3:
        ### Model 2 - Aufwölbung (durch Salzstock?) ###
        ### Model 3+9 - Parallele NNE Schichtung ohne Verwerfung ###
        ### Model 6 - Mulde ###
        gp.map_series_to_surfaces(
            geo_data,
            {
                "Strat_Series": ('Sandstone', 'Siltstone', 'Shale',
                                 'Sandstone_2', 'Schist', 'Gneiss')
            },
        )

    elif name_model in subset_list_4:
        ### Model 7 - Graben ###
        gp.map_series_to_surfaces(
            geo_data,
            {
                "Fault_1":
                'Fault_1',
                "Fault_2":
                'Fault_2',
                "Strat_Series": ('Sandstone', 'Siltstone', 'Shale',
                                 'Sandstone_2', 'Schist', 'Gneiss')
            },
        )
        geo_data.set_is_fault(['Fault_1', 'Fault_2'])

    else:
        print('You would never reach this point. Look for the bug')

    # Interpolation and Computation
    if interpolator is None:
        interp_data = gp.set_interpolator(geo_data,
                                          theano_optimizer='fast_run')
    else:
        interp_data = interpolator
        geo_data.set_theano_function(interpolator)
    sol = gp.compute_model(geo_data)

    if plot_section is True:
        # 2D Plot
        gp.plot_2d(geo_data, cell_number=25, direction='y', show_data=True)
        gp.plot_3d(geo_data)

    if save_pickle is not False:
        if type(save_pickle) is str:
            gp.save_model_to_pickle(geo_data, save_pickle)
        else:
            gp.save_model_to_pickle(geo_data, 'lisa-' + str(n_model))

    return interp_data
コード例 #23
0
    'section4_3': ([2670826, 1268793], [2676862, 1255579], [100, 100]),
    'section4_4': ([2649021, 1267107], [2659842, 1246715], [100, 100]),
    'section4_8': ([2643284, 1259358], [2680261, 1268521], [100, 100])
}
geo_model.set_section_grid(section_dict)

# ## Plot Data in 3D
#
# Using PyVista, a high-level visualization software for 3D visualization, we can plot the data in 3D:

# In[7]:

gp.plot_3d(geo_model,
           show_surfaces=False,
           show_data=True,
           show_lith=False,
           show_topography=True,
           image=False,
           plotter_type='background',
           ve=1)

# # Display Model Information
# In the following, we will go through model construction step-by-step. As an overview, we display the different units (here called `surfaces`) included in the model. Note that also faults are surfaces within this model context. Currently, they are not marked as faults, and GemPy would treat them as the base of another geological model unit.
#
# To clarify, we model the base of a unit volume. That is, everything above the base surface is the respective unit, until the next base surface is reached.
# In total, our model comprises 17 `surfaces`. Everything beneath is filled with the 18th surface, called `basement`.
#
# ### Surfaces
# The majority of the structural features, i.e. normal- and thrust faults, are named following the names in GeoMol.
# Main features of the model is the asymetric graben system, with the major normal faults (`Fault_Basement_A`, `Fault-south`, `BIH-Basement-N`), and the graben fill, which is not present beyond the graben shoulders, unless where it is inferred. This, as well as the stop of major normal faults beneath the mesozoic units (the base of `Mittlerer-Muschelkalk`) are important considerations for the modeling process.

# In[8]:
コード例 #24
0
gp.compute_model(geo_model, compute_mesh=True)

# %%
# Basic plotting API
# ------------------
#

# %%
# Data plot
# ~~~~~~~~~
#

# %%
gp.plot_3d(geo_model,
           show_surfaces=False,
           show_data=True,
           show_lith=False,
           image=False)

# %%
# Geomodel plot
# ~~~~~~~~~~~~~
#

# %%
gp.plot_3d(geo_model, image=False)

# %%

# sphinx_gallery_thumbnail_number = 2
gpv = gp.plot.plot_3d(geo_model,
コード例 #25
0
ファイル: ch1_3c_topography.py プロジェクト: snowmanman/gempy
# Now, the solutions object does also contain the computed geological map.
# It can be visualized using the 2D and 3D plotting functionality:
#

# %%
gp.plot_2d(geo_model,
           show_topography=True,
           section_names=['topography'],
           show_boundaries=False,
           show_data=True)
plt.show()

# %%
gp.plot_2d(geo_model, show_topography=True, section_names=['s1'])
plt.show()

# %%
g3d = gp.plot_3d(geo_model,
                 show_topography=True,
                 show_lith=False,
                 show_surfaces=False,
                 show_results=False,
                 ve=5)

# %%
# sphinx_gallery_thumbnail_number = 3
g3d = gp.plot_3d(geo_model,
                 show_topography=True,
                 show_lith=True,
                 show_surfaces=True,
                 ve=5)
コード例 #26
0
# %%
geo_model_graben.faults

# %%
geo_model_graben.faults.faults_relations_df

# %%
gp.compute_model(geo_model_graben)

# %%
gp.plot_2d(geo_model_graben, cell_number=[25], show_data=True)

# %%
# sphinx_gallery_thumbnail_number = 5
gp.plot_3d(geo_model_graben, image=True)

# %%
gp.plot_2d(geo_model_graben, cell_number=[25], show_scalar=True, series_n=0)

gp.plot_2d(geo_model_graben, cell_number=[25], show_scalar=True, series_n=1)

# %%
# Offset parameter (Experimental)
# -------------------------------
#

# %%
geo_model_graben._interpolator.theano_graph.offset.set_value(1)
gp.compute_model(geo_model_graben, compute_mesh=False)
コード例 #27
0
ファイル: Claudius.py プロジェクト: snowmanman/gempy
# %% 
gp.plot_2d(geo_model, cell_number=sect, show_data=True, direction='x')

# %% 
gp.plot_2d(geo_model, cell_number=[28], series_n=0, direction='y', show_scalar=True)
gp.plot_2d(geo_model, cell_number=[28], series_n=1, direction='y', show_scalar=True)
gp.plot_2d(geo_model, cell_number=[28], series_n=2, direction='y', show_scalar=True)

# %% 
gp.plot_2d(geo_model, cell_number=[28], show_data=True, direction='y')

# %%

# sphinx_gallery_thumbnail_number = 8
gp.plot_3d(geo_model)



# %%
# Export data:
# ~~~~~~~~~~~~
# 
# The solution is stored in a numpy array of the following shape. Axis 0
# are the scalar fields of each correspondent series/faults in the
# following order (except basement):
# 

# %% 
geo_model.series
コード例 #28
0
# %% md
# Adding orientations
# -------------------

# %%
# find neighbours
neighbours = gp.select_nearest_surfaces_points(geo_model, geo_model._surface_points.df, 2)

# calculate all fault orientations
gp.set_orientation_from_neighbours_all(geo_model, neighbours)

# %% md
# Using the flag to subsurface, the result of the interpolation will get stored in `subsurface` data objects. In the
# future exporting to subsurface will be the default behaviour.

# %%
gp.compute_model(geo_model, to_subsurface=True)

# %%
p3d = gp.plot_3d(geo_model)

# %%
geo_model.solutions.s_regular_grid

# %%
geo_model.solutions.meshes