How to use the segyio._segyio.fread_trace0 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 test_read_line_mmap(self):
        f, metrics, iline_idx, xline_idx = self.read_small(True)

        tr0 = metrics['trace0']
        bsz = metrics['trace_bsize']
        samples = metrics['sample_count']
        xline_stride = metrics['xline_stride']
        iline_stride = metrics['iline_stride']
        offsets = metrics['offset_count']

        xline_trace0 = _segyio.fread_trace0(20, len(iline_idx), xline_stride, offsets, xline_idx, "crossline")
        iline_trace0 = _segyio.fread_trace0(1, len(xline_idx), iline_stride, offsets, iline_idx, "inline")

        buf = numpy.zeros((len(iline_idx), samples), dtype=numpy.single)

        _segyio.read_line(f, xline_trace0, len(iline_idx), xline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 800.061169624, places=6)

        _segyio.read_line(f, iline_trace0, len(xline_idx), iline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 305.061146736, places=6)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_line_mmap(self):
        f, metrics, iline_idx, xline_idx = self.read_small(True)

        tr0 = metrics['trace0']
        bsz = metrics['trace_bsize']
        samples = metrics['sample_count']
        xline_stride = metrics['xline_stride']
        iline_stride = metrics['iline_stride']
        offsets = metrics['offset_count']

        xline_trace0 = _segyio.fread_trace0(20, len(iline_idx), xline_stride, offsets, xline_idx, "crossline")
        iline_trace0 = _segyio.fread_trace0(1, len(xline_idx), iline_stride, offsets, iline_idx, "inline")

        buf = numpy.zeros((len(iline_idx), samples), dtype=numpy.single)

        _segyio.read_line(f, xline_trace0, len(iline_idx), xline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 800.061169624, places=6)

        _segyio.read_line(f, iline_trace0, len(xline_idx), iline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 305.061146736, places=6)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
offsets       = numpy.zeros(metrics['offset_count'], dtype=numpy.uintc)
        _segyio.init_indices(f, metrics, iline_indexes, xline_indexes, offsets)

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
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)

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
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)

        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)

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)
github equinor / segyio / tests / test_segyio_c.py View on Github external
with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_line(self):
        f, metrics, iline_idx, xline_idx = self.read_small()

        tr0 = metrics['trace0']
        bsz = metrics['trace_bsize']
        samples = metrics['sample_count']
        xline_stride = metrics['xline_stride']
        iline_stride = metrics['iline_stride']
        offsets = metrics['offset_count']

        xline_trace0 = _segyio.fread_trace0(20, len(iline_idx), xline_stride, offsets, xline_idx, "crossline")
        iline_trace0 = _segyio.fread_trace0(1, len(xline_idx), iline_stride, offsets, iline_idx, "inline")

        buf = numpy.zeros((len(iline_idx), samples), dtype=numpy.single)

        _segyio.read_line(f, xline_trace0, len(iline_idx), xline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 800.061169624, places=6)

        _segyio.read_line(f, iline_trace0, len(xline_idx), iline_stride, offsets, buf, tr0, bsz, 1, samples)
        self.assertAlmostEqual(sum(sum(buf)), 305.061146736, places=6)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
offset_count = metrics['offset_count']

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

        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)

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
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)

        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)

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(0, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")

        with self.assertRaises(KeyError):
            _segyio.fread_trace0(2, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")

        value = _segyio.fread_trace0(1, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 0)

        value = _segyio.fread_trace0(2, len(xline_indexes), line_metrics['iline_stride'], offset_count, iline_indexes, "inline")
        self.assertEqual(value, 5)

        value = _segyio.fread_trace0(21, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 1)

        value = _segyio.fread_trace0(22, len(iline_indexes), line_metrics['xline_stride'], offset_count, xline_indexes, "crossline")
        self.assertEqual(value, 2)

        _segyio.close(f)