How to use the segyio.TraceSortingFormat.INLINE_SORTING function in segyio

To help you get started, we’ve selected a few segyio 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 equinor / xtgeo / src / xtgeo / cube / _cube_import.py View on Github external
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)

        logger.info(values.dtype)
        if values.dtype != np.float32:
            xtg.warnuser(
                "Values are converted from {} to {}".format(values.dtype, "float32")
            )

            values = values.astype(np.float32)

        if np.isnan(np.sum(values)):
            raise ValueError("The input contains NaN values which is trouble!")
github equinor / segyio / python / segyio / tools.py View on Github external
-------

    cube : numpy.ndarray

    Notes
    -----

    .. versionadded:: 1.1

    """

    if not isinstance(f, segyio.SegyFile):
        with segyio.open(f) as fl:
            return cube(fl)

    ilsort = f.sorting == segyio.TraceSortingFormat.INLINE_SORTING
    fast = f.ilines if ilsort else f.xlines
    slow = f.xlines if ilsort else f.ilines
    fast, slow, offs = len(fast), len(slow), len(f.offsets)
    smps = len(f.samples)
    dims = (fast, slow, smps) if offs == 1 else (fast, slow, offs, smps)
    return f.trace.raw[:].reshape(dims)
github equinor / segyio / python / examples / make-file.py View on Github external
# Write the file trace-by-trace and update headers with iline, xline
        # and offset
        tr = 0
        for il in spec.ilines:
            for xl in spec.xlines:
                f.header[tr] = {
                    segyio.su.offset : 1,
                    segyio.su.iline  : il,
                    segyio.su.xline  : xl
                }
                f.trace[tr] = trace + (xl / 100.0) + il
                tr += 1

        f.bin.update(
            tsort=segyio.TraceSortingFormat.INLINE_SORTING
        )
github equinor / segyio / python / examples / make-ps-file.py View on Github external
# Write the file trace-by-trace and update headers with iline, xline
        # and offset
        tr = 0
        for il in spec.ilines:
            for xl in spec.xlines:
                for off in spec.offsets:
                    f.header[tr] = {
                        segyio.su.offset : off,
                        segyio.su.iline  : il,
                        segyio.su.xline  : xl
                    }
                    f.trace[tr] = trace + (xl / 100.0) + il + (off * 100)
                    tr += 1

        f.bin.update(
            tsort=segyio.TraceSortingFormat.INLINE_SORTING
        )
github microsoft / seismic-deeplearning / interpretation / deepseismic_interpretation / segyconverter / utils / create_segy.py View on Github external
def create_segy_file(
    masklambda, filename, sorting=segyio.TraceSortingFormat.INLINE_SORTING, ilinerange=[10, 50], xlinerange=[100, 300]
):
    spec = segyio.spec()

    # to create a file from nothing, we need to tell segyio about the structure of
    # the file, i.e. its inline numbers, crossline numbers, etc. You can also add
    # more structural information, but offsets etc. have sensible defautls. This is
    # the absolute minimal specification for a N-by-M volume
    spec.sorting = 2
    spec.format = 1
    spec.samples = range(int(10))
    spec.ilines = range(*map(int, ilinerange))
    spec.xlines = range(*map(int, xlinerange))
    print(f"Written to {filename}")
    print(f"\tinlines: {len(spec.ilines)}")
    print(f"\tcrosslines: {len(spec.xlines)}")
github microsoft / seismic-deeplearning / interpretation / deepseismic_interpretation / segyconverter / utils / create_segy.py View on Github external
f.trace[tr] = trace * ((xl / 100.0) + il)
                        tr += 1

            f.bin.update(tsort=segyio.TraceSortingFormat.CROSSLINE_SORTING)
        else:
            # Write the file trace-by-trace and update headers with iline, xline
            # and offset
            tr = 0
            for il in spec.ilines:
                for xl in spec.xlines:
                    if masklambda(il, xl):
                        f.header[tr] = {segyio.su.offset: 1, segyio.su.iline: il, segyio.su.xline: xl}
                        f.trace[tr] = trace + (xl / 100.0) + il
                        tr += 1

            f.bin.update(tsort=segyio.TraceSortingFormat.INLINE_SORTING)
        print(f"\ttraces: {tr}")