예제 #1
0
    def test_c(self, interpolator_islith_nofault):
        """
        Two layers a bit curvy, drift degree 0
        """

        # 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_c/test_c_Foliations.csv",
                                     path_i=input_path+"/GeoModeller/test_c/test_c_Points.csv")

        geo_data.set_theano_function(interpolator_islith_nofault)


        # Compute model
        sol = gempy.compute_model(geo_data)

        gempy.plot.plot_section(geo_data, 25, direction='y', show_data=True)
        plt.savefig(os.path.dirname(__file__)+'/../figs/test_c.png', dpi=200)

        if update_sol:
            np.save(input_path + '/test_c_sol.npy', sol.lith_block[test_values])

        # Load model
        real_sol = np.load(input_path + '/test_c_sol.npy')

        # Checking that the plots do not rise errors
        gempy.plot.plot_section(geo_data, 25, direction='y', show_data=True)
        gempy.plot.plot_scalar_field(geo_data, 25)

        # 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)
예제 #2
0
    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)
예제 #3
0
    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
예제 #4
0
    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)
예제 #5
0
def test_set_orientation_from_neighbours_all():
    data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
    path_to_data = data_path + "/data/input_data/jan_models/"

    geo_data = gp.create_data('fault',
                              extent=[0, 1000, 0, 1000, 0, 1000],
                              resolution=[50, 50, 50],
                              path_o=path_to_data + "model5_orientations.csv",
                              path_i=path_to_data +
                              "model5_surface_points.csv")

    # count orientations before orientation calculation
    length_pre = geo_data._orientations.df.shape[0]

    # find neighbours
    neighbours = gp.select_nearest_surfaces_points(geo_data,
                                                   geo_data._surface_points.df,
                                                   2)
    # calculate all fault orientations
    gp.set_orientation_from_neighbours_all(geo_data, neighbours)

    # count orientations after orientation calculation
    length_after = geo_data._orientations.df.shape[0]

    assert np.array_equal(geo_data._surface_points.df.shape[0],
                          length_after - length_pre)
예제 #6
0
    def test_b(self, theano_f):
        """
        Two layers a bit curvy, drift degree 1
        """

        # 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_b/test_b_Foliations.csv",
                                     path_i=input_path+"/GeoModeller/test_b/test_b_Points.csv")

        interp_data = theano_f

        # Updating the interp data which has theano compiled
        interp_data.update_interpolator(geo_data, u_grade=[1])

        gempy.get_kriging_parameters(interp_data, verbose=1)
        # Compute model
        sol = gempy.compute_model(interp_data)

        gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True)
        plt.savefig(os.path.dirname(__file__)+'/figs/test_b.png', dpi=200)

        if False:
            np.save(input_path + '/test_b_sol.npy', sol)

        # Load model
        real_sol = np.load(input_path + '/test_b_sol.npy')

        # Checking that the plots do not rise errors
        gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True)
        gempy.plot_scalar_field(geo_data, sol[0][1, :], 25)

        # 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)
예제 #7
0
    def test_a(self, theano_f):
        """
        2 Horizontal layers with drift 0
        """
        # 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_a/test_a_Foliations.csv",
                                     path_i=os.path.dirname(__file__)+"/GeoModeller/test_a/test_a_Points.csv")

        interp_data = theano_f

        # Updating the interp data which has theano compiled

        interp_data.update_interpolator(geo_data)

        # Compute model
        sol = gempy.compute_model(interp_data, u_grade=[1])

        if False:
            np.save(os.path.dirname(__file__)+'/test_a_sol.npy', sol)

        # Load model
        real_sol = np.load(os.path.dirname(__file__)+'/test_a_sol.npy')

        # We only compare the block because the absolute pot field I changed it
        np.testing.assert_array_almost_equal(sol[0][0, :], real_sol[0][0, :], decimal=3)

        # Checking that the plots do not rise errors
        gempy.plot_section(geo_data, sol[0][0, :], 25, direction='y', plot_data=True)
        plt.savefig(os.path.dirname(__file__)+'/figs/test_a.png', dpi=100)

        gempy.plot_scalar_field(geo_data, sol[0][1, :], 25)
