Ejemplo n.º 1
0
    def test_gmm_plot(self):
        '''
		Test the GMM plotting
		'''
        try:
            gmm_util = gs.GmmUtility(gmm_file=os.path.join(
                os.path.normpath(os.getcwd() + os.sep + os.pardir),
                r'pygeostat\pygeostat\data\example_data\gmm_fit.out'),
                                     data=gs.ExampleData('point2d_mv').data,
                                     variable_names=['Var1', 'Var2', 'Var3'])
        except Exception as ex:
            self.fail('Unable to test GmmUtility \n{}'.format(str(ex)))
        try:
            gmm_util.bivariate_plot(var_index=[1, 2],
                                    cmap='viridis',
                                    title='Bivariate Plot')
        except Exception as ex:
            self.fail('Unable to test bivariate_plot \n{}'.format(str(ex)))
        try:
            gmm_util.summary_plot(pad=0.1)
        except Exception as ex:
            self.fail('Unable to test summary_plot \n{}'.format(str(ex)))
        try:
            gmm_util.univariate_conditional_plot(
                conditioning_data=[0, 0, None])
        except Exception as ex:
            self.fail('Unable to test univariate_conditional_plot \n{}'.format(
                str(ex)))
Ejemplo n.º 2
0
    def test_simple_plot(self):
        '''
		Test the capability of plotting a simple scatter plot to compare estimate vs truth
		'''
        from matplotlib import pyplot as plt

        output_file = os.path.join(self.out_dir, 'validation_plot1.png')
        _, ax = plt.subplots(1, 1)

        try:
            data = gs.ExampleData('3d_estimate')
            _ = gs.validation_plot(data.data['Estimate'],
                                   data.data['True'],
                                   stat_blk='minimal',
                                   output_file=output_file)
            _ = gs.validation_plot(data.data['Estimate'],
                                   data.data['True'],
                                   stat_blk='minimal',
                                   output_file=output_file,
                                   ax=ax)

        except Exception as ex:
            self.fail(
                'Unable to test the validation_plot with simple settings\n{}'.
                format(str(ex)))

        self.assertEqual(os.path.isfile(output_file), True)
Ejemplo n.º 3
0
    def setUp(self):
        super().setUp()
        grid_str = '''120 5.00  10.00 -nx, xmn, xsiz
					110 1205.00  10.00 -ny, ymn, ysiz
					1 0.5 1.0  -nz, zmn, zsiz'''

        griddef = gs.GridDef(grid_str=grid_str)
        self.data = gs.ExampleData("grid2d_surf", griddef=griddef)
Ejemplo n.º 4
0
    def test_simple_plot(self):
        '''
		Test the capability of plotting by passing only the data file
		'''
        data = gs.ExampleData('accuracy_plot')
        reals = data[list(data.columns[1:])].values
        truth = data[list(data.columns)[0]].values
        output_file = os.path.join(self.out_dir, 'accuracy_plot1.png')
        try:
            gs.accuracy_plot(truth=truth, reals=reals, output_file=output_file)
        except Exception as ex:
            self.fail(
                'Unable to test the accuracy plot with simple settings \n{}'.
                format(str(ex)))

        self.assertEqual(os.path.isfile(output_file), True)
Ejemplo n.º 5
0
    def test_simple_plot(self):
        '''
		Test the capability of plotting a CDF with probability scale
		'''

        output_file = os.path.join(self.out_dir, 'probability_plot1.png')

        try:
            data = gs.ExampleData('oilsands')
            _ = gs.probability_plot(data.data['Fines'],
                                    logscale=False,
                                    output_file=output_file)

        except Exception as ex:
            self.fail('Unable to test the probability_plot \n{}'.format(
                str(ex)))

        self.assertEqual(os.path.isfile(output_file), True)
Ejemplo n.º 6
0
    def test_experimental_plot(self):
        '''
		Test the capability of plotting experimental variograms
		'''

        output_file = os.path.join(self.out_dir, 'variogram_plot1.png')

        try:
            dfl = gs.ExampleData('experimental_variogram')
            _ = gs.variogram_plot(dfl,
                                  experimental=True,
                                  figsize=(8, 4),
                                  output_file=output_file)

        except Exception as ex:
            self.fail(
                'Unable to test the variogram_plot for experimental variogram\n{}'
                .format(str(ex)))

        self.assertEqual(os.path.isfile(output_file), True)
Ejemplo n.º 7
0
import pygeostat as gs
dat = gs.ExampleData('point3d_ind_mv')
data = dat.data[dat.data['HoleID'] == 3]
gs.drill_plot(data['Elevation'], data['Lithofacies'])
Ejemplo n.º 8
0
 def test_load_gslib_attributes(self):
     dat = gs.ExampleData('oilsands')
     self.assertEqual(dat.x.lower(), 'east')
     self.assertEqual(dat.y.lower(), 'north')
     self.assertEqual(dat.z.lower(), 'elevation')
