How to use the segyio._segyio.close 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_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)
        self.assertEqual(metrics['iline_stride'], 1)

        # (sorting, trace_count, inline_count, crossline_count, offset_count)
        metrics = _segyio.init_line_metrics(1, 15, 3, 5, 1)
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
metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)

        self.assertEqual(metrics['iline_field'], ilb)
        self.assertEqual(metrics['xline_field'], xlb)
        self.assertEqual(metrics['trace0'], _segyio.textheader_size() + _segyio.binheader_size())
        self.assertEqual(metrics['sample_count'], 50)
        self.assertEqual(metrics['format'], 1)
        self.assertEqual(metrics['trace_bsize'], 200)
        self.assertEqual(metrics['sorting'], 2) # inline sorting = 2, crossline sorting = 1
        self.assertEqual(metrics['trace_count'], 25)
        self.assertEqual(metrics['offset_count'], 1)
        self.assertEqual(metrics['iline_count'], 5)
        self.assertEqual(metrics['xline_count'], 5)

        _segyio.close(f)

        with self.assertRaises(IOError):
            metrics = _segyio.init_metrics(f, binary_header, ilb, xlb)
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)
github equinor / segyio / tests / test_segyio_c.py View on Github external
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
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
_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)

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

        self.assertAlmostEqual(sum(buf), 42.0 * 25, places=4)

        _segyio.close(f)
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_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_close_non_existing_file(self):
        with self.assertRaises(TypeError):
            _segyio.close(None)