예제 #8
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)
예제 #9
0
def test_custom_grid_solution(interpolator_islith_nofault):
    """
    Integration test for a gempy model using a custom grid

    2 Horizontal layers with drift 0

    :param interpolator_islith_nofault:
    :return:
    """
    # Importing the data from csv files and settign extent and resolution
    geo_model = gempy.create_data([0, 10, 0, 10, -10, 0], [10, 10, 10],
                                 path_o=input_path + "/GeoModeller/test_a/test_a_Foliations.csv",
                                 path_i=input_path + "/GeoModeller/test_a/test_a_Points.csv")
    # add a custom grid
    cg = np.array([[5, 5, -9],
                   [5, 5, -5],
                   [5, 5, -5.1],
                   [5, 5, -5.2],
                   [5, 5, -1]])
    values = geo_model.set_custom_grid(cg)
    assert geo_model.grid.active_grids[1]
    # set the theano function
    geo_model.set_theano_function(interpolator_islith_nofault)
    # Compute model
    sol = gempy.compute_model(geo_model, compute_mesh=False)
    assert sol.custom.shape == (2,1,5)
예제 #10
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])
예제 #11
0
    def test_compute_model_multiple_ranges(self, interpolator):

        # Importing the data from csv files and settign extent and resolution
        geo_data = gempy.create_data(
            extent=[0, 2000, 0, 2000, -2000, 0],
            resolution=[50, 50, 50],
            path_o=input_path + "/GeoModeller/test_f/test_f_Foliations.csv",
            path_i=input_path + "/GeoModeller/test_f/test_f_Points.csv")

        gempy.map_stack_to_surfaces(
            geo_data,
            {
                'fault1':
                'MainFault',
                'series': ('Reservoir', 'Seal', 'SecondaryReservoir',
                           'NonReservoirDeep'),
            },
        )

        geo_data.set_theano_function(interpolator)
        geo_data.set_is_fault('fault1')
        geo_data.modify_kriging_parameters('range', [3000, 3500, 0])
        geo_data._additional_data.kriging_data.set_default_c_o()
        # Compute model
        sol = gempy.compute_model(geo_data, sort_surfaces=True)
        gempy.plot.plot_2d(geo_data,
                           cell_number=25,
                           direction='y',
                           show_data=True)
        plt.show()
예제 #12
0
파일: conftest.py 프로젝트: chinasio/gempy
def theano_f():
    # 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")

    interp_data = gempy.InterpolatorData(geo_data, dtype='float64', compile_theano=True,
                                         verbose=[])
    return interp_data
예제 #13
0
    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
예제 #14
0
파일: test_ch2.py 프로젝트: yagueits/gempy
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)
예제 #15
0
    def theano_f(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_a/test_a_Foliations.csv",
                                     path_i=os.path.dirname(__file__)+"/GeoModeller/test_a/test_a_Points.csv")

        interp_data = gempy.InterpolatorData(geo_data, dtype='float64', u_grade=[1], compile_theano=True,
                                             verbose=['cov_gradients', 'cov_interfaces',
                                                      'solve_kriging', 'sed_dips_dips', 'slices'])

        return interp_data
예제 #16
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)
예제 #17
0
def test_find_interfaces():
    block = np.load(input_path+'/noddy_block.npy')
    bool_block = im.find_interfaces_from_block(block, 1)

    geo_data = gp.create_data(extent=[0, 6000,
                               0, 6000,
                               0, 500], resolution=[60, 60 ,6])

    p_df = im.interfaces_from_interfaces_block(bool_block, geo_data._grid.values)

    im.set_interfaces_from_block(geo_data, block)
예제 #18
0
파일: conftest.py 프로젝트: chinasio/gempy
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
예제 #19
0
def theano_f():
    # 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")

    interp_data = gempy.InterpolatorData(geo_data,
                                         dtype='float64',
                                         compile_theano=True,
                                         verbose=[])
    return interp_data
예제 #20
0
    def test_set_section_twice(self):
        geo_data = gp.create_data(extent=[0, 1000, 0, 1000, 0, 1000],
                                  resolution=[10, 10, 10])
        section_dict = {
            'section1': ([0, 0], [1000, 1000], [100, 80]),
            'section2': ([800, 0], [800, 1000], [150, 100]),
            'section3': ([50, 200], [100, 500], [200, 150])
        }

        geo_data.set_section_grid(section_dict)
        geo_data.set_section_grid(section_dict)
        print(geo_data._grid.sections)
