obspy.io.segy.segy.SEGYFile
- class SEGYFile(file=None, endian=None, textual_header_encoding=None, unpack_headers=False, headonly=False, read_traces=True)[source]
Bases:
object
Class that internally handles SEG Y files.
Public Methods
Write a SEG 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.
- SEGYFile._autodetect_endianness()[source]
Tries to automatically determine the endianness of the file at hand.
- SEGYFile._read_headers()[source]
Reads the textual and binary file headers starting at the current file pointer position.
- SEGYFile._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_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.
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 toTrue
.
- SEGYFile._write(file, data_encoding=None, endian=None)[source]
Writes SEG Y to a file like object.
If data_encoding or endian is set, these values will be enforced.
- SEGYFile._write_textual_header(file)[source]
Write the textual header in various encodings. The encoding will depend on self.textual_header_encoding. If self.textual_file_header is too small it will be padded with zeros. If it is too long or an invalid encoding is specified an exception will be raised.
Special Methods
- SEGYFile.__delattr__(name, /)
Implement delattr(self, name).
- SEGYFile.__dir__()
Default dir() implementation.
- SEGYFile.__eq__(value, /)
Return self==value.
- SEGYFile.__format__(format_spec, /)
Default object formatter.
- SEGYFile.__ge__(value, /)
Return self>=value.
- SEGYFile.__getattribute__(name, /)
Return getattr(self, name).
- SEGYFile.__gt__(value, /)
Return self>value.
- SEGYFile.__hash__()
Return hash(self).
- SEGYFile.__init__(file=None, endian=None, textual_header_encoding=None, unpack_headers=False, headonly=False, read_traces=True)[source]
Class that internally handles SEG Y files.
- 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.
textual_header_encoding – The encoding of the textual header. Either ‘EBCDIC’, ‘ASCII’ or None. If it is None, autodetection will be attempted. If it is None and file is also None, it will default to ‘ASCII’.
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. 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 toFalse
.
- SEGYFile.__init_subclass__()
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- SEGYFile.__le__(value, /)
Return self<=value.
- SEGYFile.__lt__(value, /)
Return self<value.
- SEGYFile.__ne__(value, /)
Return self!=value.
- SEGYFile.__new__(**kwargs)
- SEGYFile.__reduce__()
Helper for pickle.
- SEGYFile.__reduce_ex__(protocol, /)
Helper for pickle.
- SEGYFile.__repr__()
Return repr(self).
- SEGYFile.__setattr__(name, value, /)
Implement setattr(self, name, value).
- SEGYFile.__sizeof__()
Size of object in memory, in bytes.
- SEGYFile.__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).