How to use the segyio._segyio 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 / segyio / tests / test_segyio_c.py View on Github external
def read_small(self, mmap = False):
        f = _segyio.open(self.filename, "r")

        if mmap: _segyio.mmap(f)

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193

        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        sorting = metrics['sorting']
        trace_count = metrics['trace_count']
        inline_count = metrics['iline_count']
        crossline_count = metrics['xline_count']
        offset_count = metrics['offset_count']

        line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)
github equinor / segyio / tests / test_segyio_c.py View on Github external
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        sorting = metrics['sorting']
        trace_count = metrics['trace_count']
        inline_count = metrics['iline_count']
        crossline_count = metrics['xline_count']
        offset_count = metrics['offset_count']

        line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)

        metrics.update(line_metrics)

        iline_indexes = numpy.zeros(metrics['iline_count'], dtype=numpy.uintc)
        xline_indexes = numpy.zeros(metrics['xline_count'], dtype=numpy.uintc)
        offsets       = numpy.zeros(metrics['offset_count'], dtype=numpy.uintc)
        _segyio.init_indices(f, metrics, iline_indexes, xline_indexes, offsets)

        return f, metrics, iline_indexes, xline_indexes
github equinor / segyio / tests / test_segyio_c.py View on Github external
def read_small(self, mmap = False):
        f = _segyio.open(self.filename, "r")

        if mmap: _segyio.mmap(f)

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193

        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        sorting = metrics['sorting']
        trace_count = metrics['trace_count']
        inline_count = metrics['iline_count']
        crossline_count = metrics['xline_count']
        offset_count = metrics['offset_count']

        line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)

        metrics.update(line_metrics)

        iline_indexes = numpy.zeros(metrics['iline_count'], dtype=numpy.uintc)
        xline_indexes = numpy.zeros(metrics['xline_count'], dtype=numpy.uintc)
        offsets       = numpy.zeros(metrics['offset_count'], dtype=numpy.uintc)
        _segyio.init_indices(f, metrics, iline_indexes, xline_indexes, offsets)
github equinor / segyio / tests / test_segyio_c.py View on Github external
binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193
        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        empty = _segyio.empty_traceheader()

        with self.assertRaises(TypeError):
            trace_header = _segyio.read_traceheader("+", )

        with self.assertRaises(TypeError):
            trace_header = _segyio.read_traceheader(f, 0, None)

        trace_header = _segyio.read_traceheader(f, 0, _segyio.empty_traceheader(), metrics['trace0'], metrics['trace_bsize'])

        self.assertEqual(_segyio.get_field(trace_header, ilb), 1)
        self.assertEqual(_segyio.get_field(trace_header, xlb), 20)

        trace_header = _segyio.read_traceheader(f, 1, _segyio.empty_traceheader(), metrics['trace0'], metrics['trace_bsize'])

        self.assertEqual(_segyio.get_field(trace_header, ilb), 1)
        self.assertEqual(_segyio.get_field(trace_header, xlb), 21)

        _segyio.set_field(trace_header, ilb, 99)
        _segyio.set_field(trace_header, xlb, 42)

        _segyio.write_traceheader(f, 0, trace_header, metrics['trace0'], metrics['trace_bsize'])

        trace_header = _segyio.read_traceheader(f, 0, _segyio.empty_traceheader(), metrics['trace0'], metrics['trace_bsize'])

        self.assertEqual(_segyio.get_field(trace_header, ilb), 99)
        self.assertEqual(_segyio.get_field(trace_header, xlb), 42)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def read_small(self, mmap = False):
        f = _segyio.open(self.filename, "r")

        if mmap: _segyio.mmap(f)

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193

        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        sorting = metrics['sorting']
        trace_count = metrics['trace_count']
        inline_count = metrics['iline_count']
        crossline_count = metrics['xline_count']
        offset_count = metrics['offset_count']

        line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)

        metrics.update(line_metrics)

        iline_indexes = numpy.zeros(metrics['iline_count'], dtype=numpy.uintc)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def read_small(self, mmap = False):
        f = _segyio.open(self.filename, "r")

        if mmap: _segyio.mmap(f)

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193

        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        sorting = metrics['sorting']
        trace_count = metrics['trace_count']
        inline_count = metrics['iline_count']
        crossline_count = metrics['xline_count']
        offset_count = metrics['offset_count']

        line_metrics = _segyio.init_line_metrics(sorting, trace_count, inline_count, crossline_count, offset_count)

        metrics.update(line_metrics)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_binary_header_size(self):
        self.assertEqual(400, _segyio.binheader_size())
github equinor / segyio / python / segyio / field.py View on Github external
def trace(cls, traceno, segy):
        buf = bytearray(segyio._segyio.thsize())
        return Field(buf, kind='trace',
                          traceno=traceno,
                          filehandle=segy.xfd,
                          readonly=segy.readonly,
                    ).reload()
github equinor / segyio / python / segyio / field.py View on Github external
# do setup of kind/keys first, so that keys() work. if this method
        # throws, we want repr() to be well-defined for backtrace, and that
        # requires _keys
        if kind == 'binary':
            self._keys = self._bin_keys
            self.kind = BinField
        elif kind == 'trace':
            self._keys = self._tr_keys
            self.kind = TraceField
        else:
            raise ValueError('Unknown header type {}'.format(kind))

        self.buf = buf
        self.traceno = traceno
        self.filehandle = filehandle
        self.getfield = segyio._segyio.getfield
        self.putfield = segyio._segyio.putfield

        self.readonly = readonly