Esempio n. 1
0
    def __init__(self, filename, mode, iline=189, xline=193, tracecount=0, binary=None):
        self._filename = filename
        self._mode = mode
        self._il = iline
        self._xl = xline

        # property value holders
        self._ilines = None
        self._xlines = None
        self._offsets = None
        self._samples = None
        self._sorting = None

        # private values
        self._iline_length = None
        self._iline_stride = None
        self._xline_length = None
        self._xline_stride = None

        self._trace = Trace(self)
        self._header = Header(self)
        self._iline = None
        self._xline = None
        self._gather = None

        self.xfd = _segyio.segyiofd(filename, mode, tracecount, binary)
        metrics = self.xfd.metrics()
        self._fmt = metrics['format']
        self._tracecount = metrics['tracecount']
        self._ext_headers = metrics['ext_headers']

        super(SegyFile, self).__init__()
Esempio n. 2
0
    def __init__(self, filename, mode, iline=189, xline=193):
        """
        Constructor, internal.
        """

        self._filename = filename
        self._mode = mode
        self._il = iline
        self._xl = xline

        # property value holders
        self._ilines = None
        self._xlines = None
        self._tracecount = None
        self._sorting = None
        self._offsets = None
        self._ext_headers = None
        self._samples = None

        # private values
        self._iline_length = None
        self._iline_stride = None
        self._xline_length = None
        self._xline_stride = None
        self._fmt = None
        self._tr0 = None
        self._bsz = None

        self._trace = Trace(self)
        self._header = Header(self)
        self._iline = None
        self._xline = None
        self._gather = None

        self.xfd = _segyio.open(filename, mode)

        super(SegyFile, self).__init__()
Esempio n. 3
0
 def writefn(t0, length, step, val):
     val = buffn(val)
     for i, v in itertools.izip(xrange(t0, t0 + step * length, step),
                                val):
         Trace.write_trace(i, v, self)
Esempio n. 4
0
    def trace(self):
        """ Interact with segy in trace mode.

        This mode gives access to reading and writing functionality for traces.
        The primary data type is the numpy ndarray. Traces can be accessed
        individually or with python slices, and writing is done via assignment.

        All examples use `np` for `numpy`.

        Examples:
            Read all traces in file f and store in a list::
                >>> l = [np.copy(tr) for tr in f.trace]

            Do numpy operations on a trace::
                >>> tr = f.trace[10]
                >>> tr = np.transpose(tr)
                >>> tr = tr * 2
                >>> tr = tr - 100
                >>> avg = np.average(tr)

            Do numpy operations on every other trace::
                >>> for tr in f.trace[::2]:
                ...     print( np.average(tr) )
                ...

            Traverse traces in reverse::
                >>> for tr in f.trace[::-1]:
                ...     print( np.average(tr) )
                ...

            Double every trace value and write to disk. Since accessing a trace
            gives a numpy value, to write to the respective trace we need its index::
                >>> for i, tr in enumerate(f.trace):
                ...     tr = tr * 2
                ...     f.trace[i] = tr
                ...

            Reuse an array for memory efficiency when working with indices.
            When using slices or full ranges this is done for you::
                >>> tr = None
                >>> for i in xrange(100):
                ...     tr = f.trace[i, tr]
                ...     tr = tr * 2
                ...     print(np.average(tr))
                ...

            Read a value directly from a file. The second [] is numpy access
            and supports all numpy operations, including negative indexing and
            slicing::
                >>> f.trace[0][0]
                1490.2
                >>> f.trace[0][1]
                1490.8
                >>> f.trace[0][-1]
                1871.3
                >>> f.trace[-1][100]
                1562.0

            Trace mode supports len(), returning the number of traces in a
            file::
                >>> len(f.trace)
                300

            Convenient way for setting traces from 0, 1, ... n, based on the
            iterable set of traces on the right-hand-side.

            If the right-hand-side traces are exhausted before all the destination
            file traces the writing will stop, i.e. not all all traces in the
            destination file will be written.

            Copy traces from file f to file g::
                >>> f.trace = g.trace.

            Copy first half of the traces from g to f::
                >>> f.trace = g.trace[:len(g.trace)/2]

            Fill the file with one trace (filled with zeros)::
                >>> tr = np.zeros(f.samples)
                >>> f.trace = itertools.repeat(tr)
        """

        return Trace(self)
Esempio n. 5
0
 def writefn(t0, length, step, val):
     val = buffn(val)
     step *= len(self.offsets)
     for i, v in zip(range(t0, t0 + step * length, step), val):
         Trace.write_trace(i, v, self)