Ejemplo n.º 1
0
    def update_surfaces_real_time(self, interp_data):

        lith_block, fault_block = gp.compute_model(interp_data)
        try:
            v_l, s_l = gp.get_surfaces(interp_data, lith_block[1], fault_block[1], original_scale=False)
        except IndexError:
            v_l, s_l = gp.get_surfaces(interp_data, lith_block[1], None, original_scale=False)
        return v_l, s_l
Ejemplo n.º 2
0
def export_to_vtk(geo_data, path=None, name=None, voxels=True, block=None, surfaces=True):
    """
      Export data to a vtk file for posterior visualizations

      Args:
          geo_data(:class:`Model`)
          path(str): path to the location of the vtk
          name(str): Name of the files. Default name: Default
          voxels(bool): if True export lith_block
          block(Optional[np.array]): One of the solutions of the regular grid. This can be used if for
           example you want to export an scalar field or an specific series block. If None is passed, lith_block
           will be exported.
          surfaces(bool): If True, export the polydata surfaces.

      Returns:
          None
      """

    if voxels is True:
        GemPyvtkInteract.export_vtk_lith_block(geo_data, lith_block=block,
                                               path=path)
    if surfaces is True:
        geo_data.solutions.compute_all_surfaces()
        ver, sim = _gempy.get_surfaces(geo_data)
        GemPyvtkInteract.export_vtk_surfaces(geo_data, ver, sim, path=path,
                                             name=name)
    return True
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
def test_ch3_b(theano_f):

    geo_data = gp.read_pickle(os.path.dirname(__file__)+"/ch3-pymc2_tutorial_geo_data.pickle")

    # Check the stratigraphic pile for correctness:


    gp.get_sequential_pile(geo_data)


    # Then we can then compile the GemPy modeling function:


    #interp_data = gp.InterpolatorData(geo_data, u_grade=[1])
    interp_data = theano_f
    interp_data.update_interpolator(geo_data)

    # Now we can reproduce the original model:



    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(geo_data, lith_block[0], 0)


    # But of course we want to look at the perturbation results. We have a class for that:

    import gempy.posterior_analysis

    dbname = os.path.dirname(__file__)+"/ch3-pymc2.hdf5"
    post = gempy.posterior_analysis.Posterior(dbname)



    post.change_input_data(interp_data, 80)


    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(interp_data.geo_data_res, lith_block[0], 2, plot_data=True)



    post.change_input_data(interp_data, 15)
    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(interp_data.geo_data_res, lith_block[0], 2, plot_data=True)

    post.change_input_data(interp_data, 95)
    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(geo_data, lith_block[0], 2)

    ver, sim = gp.get_surfaces(interp_data, lith_block[1], None, original_scale= True)
Ejemplo n.º 6
0
def test_ch3_b(theano_f):

    geo_data = gp.read_pickle(
        os.path.dirname(__file__) + "/ch3-pymc2_tutorial_geo_data.pickle")

    # Check the stratigraphic pile for correctness:

    gp.get_sequential_pile(geo_data)

    # Then we can then compile the GemPy modeling function:

    #interp_data = gp.InterpolatorData(geo_data, u_grade=[1])
    interp_data = theano_f
    interp_data.update_interpolator(geo_data)

    # Now we can reproduce the original model:

    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(geo_data, lith_block[0], 0)

    # But of course we want to look at the perturbation results. We have a class for that:

    import gempy.posterior_analysis

    dbname = os.path.dirname(__file__) + "/ch3-pymc2.hdf5"
    post = gempy.posterior_analysis.Posterior(dbname)

    post.change_input_data(interp_data, 80)

    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(interp_data.geo_data_res, lith_block[0], 2, plot_data=True)

    post.change_input_data(interp_data, 15)
    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(interp_data.geo_data_res, lith_block[0], 2, plot_data=True)

    post.change_input_data(interp_data, 95)
    lith_block, fault_block = gp.compute_model(interp_data)
    gp.plot_section(geo_data, lith_block[0], 2)

    ver, sim = gp.get_surfaces(interp_data,
                               lith_block[1],
                               None,
                               original_scale=True)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
def export_to_vtk(geo_data, path=None, name=None, voxels=True, surfaces=True):
    """
      Export data to a vtk file for posterior visualizations

      Args:
          geo_data(gempy.InputData): All values of a DataManagement object
          block(numpy.array): 3D array containing the lithology block
          path (str): path to the location of the vtk

      Returns:
          None
      """

    _gempy.warnings.warn("gempy plot functionality will be moved in version 1.2, "
                  "use gempy.plot module instead", FutureWarning)
    if voxels is True:
        GemPyvtkInteract.export_vtk_lith_block(geo_data, geo_data.solutions.lith_block, path=path)
    if surfaces is True:
        geo_data.solutions.compute_all_surfaces()
        ver, sim = _gempy.get_surfaces(geo_data)
        GemPyvtkInteract.export_vtk_surfaces(ver, sim, path=path, name=name)
