obspy.io.segy.segy.SEGYTrace

class SEGYTrace(file=None, data_encoding=4, endian='>', unpack_headers=False, filesize=None, headonly=False)[source]

Bases: object

Convenience class that internally handles a single SEG Y trace.

Public Methods

to_obspy_trace

Convert the current Trace to an ObsPy Trace object.

write

Writes the Trace to a file like object.

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

SEGYTrace._create_empty_trace()[source]

Creates an empty trace with an empty header.

SEGYTrace._read_trace(unpack_headers=False, headonly=False)[source]

Reads the complete next header starting at the file pointer at self.file.

Parameters:
  • unpack_headers (bool) – Determines whether or not all headers will be unpacked during reading the file. Has a huge impact on the memory usage and the performance. They can be unpacked on-the-fly after being read. Defaults to False.

  • headonly (bool) – Determines whether or not the actual data records will be read and unpacked. Has a huge impact on memory usage. Data will not be unpackable on-the-fly after reading the file. Defaults to False.

SEGYTrace._repr_pretty_(p, cycle)[source]

Special Methods

SEGYTrace.__delattr__(name, /)

Implement delattr(self, name).

SEGYTrace.__dir__()

Default dir() implementation.

SEGYTrace.__eq__(value, /)

Return self==value.

SEGYTrace.__format__(format_spec, /)

Default object formatter.

SEGYTrace.__ge__(value, /)

Return self>=value.

SEGYTrace.__getattr__(name)[source]

This method is only called if the attribute is not found in the usual places (i.e. not an instance attribute or not found in the class tree for self).

SEGYTrace.__getattribute__(name, /)

Return getattr(self, name).

SEGYTrace.__gt__(value, /)

Return self>value.

SEGYTrace.__hash__()

Return hash(self).

SEGYTrace.__init__(file=None, data_encoding=4, endian='>', unpack_headers=False, filesize=None, headonly=False)[source]

Convenience class that internally handles a single SEG Y trace.

Parameters:
  • file – Open file like object with the file pointer of the beginning of a trace. If it is None, an empty trace will be created.

  • data_encoding

    The data sample format code as defined in the binary file header:

    1:

    4 byte IBM floating point

    2:

    4 byte Integer, two’s complement

    3:

    2 byte Integer, two’s complement

    4:

    4 byte Fixed point with gain

    5:

    4 byte IEEE floating point

    8:

    1 byte Integer, two’s complement

    Defaults to 4.

  • big_endian (bool) – True means the header is encoded in big endian and False corresponds to a little endian header.

  • unpack_headers (bool) – Determines whether or not all headers will be unpacked during reading the file. Has a huge impact on the memory usage and the performance. They can be unpacked on-the-fly after being read. Defaults to False.

  • filesize (int) – Filesize of the file. If not given it will be determined using fstat which is slow.

  • headonly – bool

  • headonly – Determines whether or not the actual data records will be read and unpacked. Has a huge impact on memory usage. Data will not be unpackable on-the-fly after reading the file. Defaults to False.

SEGYTrace.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

SEGYTrace.__le__(value, /)

Return self<=value.

SEGYTrace.__lt__(value, /)

Return self<value.

SEGYTrace.__ne__(value, /)

Return self!=value.

SEGYTrace.__new__(**kwargs)
SEGYTrace.__reduce__()

Helper for pickle.

SEGYTrace.__reduce_ex__(protocol, /)

Helper for pickle.

SEGYTrace.__repr__()

Return repr(self).

SEGYTrace.__setattr__(name, value, /)

Implement setattr(self, name, value).

SEGYTrace.__sizeof__()

Size of object in memory, in bytes.

SEGYTrace.__str__()[source]

Print some information about the trace.

SEGYTrace.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).