Ejemplo n.º 9
0
 def setUp(self):
     warnings.simplefilter('ignore', category=ImportWarning)
     self.grid = gs.GridDef([40, 0.5, 1, 40, 0.5, 1, 40, 0.5, 1])
     self.testfl = gs.ExampleData('3d_grid', griddef=self.grid)
Ejemplo n.º 10
0
    def test_infergriddef(self):
        df2d = gs.ExampleData("point2d_ind")
        df3d = gs.ExampleData("point3d_ind_mv")
        #where xsiz = ysiz = zsiz, a float can also be provided.
        self.compare(df3d.infergriddef(blksize=75),
                     df3d.infergriddef(blksize=[75, 75, 75]))

        #where nx = ny = nz, an int can also be provided.
        self.compare(df3d.infergriddef(nblk=60),
                     df3d.infergriddef(nblk=[60, 60, 60]))

        #for 3D data, infergriddef() must return a 3D grid definition even if zsiz is given as None or 0 or 1.
        self.compare(
            df3d.infergriddef(blksize=[50, 60, 1]),
            gs.GridDef('''20  135.0  50.0 
                                   19  1230.0 60.0 
                                   82  310.5  1.0'''))

        self.compare(df3d.infergriddef(blksize=[50, 60, 1]),
                     df3d.infergriddef(blksize=[50, 60, None]))

        self.compare(df3d.infergriddef(blksize=[50, 60, 1]),
                     df3d.infergriddef(blksize=[50, 60, 0]))

        # nz given as None or 0 or 1 returns a 2D grid that covers the vertical extent of a 3D dataset.
        self.compare(
            df3d.infergriddef(nblk=[50, 60, 1]),
            gs.GridDef('''50  119.8   19.6 
                                   60  1209.1  18.2 
                                   1   350.85  81.7'''))

        self.compare(df3d.infergriddef(nblk=[50, 60, 1]),
                     df3d.infergriddef(nblk=[50, 60, None]))

        self.compare(df3d.infergriddef(nblk=[50, 60, 1]),
                     df3d.infergriddef(nblk=[50, 60, 0]))

        #if nblk is not integer,infergriddef(), must convert it to int and provide correct grid definition
        _nblk = [12.3, 5.7, 10.11]
        self.compare(df3d.infergriddef(nblk=_nblk),
                     df3d.infergriddef(nblk=[int(i) for i in _nblk]))

        # If data is 2-D, zsiz must be provided as None. Otherwise it must raise exception.
        with self.assertRaises(ValueError):
            df2d.infergriddef(blksize=[50, 60, 4])

        with self.assertRaises(ValueError):
            df2d.infergriddef(blksize=75)

        self.compare(
            df2d.infergriddef(blksize=[50, 60, None]),
            gs.GridDef('''24   25.0    50.0  
                                   19   1230.0  60.0 
                                   1    0.5     1.0'''))

        #If data is 2-D, nz must be provided as None. Otherwise it must raise exception.
        with self.assertRaises(ValueError):
            df2d.infergriddef(nblk=[50, 60, 1])

        with self.assertRaises(ValueError):
            df2d.infergriddef(nblk=60)

        self.compare(
            df2d.infergriddef(nblk=[50, 60, None]),
            gs.GridDef('''50   11.9    23.8 
                              60   1209.1  18.2 
                              1    0.5     1.0'''))
Ejemplo n.º 11
0
import pygeostat as gs
data_file = gs.ExampleData('3d_correlation')
loadmat = data_file.data.corr().iloc[3:6,6:9]
gs.loadings_plot(loadmat.values, figsize=(5,5), xticklabels=['PC1', 'PC2', 'PC3'], yticklabels=['InputVariable1', 'InputVariable2', 'InputVariable3'])
Ejemplo n.º 12
0
import pygeostat as gs

varcalcdat = gs.ExampleData('experimental_variogram')
varmodeldat = gs.ExampleData('variogram_model')
ax = gs.variogram_plot(varcalcdat.data, index=1, sill=False)
gs.variogram_plot(varmodeldat.data, index=1, experimental=False, ax=ax)
Ejemplo n.º 13
0
 def setUp(self):
     super().setUp()
     self.data = gs.ExampleData("point3d_ind_mv")
Ejemplo n.º 14
0
 def setUp(self):
     super().setUp()
     self.griddef = gs.GridDef([40, 0.5, 1, 40, 0.5, 1, 40, 0.5, 1])
     self.data = gs.ExampleData('3d_grid', griddef=self.griddef)
Ejemplo n.º 15
0
import pygeostat as gs