Ejemplo n.º 10
0
def loop2gempy_(test_data_name, tmp_path, vtk_path, orientations_file, contacts_file, groups_file, dtm_reproj_file,
                bbox, model_base, model_top, vtk):
    import gempy as gp
    from gempy import plot
    geo_model = gp.create_model(test_data_name)

    # If depth coordinates are much smaller than XY the whole system of equations becomes very unstable. Until
    # I fix it properly in gempy this is a handcrafted hack
    ve = (bbox[0] - bbox[2]) / (model_base - model_top)

    if ve < 3:
        ve = 0
    else:
        print('The vertical exageration is: ', ve)

    gp.init_data(geo_model, extent=[bbox[0], bbox[2], bbox[1], bbox[3], model_base*ve, model_top*ve],
        resolution = (50,50,50),
          path_o = orientations_file,
          path_i = contacts_file, default_values=True);

    # Show example lithological points
    #gp.get_data(geo_model, 'surface_points').head()

    # Show example orientations
    #gp.get_data(geo_model, 'orientations').head()

    # Plot some of this data
    #gp.plot.plot_data(geo_model, direction='z')

    geo_model.modify_surface_points(geo_model.surface_points.df.index, Z=geo_model.surface_points.df['Z']*ve)

    # Load reprojected topgraphy to model

    fp = dtm_reproj_file
    geo_model.set_topography(source='gdal',filepath=fp)

    contents=np.genfromtxt(groups_file,delimiter=',',dtype='U100')
    ngroups=len(contents)

    faults = gp.Faults()
    series = gp.Series(faults)
    #series.df

    #display(ngroups,contents)
    groups = []

    for i in range (0,ngroups):
        groups.append(contents[i].replace("\n",""))
        series.add_series(contents[i].replace("\n",""))
        print(contents[i].replace("\n",""))

    series.delete_series('Default series')

    #series

    # Load surfaces and assign to series
    surfaces = gp.Surfaces(series)

    print(ngroups,groups)
    for i in range(0,ngroups):
        contents=np.genfromtxt(tmp_path+groups[i]+'.csv',delimiter=',',dtype='U100')
        nformations=len(contents.shape)

        if(nformations==1):
            for j in range (1,len(contents)):
                surfaces.add_surface(str(contents[j]).replace("\n",""))
                d={groups[i]:str(contents[j]).replace("\n","")}
                surfaces.map_series({groups[i]:(str(contents[j]).replace("\n",""))}) #working but no gps
        else:
            for j in range (1,len(contents[0])):
                surfaces.add_surface(str(contents[0][j]).replace("\n",""))
                d={groups[i]:str(contents[0][j]).replace("\n","")}
                surfaces.map_series({groups[i]:(str(contents[0][j]).replace("\n",""))}) #working but no gps

    # Set Interpolation Data
    id_only_one_bool = geo_model.surface_points.df['id'].value_counts() == 1
    id_only_one = id_only_one_bool.index[id_only_one_bool]
    single_vals = geo_model.surface_points.df[geo_model.surface_points.df['id'].isin(id_only_one)]
    for idx, vals in single_vals.iterrows():
        geo_model.add_surface_points(vals['X'], vals['Y'], vals['Z'], vals['surface'])

    geo_model.update_structure()

    gp.set_interpolation_data(geo_model,
                              compile_theano=True,
                              theano_optimizer='fast_compile',
                              verbose=[])

    # Provide summary data on model

    #geo_model.additional_data.structure_data

    #Calculate Model
    gp.compute_model(geo_model)

    # Extract surfaces to visualize in 3D renderers
    #gp.plot.plot_section(geo_model, 49, direction='z', show_data=False)

    ver, sim = gp.get_surfaces(geo_model)

    # import winsound
    # duration = 700  # milliseconds
    # freq = 1100  # Hz
    # winsound.Beep(freq, duration)
    # winsound.Beep(freq, duration)
    # winsound.Beep(freq, duration)

    #Visualise Model
    gp.plot.plot_3D(geo_model, render_data=False)

    #Save model as vtk
    if(vtk):
        gp.plot.export_to_vtk(geo_model, path=vtk_path, name=test_data_name+'.vtk', voxels=False, block=None, surfaces=True)

    return geo_model
Ejemplo n.º 11
0
 def test_get_surfaces(self, load_model):
     model = load_model
     print(model.solutions)
     print(model.solutions.compute_all_surfaces())
     print(gp.get_surfaces(model))
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
gp.plot_section(geo_data, lith_block[0], 25, direction='y')


# In[ ]:


gp.plot_section(geo_data, lith_block[0], 25, direction='x')


# ### 3.4.2 - Pseudo-3D surfaces

# In[ ]:


v_l, s_l = gp.get_surfaces(interp_data, potential_lith=lith_block[1], step_size=2)


# In[ ]:


fig = plt.figure(figsize=(13,10))
ax = fig.add_subplot(111, projection='3d')

cs = ["blue", "red", "orange"]



for i in range(3):
    surf = ax.plot_trisurf(v_l[i][:,0], v_l[i][:,1], v_l[i][:,2], 
                           color=cs[i], linewidth=0, alpha=0.75, shade=False)
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
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()
Ejemplo n.º 17
0
plt.show()

# %%
# Marching cubes and vtk visualization
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# In addition to 2D sections we can extract surfaces to visualize in 3D
# renderers. Surfaces can be visualized as 3D triangle complexes in VTK
# (see function plot\_surfaces\_3D below). To create these triangles, we
# need to extract respective vertices and simplices from the potential
# fields of lithologies and faults. This process is automatized in GemPy
# with the function ``get_surface``\ .
#

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

# %%
# Using the rescaled interpolation data, we can also run our 3D VTK
# visualization in an interactive mode which allows us to alter and update
# our model in real time. Similarly to the interactive 3D visualization of
# our input data, the changes are permanently saved (in the
# ``InterpolationInput.dataframe`` object). Additionally, the resulting changes
# in the geological models are re-computed in real time.
#

# %%
# Adding topography
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
geo_model.set_topography(d_z=(350, 750))
Ejemplo n.º 18
0
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()