How to use the segyio._segyio.open 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_open_non_existing_file(self):
        with self.assertRaises(IOError):
            f = _segyio.open("non-existing", "r")
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_open_and_close_file(self):
        f = _segyio.open(self.filename, "r")
        _segyio.close(f)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_and_write_traceheader(self):
        fname = self.filename.replace("small", "bin_hdr_wrt")
        shutil.copyfile(self.filename, fname)
        f = _segyio.open(fname, "r+")
        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)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_text_header(self):
        f = _segyio.open(self.filename, "r")

        self.assertEqual(_segyio.read_textheader(f, 0), ACTUAL_TEXT_HEADER)

        with self.assertRaises(Exception):
            _segyio.read_texthdr(None, 0)

        _segyio.close(f)
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)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_read_and_write_trace(self):
        f = _segyio.open("test-data/trace-wrt.sgy", "w+")

        buf = numpy.ones(25, dtype=numpy.single)
        buf[11] = 3.1415
        _segyio.write_trace(f, 0, buf, 0, 100, 1, 25)
        buf[:] = 42.0
        _segyio.write_trace(f, 1, buf, 0, 100, 1, 25)

        _segyio.flush(f)

        buf = numpy.zeros(25, dtype=numpy.single)

        _segyio.read_trace(f, 0, 25, buf, 0, 100, 1, 25)

        self.assertAlmostEqual(buf[10], 1.0, places=4)
        self.assertAlmostEqual(buf[11], 3.1415, places=4)
github equinor / segyio / tests / test_segyio_c.py View on Github external
def test_open_flush_and_close_file(self):
        _segyio.flush(None)
        f = _segyio.open(self.filename, "r")
        _segyio.flush(f)
        _segyio.close(f)