obspy.io.segy.segy.SUFile

class SUFile(file=None, endian=None, unpack_headers=False, headonly=False, read_traces=True)[source]

Bases: object

Convenience class that internally handles Seismic Unix data files. It currently can only read IEEE 4 byte float encoded SU data files.

Public Methods

write

Write a SU Y file to file which is either a file like object with a write method or a filename string.

Private Methods

Warning

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

SUFile._autodetect_endianness()[source]

Tries to automatically determine the endianness of the file at hand.

SUFile._create_empty_su_file_object()[source]

Creates an empty SUFile object.

SUFile._read_traces(unpack_headers=False, headonly=False, yield_each_trace=False)[source]

Reads the actual traces starting at the current file pointer position to the end of the file.

Parameters
  • unpack_header (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 unpacked. Useful if one is just interested in the headers. Data will not be unpackable on-the-fly after reading the file. Defaults to False.

  • yield_each_trace (bool) – If True, it will yield each trace after it has been read. This enables a simple implementation of a streaming interface to read SEG-Y files. Read traces will no longer be collected in self.traces list if this is set to True.

SUFile._repr_pretty_(p, cycle)[source]
SUFile._write(file, endian=None)[source]

Write a SU Y file to file which is either a file like object with a write method or a filename string.

If endian is set it will be enforced.

Special Methods

SUFile.__delattr__(name, /)

Implement delattr(self, name).

SUFile.__dir__()

Default dir() implementation.

SUFile.__eq__(value, /)

Return self==value.

SUFile.__format__(format_spec, /)

Default object formatter.

SUFile.__ge__(value, /)

Return self>=value.

SUFile.__getattribute__(name, /)

Return getattr(self, name).

SUFile.__gt__(value, /)

Return self>value.

SUFile.__hash__()

Return hash(self).

SUFile.__init__(file=None, endian=None, unpack_headers=False, headonly=False, read_traces=True)[source]
Parameters
  • file – A file like object with the file pointer set at the beginning of the SEG Y file. If file is None, an empty SEGYFile object will be initialized.

  • endian – The endianness of the file. If None, autodetection will be used.

  • unpack_header (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.

  • read_traces (bool) – Data traces will only be read if this is set to True. The data will be completely ignored if this is set to False.

SUFile.__init_subclass__()

This method is called when a class is subclassed.

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

SUFile.__le__(value, /)

Return self<=value.

SUFile.__lt__(value, /)

Return self<value.

SUFile.__ne__(value, /)

Return self!=value.

SUFile.__new__(**kwargs)
SUFile.__reduce__()

Helper for pickle.

SUFile.__reduce_ex__(protocol, /)

Helper for pickle.

SUFile.__repr__()

Return repr(self).

SUFile.__setattr__(name, value, /)

Implement setattr(self, name, value).

SUFile.__sizeof__()

Size of object in memory, in bytes.

SUFile.__str__()[source]

Prints some information about the SU file.

SUFile.__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).