How to use the gstools.tools.geometric.pos2xyz 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 / mesh.py View on Github external
def _vtk_structured_reshape(self, fields):
        """An internal helper to extract what is needed for the vtk rectilinear grid
        """
        if not isinstance(fields, dict):
            fields = {"field": fields}
        x, y, z = pos2xyz(self.pos)
        if y is None:
            y = np.array([0])
        if z is None:
            z = np.array([0])
        # need fortran order in VTK
        for field in fields:
            fields[field] = fields[field].reshape(-1, order="F")
            if len(fields[field]) != len(x) * len(y) * len(z):
                raise ValueError(
                    "gstools.vtk_export_structured: "
                    "field shape doesn't match the given mesh"
                )
        return x, y, z, fields
github GeoStat-Framework / GSTools / gstools / field / mesh.py View on Github external
def _vtk_unstructured_reshape(self, fields):
        if not isinstance(fields, dict):
            fields = {"field": fields}
        x, y, z = pos2xyz(self.pos)
        if y is None:
            y = np.zeros_like(x)
        if z is None:
            z = np.zeros_like(x)
        for field in fields:
            fields[field] = fields[field].reshape(-1)
            if (
                len(fields[field]) != len(x)
                or len(fields[field]) != len(y)
                or len(fields[field]) != len(z)
            ):
                raise ValueError(
                    "gstools.vtk_export_unstructured: "
                    "field shape doesn't match the given mesh"
                )
        return x, y, z, fields
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_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 / tools / export.py View on Github external
def _vtk_unstructured_helper(pos, fields):
    if not isinstance(fields, dict):
        fields = {"field": fields}
    x, y, z = pos2xyz(pos)
    if y is None:
        y = np.zeros_like(x)
    if z is None:
        z = np.zeros_like(x)
    for field in fields:
        fields[field] = fields[field].reshape(-1)
        if (
            len(fields[field]) != len(x)
            or len(fields[field]) != len(y)
            or len(fields[field]) != len(z)
        ):
            raise ValueError(
                "gstools.vtk_export_unstructured: "
                "field shape doesn't match the given mesh"
            )
    return x, y, z, fields
github GeoStat-Framework / GSTools / gstools / tools / export.py View on Github external
def _vtk_structured_helper(pos, fields):
    """An internal helper to extract what is needed for the vtk rectilinear grid
    """
    if not isinstance(fields, dict):
        fields = {"field": fields}
    x, y, z = pos2xyz(pos)
    if y is None:
        y = np.array([0])
    if z is None:
        z = np.array([0])
    # need fortran order in VTK
    for field in fields:
        fields[field] = fields[field].reshape(-1, order="F")
        if len(fields[field]) != len(x) * len(y) * len(z):
            raise ValueError(
                "gstools.vtk_export_structured: "
                "field shape doesn't match the given mesh"
            )
    return x, y, z, fields
github GeoStat-Framework / GSTools / gstools / krige / tools.py View on Github external
cond_pos : :class:`list`
        the position tuple of the conditions (x, [y, z])
    cond_val : :class:`numpy.ndarray`
        the values of the conditions
    max_dim : :class:`int`, optional
        Cut of information above the given dimension. Default: 3

    Returns
    -------
    cond_pos : :class:`list`
        the error checked cond_pos
    cond_val : :class:`numpy.ndarray`
        the error checked cond_val
    """
    # convert the input for right shapes and dimension checks
    c_x, c_y, c_z = pos2xyz(cond_pos, dtype=np.double, max_dim=max_dim)
    cond_pos = xyz2pos(c_x, c_y, c_z)
    cond_val = np.array(cond_val, dtype=np.double).reshape(-1)
    if not all([len(cond_pos[i]) == len(cond_val) for i in range(max_dim)]):
        raise ValueError(
            "Please check your 'cond_pos' and 'cond_val' parameters. "
            + "The shapes do not match."
        )
    return cond_pos, cond_val