예제 #21
0
def create_gempy_model(resolution=[20, 20, 20], type=2):
    if type == 1:
        data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
        path_to_data = data_path + "/data/input_data/jan_models/"
        geo_data = gp.create_data(
            'fold',
            extent=[0, 1000, 0, 1000, 0, 1000],
            resolution=resolution,
            path_o=path_to_data + "model2_orientations.csv",
            path_i=path_to_data + "model2_surface_points.csv")
        gp.map_stack_to_surfaces(geo_data, {
            "Strat_Series": ('rock2', 'rock1'),
            "Basement_Series": ('basement')
        })

        interp_data = gp.set_interpolator(geo_data,
                                          theano_optimizer='fast_compile')

        sol = gp.compute_model(geo_data)
    elif type == 2:
        data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
        path_to_data = data_path + "/data/input_data/jan_models/"

        geo_data = gp.create_data(
            'unconformity',
            extent=[0, 1000, 0, 1000, 0, 1000],
            resolution=[50, 50, 50],
            path_o=path_to_data + "model6_orientations.csv",
            path_i=path_to_data + "model6_surface_points.csv")
        gp.map_stack_to_surfaces(
            geo_data, {
                "Strat_Series1": ('rock3'),
                "Strat_Series2": ('rock2', 'rock1'),
                "Basement_Series": ('basement')
            })
        interp_data = gp.set_interpolator(geo_data,
                                          theano_optimizer='fast_compile')
        sol = gp.compute_model(geo_data)

    return geo_data
예제 #22
0
def one_fault_model_no_interp():
    """This only makes sense for running small test fast"""
    model = gp.create_data('one_fault_model', [0, 2000, 0, 2000, 0, 2000], [50, 50, 50],
                           path_o=input_path2 + 'tut_chapter1/simple_fault_model_orientations.csv',
                           path_i=input_path2 + 'tut_chapter1/simple_fault_model_points.csv')

    # Assigning series to surface as well as their order (timewise)
    gp.map_stack_to_surfaces(model, {"Fault_Series": 'Main_Fault',
                                      "Strat_Series": ('Sandstone_2', 'Siltstone',
                                                       'Shale', 'Sandstone_1')},
                             )
    model.set_is_fault(['Fault_Series'])
    return model
예제 #23
0
    def geo_model(self, interpolator_islith_nofault):
        """
        2 Horizontal layers with drift 0
        """
        # 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")

        geo_data.set_theano_function(interpolator_islith_nofault)

        # Compute model
        sol = gempy.compute_model(geo_data, compute_mesh_options={'rescale': True})

        return geo_data
예제 #24
0
파일: test_grid.py 프로젝트: sslob/gempy
    def test_section_grid(self):
        geo_data = gp.create_data([0, 1000, 0, 1000, 0, 1000],
                                  resolution=[10, 10, 10])
        geo_data.set_topography()
        section_dict = {
            'section1': ([0, 0], [1000, 1000], [100, 80]),
            'section2': ([800, 0], [800, 1000], [150, 100]),
            'section3': ([50, 200], [100, 500], [200, 150])
        }

        geo_data.set_section_grid(section_dict)

        print(geo_data.grid.sections)
        np.testing.assert_almost_equal(
            geo_data.grid.sections.df.loc['section3', 'dist'],
            304.138127,
            decimal=4)
예제 #25
0
def test_rescaled_marching_cube(interpolator):
    """
    2 Horizontal layers with drift 0
    """
    # Importing the data from csv files and setting extent and resolution
    geo_data = gempy.create_data(
        'Simple interpolator', [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")

    geo_data.set_theano_function(interpolator)

    # Compute model
    sol = gempy.compute_model(geo_data, compute_mesh_options={'rescale': True})
    print(sol.vertices)

    return geo_data
예제 #26
0
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)
예제 #27
0
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"]
예제 #28
0
def unconformity_model(interpolator):
    geo_model = gp.create_data(
        'unconformity_model', [0, 1000, 0, 1000, 0, 1000],
        resolution=[50, 42, 33],
        path_o=input_path2 + "jan_models/model6_orientations.csv",
        path_i=input_path2 + "jan_models/model6_surface_points.csv")
    gp.map_stack_to_surfaces(
        geo_model, {
            "Strat_Series1": ('rock3'),
            "Strat_Series2": ('rock2', 'rock1'),
            "Basement_Series": ('basement')
        })

    # with open("input_data/geomodel_jan_sol.p", "rb") as f:
    # geo_model.solutions = load(f)
    geo_model.set_theano_function(interpolator)
    gp.compute_model(geo_model)
    return geo_model
예제 #29
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)
예제 #30
0
    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
예제 #31
0
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
예제 #32
0
파일: test_core.py 프로젝트: chinasio/gempy
    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)
