예제 #1
0
def estimate_flip(self):
    """Estimate if grid is left or right handed."""
    corners = self.get_xyz_cell_corners(activeonly=False)  # for cell 1, 1, 1

    v1 = (corners[3] - corners[0], corners[4] - corners[1], 0.0)
    v2 = (corners[6] - corners[0], corners[7] - corners[1], 0.0)

    flipvalue = find_flip(v1, v2)

    return flipvalue
예제 #2
0
def estimate_flip(self):
    """Estimate if grid is left or right handed"""
    # perhaps better to find these vectors in C as the
    # operations here are costly

    xc, yc, _zc = self.get_xyz(asmasked=False)

    v1 = (
        xc.values[1, 0, 0] - xc.values[0, 0, 0],
        yc.values[1, 0, 0] - yc.values[0, 0, 0],
        0.0,
    )

    v2 = (
        xc.values[0, 1, 0] - xc.values[0, 0, 0],
        yc.values[0, 1, 0] - yc.values[0, 0, 0],
        0.0,
    )

    flipvalue = find_flip(v1, v2)

    return flipvalue
예제 #3
0
def _import_segy_io(self, sfile):
    """Import SEGY via Statoils FOSS SegyIO library.

    Args:
        self (Cube): Cube object
        sfile (str): File name of SEGY file
        undef (float): If None, dead traces (undef) are read as is, but
            if a a value, than dead traces get this value.
    """

    # pylint: disable=too-many-statements
    # pylint: disable=too-many-locals

    logger.debug("Inline sorting %s", segyio.TraceSortingFormat.INLINE_SORTING)

    with segyio.open(sfile, "r") as segyfile:
        segyfile.mmap()

        values = segyio.tools.cube(segyfile)

        if np.isnan(np.sum(values)):
            raise ValueError("The input contains NaN values which is trouble!")

        logger.debug(segyfile.fast)
        logger.debug(segyfile.ilines)
        logger.debug(len(segyfile.ilines))
        ilines = segyfile.ilines
        xlines = segyfile.xlines

        ncol, nrow, nlay = values.shape

        trcode = segyio.TraceField.TraceIdentificationCode
        traceidcodes = segyfile.attributes(trcode)[:].reshape(ncol, nrow)

        logger.info("NRCL  %s %s %s", ncol, nrow, nlay)

        # need positions for all 4 corners
        c1v = xcalc.ijk_to_ib(1, 1, 1, ncol, nrow, 1, forder=False)
        c2v = xcalc.ijk_to_ib(ncol, 1, 1, ncol, nrow, 1, forder=False)
        c3v = xcalc.ijk_to_ib(1, nrow, 1, ncol, nrow, 1, forder=False)
        c4v = xcalc.ijk_to_ib(ncol, nrow, 1, ncol, nrow, 1, forder=False)

        clist = [c1v, c2v, c3v, c4v]

        for inum, cox in enumerate(clist):
            logger.debug(inum)
            origin = segyfile.header[cox][segyio.su.cdpx, segyio.su.cdpy,
                                          segyio.su.scalco, segyio.su.delrt,
                                          segyio.su.dt, segyio.su.iline,
                                          segyio.su.xline, ]
            # get the data on SU (seismic unix) format
            cdpx = origin[segyio.su.cdpx]
            cdpy = origin[segyio.su.cdpy]
            scaler = origin[segyio.su.scalco]
            if scaler < 0:
                cdpx = -1 * float(cdpx) / scaler
                cdpy = -1 * float(cdpy) / scaler
            else:
                cdpx = cdpx * scaler
                cdpy = cdpy * scaler

            if inum == 0:
                xori = cdpx
                yori = cdpy
                zori = origin[segyio.su.delrt]
                zinc = origin[segyio.su.dt] / 1000.0

            if inum == 1:
                slen, _rotrad1, rot1 = xcalc.vectorinfo2(
                    xori, cdpx, yori, cdpy)
                xinc = slen / (ncol - 1)

                rotation = rot1
                xvv = (cdpx - xori, cdpy - yori, 0)

            if inum == 2:
                slen, _rotrad2, rot2 = xcalc.vectorinfo2(
                    xori, cdpx, yori, cdpy)
                yinc = slen / (nrow - 1)

                # find YFLIP by cross products
                yvv = (cdpx - xori, cdpy - yori, 0)

                yflip = xcalc.find_flip(xvv, yvv)

        rot2 = segyio.tools.rotation(segyfile)[0]
        logger.debug("SEGYIO rotation is %s", rot2 * 180 / 3.1415)
        logger.debug("XTGeo rotation is %s", rotation)

    # attributes to update
    self._ilines = ilines
    self._xlines = xlines
    self._ncol = ncol
    self._nrow = nrow
    self._nlay = nlay
    self._xori = xori
    self._xinc = xinc
    self._yori = yori
    self._yinc = yinc
    self._zori = zori
    self._zinc = zinc
    self._rotation = rotation
    self._values = values
    self._yflip = yflip
    self._segyfile = sfile
    self._traceidcodes = traceidcodes