#Load the data from output from varcal/varmodel file
varcalcdat = gs.ExampleData('experimental_variogram')
gs.variogram_plot(varcalcdat, index=1)
Ejemplo n.º 16
0
import pygeostat as gs
data = gs.ExampleData('oilsands')
gs.probability_plot(data.data['Fines'], logscale=False)
Ejemplo n.º 17
0
import pygeostat as gs
grid_str = '''120 5.00  10.00 -nx, xmn, xsiz
            110 1205.00  10.00 -ny, ymn, ysiz
            1 0.5 1.0  -nz, zmn, zsiz'''

griddef = gs.GridDef(grid_str=grid_str)

data_fl = gs.ExampleData("grid2d_surf", griddef=griddef)
ax = gs.slice_plot(data_fl, var="Thickness")
_ = gs.contour_plot(data_fl, var="Thickness", ax=ax, clabel=True)
Ejemplo n.º 18
0
import pygeostat as gs
data = gs.ExampleData('3d_estimate')
gs.validation_plot(data.data['Estimate'],
                   data.data['True'],
                   stat_blk='minimal')
Ejemplo n.º 19
0
 def setUp(self):
     super().setUp()
     refdata = gs.ExampleData('3d_correlation')
     self.loadmat = refdata.data.corr().iloc[3:6, 6:9]
Ejemplo n.º 20
0
import pygeostat as gs
# load some data
data = gs.ExampleData('3d_grid',
                      griddef=gs.GridDef([40, 1, 2, 40, 1, 2, 40, 0.5, 1]))
# plot the grid slices
_ = gs.grid_slice_plot(data, orient='xz', n_slice=5)
Ejemplo n.º 21
0
import pygeostat as gs
griddef = gs.GridDef([40, 0.5, 1, 40, 0.5, 1, 40, 0.5, 1])
data_file = gs.ExampleData('3d_grid', griddef)
gs.slice_plot(data_file, orient='xy', cmap='viridis', slice_thickness=20)
Ejemplo n.º 22
0
 def setUp(self):
     super().setUp()
     dfl = gs.ExampleData("point3d_ind_mv")
     data = dfl[dfl.variables]
     self.data_cor = data.corr()
Ejemplo n.º 23
0
import pygeostat as gs
import numpy as np

# Load the data, which registers the variables attribute
data_file1 = gs.ExampleData('point3d_ind_mv')
data_file2 = gs.ExampleData('point3d_ind_mv')
mask = np.random.rand(len(data_file2))<0.3
data_file2.data = data_file2.data[mask]

# Plot with the standard orientation
fig = gs.scatter_plots_lu(data_file1, data_file2, titles=('Data', 'Realization'), s=10, nmax=1000,
                     stat_xy=(0.95, 0.95), pad=(-1, -1), figsize=(10, 10))

# Plot with aligned orientation to ease comparison
fig = gs.scatter_plots_lu(data_file1, data_file2, titles=('Data', 'Realization'), s=10, nmax=1000,
                     stat_xy=(0.95, 0.95), pad=(-1, -1), figsize=(10, 10), cmap='jet',
                     align_orient=True)
Ejemplo n.º 24
0
import pygeostat as gs

# Load the data, which registers the variables attribute
data_file = gs.ExampleData('point3d_ind_mv')

# Plot with the default KDE coloring
fig = gs.scatter_plots(data_file,
                       nmax=1000,
                       stat_xy=(0.95, 0.95),
                       pad=(-1, -1),
                       s=10,
                       figsize=(10, 10))
Ejemplo n.º 25
0
import pygeostat as gs
# load some data
dfl = gs.ExampleData("point3d_ind_mv")
cats = [1, 2, 3, 4, 5]
colors = gs.catcmapfromcontinuous("Spectral", 5).colors
# build the required cat dictionaries
dfl.catdict = {c: "RT {:02d}".format(c) for c in cats}
colordict = {c: colors[i] for i, c in enumerate(cats)}
# plot the histogram_plot
ax = gs.histogram_plot(dfl,
                       cat=True,
                       color=colordict,
                       figsize=(7, 4),
                       rotateticks=(45, 0),
                       label_count=True)
Ejemplo n.º 26
0
 def setUp(self):
     super().setUp()
     dat = gs.ExampleData('point3d_ind_mv')
     self.data = dat.data[dat.data['HoleID'] == 3]
Ejemplo n.º 27
0
import pygeostat as gs
data_file = gs.ExampleData('accuracy_plot')
reals = data_file[list(data_file.columns[1:])].values
truth = data_file[list(data_file.columns)[0]].values
gs.accuracy_plot(truth=truth, reals=reals)
Ejemplo n.º 28
0
import pygeostat as gs

data_file = gs.ExampleData("point3d_ind_mv")
data = data_file[data_file.variables]
data_cor = data.corr()
gs.correlation_matrix_plot(data_cor.values, cmap='bwr')
Ejemplo n.º 29
0
import pygeostat as gs

varmodeldat = gs.ExampleData('variogram_model')
gs.variogram_plot(varmodeldat, index=1, experimental=False)