How to use the pykrige.core._adjust_for_anisotropy function in PyKrige

To help you get started, we’ve selected a few PyKrige 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 bsmurphy / PyKrige / pykrige / uk3d.py View on Github external
self.verbose = verbose
        self.enable_plotting = enable_plotting
        if self.enable_plotting and self.verbose:
            print("Plotting Enabled\n")

        self.XCENTER = (np.amax(self.X_ORIG) + np.amin(self.X_ORIG)) / 2.0
        self.YCENTER = (np.amax(self.Y_ORIG) + np.amin(self.Y_ORIG)) / 2.0
        self.ZCENTER = (np.amax(self.Z_ORIG) + np.amin(self.Z_ORIG)) / 2.0
        self.anisotropy_scaling_y = anisotropy_scaling_y
        self.anisotropy_scaling_z = anisotropy_scaling_z
        self.anisotropy_angle_x = anisotropy_angle_x
        self.anisotropy_angle_y = anisotropy_angle_y
        self.anisotropy_angle_z = anisotropy_angle_z
        if self.verbose:
            print("Adjusting data for anisotropy...")
        self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED = _adjust_for_anisotropy(
            np.vstack((self.X_ORIG, self.Y_ORIG, self.Z_ORIG)).T,
            [self.XCENTER, self.YCENTER, self.ZCENTER],
            [self.anisotropy_scaling_y, self.anisotropy_scaling_z],
            [self.anisotropy_angle_x, self.anisotropy_angle_y, self.anisotropy_angle_z],
        ).T

        if self.verbose:
            print("Initializing variogram model...")

        vp_temp = _make_variogram_parameter_list(
            self.variogram_model, variogram_parameters
        )
        (
            self.lags,
            self.semivariance,
            self.variogram_model_parameters,
github bsmurphy / PyKrige / pykrige / uk.py View on Github external
raise ValueError(
                    "Inconsistent number of specified drift terms supplied."
                )
        else:
            if len(specified_drift_arrays) != 0:
                warnings.warn(
                    "Provided specified drift values, but "
                    "'specified' drift was not initialized during "
                    "instantiation of UniversalKriging class.",
                    RuntimeWarning,
                )

        xy_points_original = np.concatenate(
            (xpts[:, np.newaxis], ypts[:, np.newaxis]), axis=1
        )
        xpts, ypts = _adjust_for_anisotropy(
            np.vstack((xpts, ypts)).T,
            [self.XCENTER, self.YCENTER],
            [self.anisotropy_scaling],
            [self.anisotropy_angle],
        ).T
        xy_points = np.concatenate((xpts[:, np.newaxis], ypts[:, np.newaxis]), axis=1)
        xy_data = np.concatenate(
            (self.X_ADJUSTED[:, np.newaxis], self.Y_ADJUSTED[:, np.newaxis]), axis=1
        )

        if style != "masked":
            mask = np.zeros(npt, dtype="bool")

        bd = cdist(xy_points, xy_data, "euclidean")
        if backend == "vectorized":
            zvalues, sigmasq = self._exec_vector(
github bsmurphy / PyKrige / pykrige / uk.py View on Github external
if self.verbose:
                print("Implementing external Z drift.")
        else:
            self.external_Z_drift = False

        # Well coordinates are rotated into adjusted coordinate frame.
        if "point_log" in drift_terms:
            if point_drift is None:
                raise ValueError(
                    "Must specify location(s) and strength(s) of point drift terms."
                )
            self.point_log_drift = True
            point_log = np.atleast_2d(np.squeeze(np.array(point_drift, copy=True)))
            self.point_log_array = np.zeros(point_log.shape)
            self.point_log_array[:, 2] = point_log[:, 2]
            self.point_log_array[:, :2] = _adjust_for_anisotropy(
                np.vstack((point_log[:, 0], point_log[:, 1])).T,
                [self.XCENTER, self.YCENTER],
                [self.anisotropy_scaling],
                [self.anisotropy_angle],
            )
            if self.verbose:
                print(
                    "Implementing external point-logarithmic drift; "
                    "number of points =",
                    self.point_log_array.shape[0],
                    "\n",
                )
        else:
            self.point_log_drift = False

        if "specified" in drift_terms:
github bsmurphy / PyKrige / pykrige / uk.py View on Github external
)
        self.Z = np.atleast_1d(np.squeeze(np.array(z, copy=True, dtype=np.float64)))

        self.verbose = verbose
        self.enable_plotting = enable_plotting
        if self.enable_plotting and self.verbose:
            print("Plotting Enabled\n")

        # adjust for anisotropy...
        self.XCENTER = (np.amax(self.X_ORIG) + np.amin(self.X_ORIG)) / 2.0
        self.YCENTER = (np.amax(self.Y_ORIG) + np.amin(self.Y_ORIG)) / 2.0
        self.anisotropy_scaling = anisotropy_scaling
        self.anisotropy_angle = anisotropy_angle
        if self.verbose:
            print("Adjusting data for anisotropy...")
        self.X_ADJUSTED, self.Y_ADJUSTED = _adjust_for_anisotropy(
            np.vstack((self.X_ORIG, self.Y_ORIG)).T,
            [self.XCENTER, self.YCENTER],
            [self.anisotropy_scaling],
            [self.anisotropy_angle],
        ).T

        if self.verbose:
            print("Initializing variogram model...")

        # see comment in ok.py about 'use_psill' kwarg...
        vp_temp = _make_variogram_parameter_list(
            self.variogram_model, variogram_parameters
        )
        (
            self.lags,
            self.semivariance,
github bsmurphy / PyKrige / pykrige / ok3d.py View on Github external
self.verbose = verbose
        self.enable_plotting = enable_plotting
        if self.enable_plotting and self.verbose:
            print("Plotting Enabled\n")

        self.XCENTER = (np.amax(self.X_ORIG) + np.amin(self.X_ORIG)) / 2.0
        self.YCENTER = (np.amax(self.Y_ORIG) + np.amin(self.Y_ORIG)) / 2.0
        self.ZCENTER = (np.amax(self.Z_ORIG) + np.amin(self.Z_ORIG)) / 2.0
        self.anisotropy_scaling_y = anisotropy_scaling_y
        self.anisotropy_scaling_z = anisotropy_scaling_z
        self.anisotropy_angle_x = anisotropy_angle_x
        self.anisotropy_angle_y = anisotropy_angle_y
        self.anisotropy_angle_z = anisotropy_angle_z
        if self.verbose:
            print("Adjusting data for anisotropy...")
        self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED = _adjust_for_anisotropy(
            np.vstack((self.X_ORIG, self.Y_ORIG, self.Z_ORIG)).T,
            [self.XCENTER, self.YCENTER, self.ZCENTER],
            [self.anisotropy_scaling_y, self.anisotropy_scaling_z],
            [self.anisotropy_angle_x, self.anisotropy_angle_y, self.anisotropy_angle_z],
        ).T

        if self.verbose:
            print("Initializing variogram model...")

        vp_temp = _make_variogram_parameter_list(
            self.variogram_model, variogram_parameters
        )
        (
            self.lags,
            self.semivariance,
            self.variogram_model_parameters,
github bsmurphy / PyKrige / pykrige / ok.py View on Github external
xpts = grid_x.flatten()
            ypts = grid_y.flatten()

        elif style == "points":
            if xpts.size != ypts.size:
                raise ValueError(
                    "xpoints and ypoints must have "
                    "same dimensions when treated as "
                    "listing discrete points."
                )
            npt = nx
        else:
            raise ValueError("style argument must be 'grid', 'points', or 'masked'")

        if self.coordinates_type == "euclidean":
            xpts, ypts = _adjust_for_anisotropy(
                np.vstack((xpts, ypts)).T,
                [self.XCENTER, self.YCENTER],
                [self.anisotropy_scaling],
                [self.anisotropy_angle],
            ).T
            # Prepare for cdist:
            xy_data = np.concatenate(
                (self.X_ADJUSTED[:, np.newaxis], self.Y_ADJUSTED[:, np.newaxis]), axis=1
            )
            xy_points = np.concatenate(
                (xpts[:, np.newaxis], ypts[:, np.newaxis]), axis=1
            )
        elif self.coordinates_type == "geographic":
            # In spherical coordinates, we do not correct for anisotropy.
            # Also, we don't use scipy.spatial.cdist, so we do not have to
            # format the input data accordingly.
github bsmurphy / PyKrige / pykrige / ok.py View on Github external
self.verbose = verbose
        self.enable_plotting = enable_plotting
        if self.enable_plotting and self.verbose:
            print("Plotting Enabled\n")

        # adjust for anisotropy... only implemented for euclidean (rectangular)
        # coordinates, as anisotropy is ambiguous for geographic coordinates...
        if coordinates_type == "euclidean":
            self.XCENTER = (np.amax(self.X_ORIG) + np.amin(self.X_ORIG)) / 2.0
            self.YCENTER = (np.amax(self.Y_ORIG) + np.amin(self.Y_ORIG)) / 2.0
            self.anisotropy_scaling = anisotropy_scaling
            self.anisotropy_angle = anisotropy_angle
            if self.verbose:
                print("Adjusting data for anisotropy...")
            self.X_ADJUSTED, self.Y_ADJUSTED = _adjust_for_anisotropy(
                np.vstack((self.X_ORIG, self.Y_ORIG)).T,
                [self.XCENTER, self.YCENTER],
                [self.anisotropy_scaling],
                [self.anisotropy_angle],
            ).T
        elif coordinates_type == "geographic":
            # Leave everything as is in geographic case.
            # May be open to discussion?
            if anisotropy_scaling != 1.0:
                warnings.warn(
                    "Anisotropy is not compatible with geographic "
                    "coordinates. Ignoring user set anisotropy.",
                    UserWarning,
                )
            self.XCENTER = 0.0
            self.YCENTER = 0.0
github bsmurphy / PyKrige / pykrige / ok.py View on Github external
)
            else:
                self.variogram_function = variogram_function
        else:
            self.variogram_function = self.variogram_dict[self.variogram_model]

        if (
            anisotropy_scaling != self.anisotropy_scaling
            or anisotropy_angle != self.anisotropy_angle
        ):
            if self.coordinates_type == "euclidean":
                if self.verbose:
                    print("Adjusting data for anisotropy...")
                self.anisotropy_scaling = anisotropy_scaling
                self.anisotropy_angle = anisotropy_angle
                self.X_ADJUSTED, self.Y_ADJUSTED = _adjust_for_anisotropy(
                    np.vstack((self.X_ORIG, self.Y_ORIG)).T,
                    [self.XCENTER, self.YCENTER],
                    [self.anisotropy_scaling],
                    [self.anisotropy_angle],
                ).T
            elif self.coordinates_type == "geographic":
                if anisotropy_scaling != 1.0:
                    warnings.warn(
                        "Anisotropy is not compatible with geographic"
                        " coordinates. Ignoring user set anisotropy.",
                        UserWarning,
                    )
                self.anisotropy_scaling = 1.0
                self.anisotropy_angle = 0.0
                self.X_ADJUSTED = self.X_ORIG
                self.Y_ADJUSTED = self.Y_ORIG
github bsmurphy / PyKrige / pykrige / uk3d.py View on Github external
if (
            anisotropy_scaling_y != self.anisotropy_scaling_y
            or anisotropy_scaling_z != self.anisotropy_scaling_z
            or anisotropy_angle_x != self.anisotropy_angle_x
            or anisotropy_angle_y != self.anisotropy_angle_y
            or anisotropy_angle_z != self.anisotropy_angle_z
        ):
            if self.verbose:
                print("Adjusting data for anisotropy...")
            self.anisotropy_scaling_y = anisotropy_scaling_y
            self.anisotropy_scaling_z = anisotropy_scaling_z
            self.anisotropy_angle_x = anisotropy_angle_x
            self.anisotropy_angle_y = anisotropy_angle_y
            self.anisotropy_angle_z = anisotropy_angle_z
            self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED = _adjust_for_anisotropy(
                np.vstack((self.X_ORIG, self.Y_ORIG, self.Z_ORIG)).T,
                [self.XCENTER, self.YCENTER, self.ZCENTER],
                [self.anisotropy_scaling_y, self.anisotropy_scaling_z],
                [
                    self.anisotropy_angle_x,
                    self.anisotropy_angle_y,
                    self.anisotropy_angle_z,
                ],
            ).T

        if self.verbose:
            print("Updating variogram mode...")

        vp_temp = _make_variogram_parameter_list(
            self.variogram_model, variogram_parameters
        )