コード例 #1
0
def test_ijk_to_ib():
    """Convert I J K to IB index (F or C order)"""

    ib = xcalc.ijk_to_ib(2, 2, 2, 3, 4, 5)
    assert ib == 16

    ib = xcalc.ijk_to_ib(3, 1, 1, 3, 4, 5)
    assert ib == 2

    ic = xcalc.ijk_to_ib(2, 2, 2, 3, 4, 5, forder=False)
    assert ic == 26

    ic = xcalc.ijk_to_ib(3, 1, 1, 3, 4, 5, forder=False)
    assert ic == 40
コード例 #2
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
コード例 #3
0
ファイル: test_calc.py プロジェクト: sindre-nistad/xtgeo
def test_ijk_to_ib():
    """Convert I J K to IB index."""

    ib = xcalc.ijk_to_ib(2, 2, 2, 3, 4, 5)
    assert ib == 16