How to use the segyio._segyio.read_binaryheader 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_indices(self):
        f = _segyio.open(self.filename, "r")

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193
        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
        dmy = numpy.zeros(2, dtype=numpy.uintc)

        dummy_metrics = {'xline_count':   2,
                         'iline_count':   2,
                         'offset_count':  1}

        with self.assertRaises(TypeError):
            _segyio.init_indices(".", {}, dmy, dmy, dmy)

        with self.assertRaises(TypeError):
            _segyio.init_indices(f, "-", dmy, dmy, dmy)

        # with self.assertRaises(KeyError):
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_metrics(self):
        f = _segyio.open(self.filename, "r")
        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193

        with self.assertRaises(TypeError):
            metrics = _segyio.init_metrics("?", binary_header, ilb, xlb)

        with self.assertRaises(TypeError):
            metrics = _segyio.init_metrics(f, "?", ilb, xlb)

        with self.assertRaises(IndexError):
            metrics = _segyio.init_metrics(f, binary_header, ilb + 1, xlb)

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

        self.assertEqual(metrics['iline_field'], ilb)
        self.assertEqual(metrics['xline_field'], xlb)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_binary_header_fields(self):
        f = _segyio.open(self.filename, "r")

        binary_header = _segyio.read_binaryheader(f)

        with self.assertRaises(TypeError):
            value = _segyio.get_field("s", 0)

        with self.assertRaises(IndexError):
            value = _segyio.get_field(binary_header, -1)

        self.assertEqual(_segyio.get_field(binary_header, 3225), 1)
        self.assertEqual(_segyio.get_field(binary_header, 3221), 50)

        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_line_metrics(self):
        f = _segyio.open(self.filename, "r")

        binary_header = _segyio.read_binaryheader(f)
        ilb = 189
        xlb = 193
        metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
        _segyio.close(f)

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

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

        self.assertEqual(metrics['xline_length'], 5)
        self.assertEqual(metrics['xline_stride'], 5)
        self.assertEqual(metrics['iline_length'], 5)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_and_write_binary_header(self):
        with self.assertRaises(Exception):
            hdr = _segyio.read_binaryheader(None)

        with self.assertRaises(Exception):
            _segyio.write_binaryheader(None, None)

        fname = self.filename.replace("small", "bin_hdr_wrt")
        shutil.copyfile(self.filename, fname)
        f = _segyio.open(fname, "r+")

        binary_header = _segyio.read_binaryheader(f)

        with self.assertRaises(Exception):
            _segyio.write_binaryheader(f, "Not the correct type")

        _segyio.write_binaryheader(f, binary_header)
        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_fread_trace0(self):
        f = _segyio.open(self.filename, "r")

        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)

        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)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_and_write_binary_header(self):
        with self.assertRaises(Exception):
            hdr = _segyio.read_binaryheader(None)

        with self.assertRaises(Exception):
            _segyio.write_binaryheader(None, None)

        fname = self.filename.replace("small", "bin_hdr_wrt")
        shutil.copyfile(self.filename, fname)
        f = _segyio.open(fname, "r+")

        binary_header = _segyio.read_binaryheader(f)

        with self.assertRaises(Exception):
            _segyio.write_binaryheader(f, "Not the correct type")

        _segyio.write_binaryheader(f, binary_header)
        _segyio.close(f)