How to use the gstools.field.tools.make_isotropic 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 / gstools / field / condition.py View on Github external
the error field to set the given random field to zero at the conditions
    krige_var : :class:`numpy.ndarray`
        the variance of the kriged field
    """
    if srf._value_type != "scalar":
        raise ValueError("Conditioned SRF: only scalar fields allowed.")
    krige_ok = Ordinary(
        model=srf.model, cond_pos=srf.cond_pos, cond_val=srf.cond_val
    )
    krige_field, krige_var = krige_ok(srf.pos, srf.mesh_type)

    # evaluate the field at the conditional points
    x, y, z = pos2xyz(srf.cond_pos, max_dim=srf.model.dim)
    if srf.model.do_rotation:
        x, y, z = unrotate_mesh(srf.model.dim, srf.model.angles, x, y, z)
    y, z = make_isotropic(srf.model.dim, srf.model.anis, y, z)
    err_data = srf.generator.__call__(x, y, z, "unstructured")

    err_ok = Ordinary(
        model=srf.model, cond_pos=srf.cond_pos, cond_val=err_data
    )
    err_field, __ = err_ok(srf.pos, srf.mesh_type)
    cond_field = srf.raw_field + krige_field - err_field
    info = {"mean": krige_ok.mean}
    return cond_field, krige_field, err_field, krige_var, info
github GeoStat-Framework / GSTools / gstools / krige / ordinary.py View on Github external
check_mesh(self.model.dim, x, y, z, mesh_type)
        mesh_type_changed = False
        if mesh_type == "structured":
            mesh_type_changed = True
            mesh_type_old = mesh_type
            mesh_type = "unstructured"
            x, y, z, axis_lens = reshape_axis_from_struct_to_unstruct(
                self.model.dim, x, y, z
            )
        if self.model.do_rotation:
            x, y, z = unrotate_mesh(self.model.dim, self.model.angles, x, y, z)
            c_x, c_y, c_z = unrotate_mesh(
                self.model.dim, self.model.angles, c_x, c_y, c_z
            )
        y, z = make_isotropic(self.model.dim, self.model.anis, y, z)
        c_y, c_z = make_isotropic(self.model.dim, self.model.anis, c_y, c_z)

        # set condtions
        cond = np.concatenate((self.cond_val, [0]))
        krig_mat = inv(self._get_krig_mat((c_x, c_y, c_z), (c_x, c_y, c_z)))
        krig_vecs = self._get_vario_mat((c_x, c_y, c_z), (x, y, z), add=True)
        # generate the kriged field
        field, krige_var = krigesum(krig_mat, krig_vecs, cond)
        # calculate the estimated mean (kriging field at infinity)
        mean_est = np.concatenate(
            (np.full_like(self.cond_val, self.model.sill), [1])
        )
        self.mean = np.einsum("i,ij,j", cond, krig_mat, mean_est)

        # reshape field if we got an unstructured mesh
        if mesh_type_changed:
            mesh_type = mesh_type_old
github GeoStat-Framework / GSTools / gstools / covmodel / base.py View on Github external
def _get_iso_rad(self, pos):
        x, y, z = pos2xyz(pos, max_dim=self.dim)
        if self.do_rotation:
            x, y, z = unrotate_mesh(self.dim, self.angles, x, y, z)
        if not self.is_isotropic:
            y, z = make_isotropic(self.dim, self.anis, y, z)
        return np.linalg.norm((x, y, z)[: self.dim], axis=0)
github GeoStat-Framework / GSTools / gstools / field / condition.py View on Github external
"""
    if srf._value_type != "scalar":
        raise ValueError("Conditioned SRF: only scalar fields allowed.")
    krige_sk = Simple(
        model=srf.model,
        mean=srf.mean,
        cond_pos=srf.cond_pos,
        cond_val=srf.cond_val,
    )
    krige_field, krige_var = krige_sk(srf.pos, srf.mesh_type)

    # evaluate the field at the conditional points
    x, y, z = pos2xyz(srf.cond_pos, max_dim=srf.model.dim)
    if srf.model.do_rotation:
        x, y, z = unrotate_mesh(srf.model.dim, srf.model.angles, x, y, z)
    y, z = make_isotropic(srf.model.dim, srf.model.anis, y, z)
    err_data = srf.generator.__call__(x, y, z, "unstructured") + srf.mean

    err_sk = Simple(
        model=srf.model,
        mean=srf.mean,
        cond_pos=srf.cond_pos,
        cond_val=err_data,
    )
    err_field, __ = err_sk(srf.pos, srf.mesh_type)
    cond_field = srf.raw_field + krige_field - err_field + srf.mean
    info = {}
    return cond_field, krige_field, err_field, krige_var, info
github GeoStat-Framework / GSTools / gstools / krige / ordinary.py View on Github external
# format the positional arguments of the mesh
        check_mesh(self.model.dim, x, y, z, mesh_type)
        mesh_type_changed = False
        if mesh_type == "structured":
            mesh_type_changed = True
            mesh_type_old = mesh_type
            mesh_type = "unstructured"
            x, y, z, axis_lens = reshape_axis_from_struct_to_unstruct(
                self.model.dim, x, y, z
            )
        if self.model.do_rotation:
            x, y, z = unrotate_mesh(self.model.dim, self.model.angles, x, y, z)
            c_x, c_y, c_z = unrotate_mesh(
                self.model.dim, self.model.angles, c_x, c_y, c_z
            )
        y, z = make_isotropic(self.model.dim, self.model.anis, y, z)
        c_y, c_z = make_isotropic(self.model.dim, self.model.anis, c_y, c_z)

        # set condtions
        cond = np.concatenate((self.cond_val, [0]))
        krig_mat = inv(self._get_krig_mat((c_x, c_y, c_z), (c_x, c_y, c_z)))
        krig_vecs = self._get_vario_mat((c_x, c_y, c_z), (x, y, z), add=True)
        # generate the kriged field
        field, krige_var = krigesum(krig_mat, krig_vecs, cond)
        # calculate the estimated mean (kriging field at infinity)
        mean_est = np.concatenate(
            (np.full_like(self.cond_val, self.model.sill), [1])
        )
        self.mean = np.einsum("i,ij,j", cond, krig_mat, mean_est)

        # reshape field if we got an unstructured mesh
        if mesh_type_changed:
github GeoStat-Framework / GSTools / gstools / field / base.py View on Github external
# format the positional arguments of the mesh
        check_mesh(self.model.dim, x, y, z, mesh_type)
        mesh_type_changed = False
        axis_lens = None
        if (
            self.model.do_rotation or make_unstruct
        ) and mesh_type == "structured":
            mesh_type_changed = True
            mesh_type_gen = "unstructured"
            x, y, z, axis_lens = reshape_axis_from_struct_to_unstruct(
                self.model.dim, x, y, z
            )
        if self.model.do_rotation:
            x, y, z = unrotate_mesh(self.model.dim, self.model.angles, x, y, z)
        if not self.model.is_isotropic:
            y, z = make_isotropic(self.model.dim, self.model.anis, y, z)
        return x, y, z, pos, mesh_type_gen, mesh_type_changed, axis_lens