Esempio n. 1
0
    def bin(self):
        """ Interact with segy in binary mode.

        Since v1.1

        This mode gives access to reading and writing functionality for the
        binary header. Please note that using numeric binary offsets uses the
        offset numbers from the specification, i.e. the first field of the
        binary header starts at 3201, not 1. If you're using the enumerations
        this is handled for you.

        Examples:
            Copy a header from file g to file f::
                >>> f.bin = g.bin

            Reading a field in a trace::
                >>> traces_per_ensemble = f.bin[3213]

            Writing a field in a trace::
                >>> f.bin[BinField.Traces] = 5

            Reading multiple fields::
                >>> d = f.bin[BinField.Traces, 3233]

            Copy a field from file g to file f::
                >>> f.bin[BinField.Format] = g.bin[BinField.Format]

            Copy full binary from file f to file g::
                >>> f.bin = g.bin

            Copy multiple fields from file f to file g::
                >>> f.bin = g.bin[BinField.Traces, 3233]

            Write field in binary header via dict::
                >>> f.bin = { BinField.Traces: 350 }

            Write multiple fields in a trace::
                >>> f.bin = { 3213: 5, BinField.SweepFrequencyStart: 17 }

            Since v1.3, common dict operations are supported.

            Get a list of keys and values::
                >>> f.bin.keys()
                >>> f.bin.values()

            Get a list of key-value pairs::
                >>> f.bin.items()

            Get the number of keys-value pairs in a header::
                >>> len(f.bin)

            Update a set of values::
                >>> d = { segyio.su.jobid: 10, segyio.su.lino: 5 }
                >>> f.bin.update(d)
                >>> l = [ (segyio.su.hdt, 11), (segyio.su.hsfs, 4) ]
                >>> f.bin.update(l)
        """

        return Field.binary(self)
Esempio n. 2
0
 def gen():
     buf1, buf2 = self._header_buffer(), self._header_buffer()
     start = t0
     step = stride * len(self.segy.offsets)
     stop = t0 + (length * step)
     for i in range(start, stop, step):
         x = Field.trace(buf1, traceno=i, segy=self.segy)
         buf2, buf1 = buf1, buf2
         yield x
Esempio n. 3
0
    def __getitem__(self, traceno, buf=None):
        if isinstance(traceno, tuple):
            return self.__getitem__(traceno[0], traceno[1])

        if isinstance(traceno, slice):
            gen_buf = self._header_buffer(buf)

            def gen():
                for i in xrange(*traceno.indices(self.segy.tracecount)):
                    yield self.__getitem__(i, gen_buf)

            return gen()

        return Field.trace(buf, traceno=traceno, segy=self.segy)
Esempio n. 4
0
    def __getitem__(self, traceno, buf=None):
        if isinstance(traceno, tuple):
            return self.__getitem__(traceno[0], traceno[1])

        buf = self._header_buffer(buf)

        if isinstance(traceno, slice):
            def gen():
                buf1, buf2 = self._header_buffer(), self._header_buffer()
                for i in range(*traceno.indices(self.segy.tracecount)):
                    x = self.__getitem__(i, buf1)
                    buf2, buf1 = buf1, buf2
                    yield x

            return gen()

        return Field.trace(buf, traceno=traceno, segy=self.segy)
Esempio n. 5
0
    def bin(self):
        """ Interact with segy in binary mode.

        This mode gives access to reading and writing functionality for the
        binary header. Please note that using numeric binary offsets uses the
        offset numbers from the specification, i.e. the first field of the
        binary header starts at 3201, not 1. If you're using the enumerations
        this is handled for you.

        Examples:
            Copy a header from file g to file f::
                >>> f.bin = g.bin

            Reading a field in a trace::
                >>> traces_per_ensemble = f.bin[3213]

            Writing a field in a trace::
                >>> f.bin[BinField.Traces] = 5

            Reading multiple fields::
                >>> d = f.bin[BinField.Traces, 3233]

            Copy a field from file g to file f::
                >>> f.bin[BinField.Format] = g.bin[BinField.Format]

            Copy full binary from file f to file g::
                >>> f.bin = g.bin

            Copy multiple fields from file f to file g::
                >>> f.bin = g.bin[BinField.Traces, 3233]

            Write field in binary header via dict::
                >>> f.bin = { BinField.Traces: 350 }

            Write multiple fields in a trace::
                >>> f.bin = { 3213: 5, BinField.SweepFrequencyStart: 17 }
        """

        return Field.binary(self)
Esempio n. 6
0
 def gen():
     start = t0
     stop = t0 + (length * stride)
     for i in xrange(start, stop, stride):
         yield Field.trace(buf, traceno=i, segy=self.segy)