Exemple #1
0
def get_fence(self, xyfence, sampling="bilinear"):
    """Get surface values along fence."""

    cxarr = xyfence[:, 0]
    cyarr = xyfence[:, 1]
    czarr = xyfence[:, 2].copy()

    sampleoptions = {"bilinear": 0, "nearest": 2}

    # czarr will be updated "inplace":
    istat = _cxtgeo.surf_get_zv_from_xyv(
        cxarr,
        cyarr,
        czarr,
        self.ncol,
        self.nrow,
        self.xori,
        self.yori,
        self.xinc,
        self.yinc,
        self.yflip,
        self.rotation,
        self.get_values1d(),
        sampleoptions.get(sampling, 0),
    )

    if istat != 0:
        logger.warning("Seem to be rotten")

    xyfence[:, 2] = czarr
    xyfence = ma.masked_greater(xyfence, xtgeo.UNDEF_LIMIT)
    xyfence = ma.mask_rows(xyfence)

    return xyfence
Exemple #2
0
def get_randomline(self,
                   fencespec,
                   hincrement=None,
                   atleast=5,
                   nextend=2,
                   sampling="bilinear"):
    """Get surface values along fence."""

    if hincrement is None and isinstance(fencespec, xtgeo.Polygons):
        logger.info("Estimate hincrement from instance...")
        fencespec = _get_randomline_fence(self, fencespec, hincrement, atleast,
                                          nextend)
        logger.info("Estimate hincrement from instance... DONE")

    if fencespec is None or fencespec is False:
        return None

    sampleoptions = {"bilinear": 0, "nearest": 2}

    xcoords = fencespec[:, 0]
    ycoords = fencespec[:, 1]
    zcoords = fencespec[:, 2].copy()
    hcoords = fencespec[:, 3]

    # zcoords will be updated "inplace":
    istat = _cxtgeo.surf_get_zv_from_xyv(
        xcoords,
        ycoords,
        zcoords,
        self.ncol,
        self.nrow,
        self.xori,
        self.yori,
        self.xinc,
        self.yinc,
        self.yflip,
        self.rotation,
        self.get_values1d(),
        sampleoptions.get(sampling, 0),
    )

    if istat != 0:
        logger.warning("Seem to be rotten")

    zcoords[zcoords > xtgeo.UNDEF_LIMIT] = np.nan
    arr = np.vstack([hcoords, zcoords]).T

    return arr
Exemple #3
0
def snap_surface(self, surf, activeonly=True):
    """Snap (or transfer) operation.

    Points that falls outside the surface will be UNDEF, and they will be removed
    if activeonly. Otherwise, the old values will be kept.
    """

    if not isinstance(surf, xtgeo.RegularSurface):
        raise ValueError(
            "Input object of wrong data type, must be RegularSurface")

    zval = self._df[self.zname].values.copy()

    ier = _cxtgeo.surf_get_zv_from_xyv(
        self._df[self.xname].values,
        self._df[self.yname].values,
        zval,
        surf.ncol,
        surf.nrow,
        surf.xori,
        surf.yori,
        surf.xinc,
        surf.yinc,
        surf.yflip,
        surf.rotation,
        surf.get_values1d(),
        0,
    )

    if ier != 0:
        raise RuntimeError(
            "Error code from C routine surf_get_zv_from_xyv is {}".format(ier))
    if activeonly:
        self._df[self.zname] = zval
        self._df = self._df[self._df[self.zname] < xtgeo.UNDEF_LIMIT]
        self._df.reset_index(inplace=True, drop=True)
    else:
        out = np.where(zval < xtgeo.UNDEF_LIMIT, zval,
                       self._df[self.zname].values)
        self._df[self.zname] = out