How to use the gstools.transform.discrete function in gstools

To help you get started, we’ve selected a few gstools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoStat-Framework / GSTools / tests / test_srf.py View on Github external
srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uquad(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uniform(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.binary(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.boxcox(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = np.linspace(np.min(srf.field), np.max(srf.field), 3)
        tf.discrete(srf, values)

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        thresholds = [-0.9, 0.1]
        tf.discrete(srf, values, thresholds)
        np.testing.assert_array_equal(np.unique(srf.field), [-1, 0, 1])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        tf.discrete(srf, values, thresholds="arithmetic")
        np.testing.assert_array_equal(np.unique(srf.field), [-1.0, 0.0, 1.0])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 0.5, 1]
        tf.discrete(srf, values, thresholds="equal")
        np.testing.assert_array_equal(np.unique(srf.field), values)
github GeoStat-Framework / GSTools / tests / test_srf.py View on Github external
tf.zinnharvey(srf)  # make high values mostly connected
        tf.normal_force_moments(srf)  # force ergodicity of the given field
        tf.normal_to_lognormal(srf)  # log-normal
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_arcsin(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uquad(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uniform(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.binary(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.boxcox(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = np.linspace(np.min(srf.field), np.max(srf.field), 3)
        tf.discrete(srf, values)

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        thresholds = [-0.9, 0.1]
        tf.discrete(srf, values, thresholds)
        np.testing.assert_array_equal(np.unique(srf.field), [-1, 0, 1])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        tf.discrete(srf, values, thresholds="arithmetic")
        np.testing.assert_array_equal(np.unique(srf.field), [-1.0, 0.0, 1.0])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 0.5, 1]
        tf.discrete(srf, values, thresholds="equal")
        np.testing.assert_array_equal(np.unique(srf.field), values)
github GeoStat-Framework / GSTools / tests / test_srf.py View on Github external
tf.binary(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.boxcox(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = np.linspace(np.min(srf.field), np.max(srf.field), 3)
        tf.discrete(srf, values)

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        thresholds = [-0.9, 0.1]
        tf.discrete(srf, values, thresholds)
        np.testing.assert_array_equal(np.unique(srf.field), [-1, 0, 1])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        tf.discrete(srf, values, thresholds="arithmetic")
        np.testing.assert_array_equal(np.unique(srf.field), [-1.0, 0.0, 1.0])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 0.5, 1]
        tf.discrete(srf, values, thresholds="equal")
        np.testing.assert_array_equal(np.unique(srf.field), values)
github GeoStat-Framework / GSTools / examples / 07_transformations / 02_discrete.py View on Github external
If we do not give thresholds, the pairwise means of the given
values are taken as thresholds.
If thresholds are given, arbitrary values can be applied to the field.
"""
import numpy as np
import gstools as gs

# structured field with a size of 100x100 and a grid-size of 0.5x0.5
x = y = np.arange(200) * 0.5
model = gs.Gaussian(dim=2, var=1, len_scale=5)
srf = gs.SRF(model, seed=20170519)

# create 5 equidistanly spaced values, thresholds are the arithmetic means
srf.structured([x, y])
discrete_values = np.linspace(np.min(srf.field), np.max(srf.field), 5)
gs.transform.discrete(srf, discrete_values)
srf.plot()

# calculate thresholds for equal shares
# but apply different values to the separated classes
discrete_values2 = [0, -1, 2, -3, 4]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values2, thresholds="equal")
srf.plot()

# user defined thresholds
thresholds = [-1, 1]
# apply different values to the separated classes
discrete_values3 = [0, 1, 10]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values3, thresholds=thresholds)
srf.plot()
github GeoStat-Framework / GSTools / examples / 07_transformations / 02_discrete.py View on Github external
gs.transform.discrete(srf, discrete_values)
srf.plot()

# calculate thresholds for equal shares
# but apply different values to the separated classes
discrete_values2 = [0, -1, 2, -3, 4]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values2, thresholds="equal")
srf.plot()

# user defined thresholds
thresholds = [-1, 1]
# apply different values to the separated classes
discrete_values3 = [0, 1, 10]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values3, thresholds=thresholds)
srf.plot()
github GeoStat-Framework / GSTools / examples / 07_transformations / 02_discrete.py View on Github external
# structured field with a size of 100x100 and a grid-size of 0.5x0.5
x = y = np.arange(200) * 0.5
model = gs.Gaussian(dim=2, var=1, len_scale=5)
srf = gs.SRF(model, seed=20170519)

# create 5 equidistanly spaced values, thresholds are the arithmetic means
srf.structured([x, y])
discrete_values = np.linspace(np.min(srf.field), np.max(srf.field), 5)
gs.transform.discrete(srf, discrete_values)
srf.plot()

# calculate thresholds for equal shares
# but apply different values to the separated classes
discrete_values2 = [0, -1, 2, -3, 4]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values2, thresholds="equal")
srf.plot()

# user defined thresholds
thresholds = [-1, 1]
# apply different values to the separated classes
discrete_values3 = [0, 1, 10]
srf.structured([x, y])
gs.transform.discrete(srf, discrete_values3, thresholds=thresholds)
srf.plot()