Beispiel #1
0
    def __setitem__(self, index, val):
        if isinstance(val, TextHeader):
            self[index] = val[0]
            return

        if index > self.outer.ext_headers:
            raise IndexError("Textual header {} not in file".format(index))

        _segyio.write_textheader(self.outer.xfd, index, val)
Beispiel #2
0
    def test_write_text_header(self):
        fname = self.filename.replace("small", "txt_hdr_wrt")
        shutil.copyfile(self.filename, fname)
        f = _segyio.open(fname, "r+")

        with self.assertRaises(ValueError):
            _segyio.write_textheader(f, 0, "")

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

        _segyio.write_textheader(f, 0, "yolo" * 800)

        self.assertEqual(_segyio.read_textheader(f, 0), "yolo" * 800)

        _segyio.close(f)
Beispiel #3
0
    def test_write_text_header(self):
        with TestContext("write_text_header") as context:
            context.copy_file(self.filename)

            f = _segyio.open("small.sgy", "r+")

            with self.assertRaises(ValueError):
                _segyio.write_textheader(f, 0, "")

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

            _segyio.write_textheader(f, 0, "yolo" * 800)

            textheader = _segyio.read_textheader(f, 0)
            textheader = textheader.decode('ascii')  # Because in Python 3.5 bytes are not comparable to strings
            self.assertEqual(textheader, "yolo" * 800)

            _segyio.close(f)
Beispiel #4
0
    def test_write_text_header(self):
        with TestContext("write_text_header") as context:
            context.copy_file(self.filename)

            f = _segyio.open("small.sgy", "r+")

            _segyio.write_textheader(f, 0, "")

            textheader = _segyio.read_textheader(f, 0)
            textheader = textheader.decode('ascii')
            self.assertEqual(textheader, "" * 3200)

            _segyio.write_textheader(f, 0, "yolo" * 800)

            textheader = _segyio.read_textheader(f, 0)
            textheader = textheader.decode(
                'ascii'
            )  # Because in Python 3.5 bytes are not comparable to strings
            self.assertEqual(textheader, "yolo" * 800)

            _segyio.close(f)
Beispiel #5
0
            def __setitem__(inner, index, val):
                if index > self.ext_headers:
                    raise IndexError("Textual header %d not in file" % index)

                _segyio.write_textheader(self.xfd, index, val)