예제 #33
0
def topology_jan_unconf():
    geo_model = gp.create_data(
        [0, 1000, 0, 1000, 0, 1000],
        resolution=[50, 50, 50],
        path_o=data_path / "jan_models/model6_orientations.csv",
        path_i=data_path / "jan_models/model6_surface_points.csv")

    gp.map_series_to_surfaces(
        geo_model, {
            "Strat_Series1": ('rock3'),
            "Strat_Series2": ('rock2', 'rock1'),
            "Basement_Series": ('basement')
        })

    # with open("input_data/geomodel_jan_sol.p", "rb") as f:
    # geo_model.solutions = load(f)
    gp.set_interpolator(geo_model)
    gp.compute_model(geo_model)

    edges, centroids = tp.compute_topology(geo_model, voxel_threshold=1)
    return edges, centroids
예제 #34
0
파일: test_ch6.py 프로젝트: chinasio/gempy
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"]
예제 #35
0
파일: test_ch1.py 프로젝트: chinasio/gempy
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)
예제 #36
0
import importlib

from operator import itemgetter

from mpl_toolkits.mplot3d import Axes3D

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
예제 #37
0
파일: test_ch3.py 프로젝트: chinasio/gempy
def test_ch3_a(theano_f):

    # set cube size and model extent
    cs = 50
    extent = (3000, 200, 2000)  # (x, y, z)
    res = (120, 4, 80)


    # initialize geo_data object
    geo_data = gp.create_data([0, extent[0],
                               0, extent[1],
                               0, extent[2]],
                              resolution=[res[0],  # number of voxels
                                          res[1],
                                          res[2]])

    geo_data.set_interfaces(pn.read_csv(input_path+"/input_data/tut_chapter3/tutorial_ch3_interfaces",
                                        index_col="Unnamed: 0"), append=True)
    geo_data.set_orientations(pn.read_csv(input_path+"/input_data/tut_chapter3/tutorial_ch3_foliations",
                                        index_col="Unnamed: 0"))

    # let's have a look at the upper five interface data entries in the dataframe
    gp.get_data(geo_data, 'interfaces', verbosity=1).head()

    # Original pile
    gp.get_sequential_pile(geo_data)

    # Ordered pile
    gp.set_order_formations(geo_data, ['Layer 2', 'Layer 3', 'Layer 4','Layer 5'])
    gp.get_sequential_pile(geo_data)

    # and at all of the foliation data
    gp.get_data(geo_data, 'orientations', verbosity=0)

    gp.plot_data(geo_data, direction="y")
    plt.xlim(0,3000)
    plt.ylim(0,2000);

    gp.data_to_pickle(geo_data, os.path.dirname(__file__)+"/ch3-pymc2_tutorial_geo_data")

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

    # Afterwards we can compute the geological model
    lith_block, fault_block = gp.compute_model(interp_data)


    # And plot a section:
    gp.plot_section(geo_data, lith_block[0], 2, plot_data = True)

    import pymc

    # Checkpoint in case you did not execute the cells above
    geo_data = gp.read_pickle(os.path.dirname(__file__)+"/ch3-pymc2_tutorial_geo_data.pickle")

    gp.get_data(geo_data, 'orientations', verbosity=1).head()

    # So let's assume the vertical location of our layer interfaces is uncertain, and we want to represent this
    #  uncertainty by using a normal distribution. To define a normal distribution, we need a mean and a measure
    #  of deviation (e.g. standard deviation). For convenience the input data is already grouped by a "group_id" value,
    # which allows us to collectively modify data that belongs together. In this example we want to treat the vertical
    # position of each layer interface, on each side of the anticline, as uncertain. Therefore, we want to perturbate
    # the respective three points on each side of the anticline collectively.

    # These are our unique group id's, the number representing the layer, and a/b the side of the anticline.

    group_ids = geo_data.interfaces["group_id"].dropna().unique()
    print(group_ids)


    # As a reminder, GemPy stores data in two main objects, an InputData object (called geo_data in the tutorials) and
    # a InpterpolatorInput object (interp_data) in tutorials. geo_data contains the original data while interp_data the
    # data prepared (and compiled) to compute the 3D model.
    #
    # Since we do not want to compile our code at every new stochastic realization, from here on we will need to work
    # with thte interp_data. And remember that to improve float32 to stability we need to work with rescaled data
    # (between 0 and 1). Therefore all the stochastic data needs to be rescaled accordingly. The object interp_data
    #  contains a property with the rescale factor (see below. As default depends on the model extent), or it is
    # possible to add the stochastic data to the pandas dataframe of the geo_data---when the InterpolatorInput object
    # is created the rescaling happens under the hood.

    interface_Z_modifier = []

    # We rescale the standard deviation
    std = 20./interp_data.rescaling_factor

    # loop over the unique group id's and create a pymc.Normal distribution for each
    for gID in group_ids:
        stoch = pymc.Normal(gID+'_stoch', 0, 1./std**2)
        interface_Z_modifier.append(stoch)

    # Let's have a look at one:


    # sample from a distribtion
    samples = [interface_Z_modifier[3].rand() for i in range(10000)]
    # plot histogram
    plt.hist(samples, bins=24, normed=True);
    plt.xlabel("Z modifier")
    plt.vlines(0, 0, 0.01)
    plt.ylabel("n");


    #  Now we need to somehow sample from these distribution and put them into GemPy

    # ## Input data handling
    #
    # First we need to write a function which modifies the input data for each iteration of the stochastic simulation.
    #  As this process is highly dependant on the simulation (e.g. what input parameters you want modified in which way),
    #  this process generally can't be automated.
    #
    # The idea is to change the column Z (in this case) of the rescaled dataframes in our interp_data object (which can
    #  be found in interp_data.geo_data_res). First we simply create the pandas Dataframes we are interested on:


    import copy
    # First we extract from our original intep_data object the numerical data that is necessary for the interpolation.
    # geo_data_stoch is a pandas Dataframe

    # This is the inital model so it has to be outside the stochastic frame
    geo_data_stoch_init = copy.deepcopy(interp_data.geo_data_res)

    gp.get_data(geo_data_stoch_init, numeric=True).head()

    @pymc.deterministic(trace=True)
    def input_data(value = 0,
                   interface_Z_modifier = interface_Z_modifier,
                   geo_data_stoch_init = geo_data_stoch_init,
                   verbose=0):
        # First we extract from our original intep_data object the numerical data that is necessary for the interpolation.
        # geo_data_stoch is a pandas Dataframe

        geo_data_stoch = gp.get_data(geo_data_stoch_init, numeric=True)
        # Now we loop each id which share the same uncertainty variable. In this case, each layer.
        for e, gID in enumerate(group_ids):
            # First we obtain a boolean array with trues where the id coincide
            sel = gp.get_data(interp_data.geo_data_res, verbosity=2)['group_id'] == gID

            # We add to the original Z value (its mean) the stochastic bit in the correspondant groups id
            geo_data_stoch.loc[sel, 'Z']  += np.array(interface_Z_modifier[e])

        if verbose > 0:
            print(geo_data_stoch)

        # then return the input data to be input into the modeling function. Due to the way pymc2 stores the traces
        # We need to save the data as numpy arrays
        return [geo_data_stoch.xs('interfaces')[["X", "Y", "Z"]].values, geo_data_stoch.xs('orientations').values]


    # ## Modeling function

    @pymc.deterministic(trace=False)
    def gempy_model(value=0,
                    input_data=input_data, verbose=True):

        # modify input data values accordingly
        interp_data.geo_data_res.interfaces[["X", "Y", "Z"]] = input_data[0]

        # Gx, Gy, Gz are just used for visualization. The theano function gets azimuth dip and polarity!!!
        interp_data.geo_data_res.orientations[["G_x", "G_y", "G_z", "X", "Y", "Z",  'dip', 'azimuth', 'polarity']] = input_data[1]

        try:
            # try to compute model
            lb, fb = gp.compute_model(interp_data)
            if True:
                gp.plot_section(interp_data.geo_data_res, lb[0], 0, plot_data=True)

            return lb, fb

        except np.linalg.linalg.LinAlgError as err:
            # if it fails (e.g. some input data combinations could lead to
            # a singular matrix and thus break the chain) return an empty model
            # with same dimensions (just zeros)
            if verbose:
                print("Exception occured.")
            return np.zeros_like(lith_block), np.zeros_like(fault_block)

    # We then create a pymc model with the two deterministic functions (*input_data* and *gempy_model*), as well as all
    #  the prior parameter distributions stored in the list *interface_Z_modifier*:

    params = [input_data, gempy_model, *interface_Z_modifier]
    model = pymc.Model(params)

    # Then we set the number of iterations:

    # Then we create an MCMC chain (in pymc an MCMC chain without a likelihood function is essentially a Monte Carlo
    # forward simulation) and specify an hdf5 database to store the results in

    RUN = pymc.MCMC(model, db="hdf5", dbname=os.path.dirname(__file__)+"/ch3-pymc2.hdf5")

    # and we are finally able to run the simulation:

    RUN.sample(iter=100, verbose=0)
예제 #38
0
파일: test_ch5.py 프로젝트: chinasio/gempy
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()