obspy.io.segy.segy.iread_su

iread_su(file, endian=None, unpack_headers=False, headonly=False)[source]

Iteratively read a SU field and yield single ObsPy Traces.

The function iteratively loops over the whole file and yields single ObsPy Traces. The next Trace will be read after the current loop has finished - this function is thus suitable for reading arbitrarily large SU files without running into memory problems.

>>> from obspy.core.util import get_example_file
>>> filename = get_example_file("1.su_first_trace")
>>> from obspy.io.segy.segy import iread_su
>>> for tr in iread_su(filename):
...     # Each Trace's stats attribute will have some file-wide
...     # information.
...     de = tr.stats.su.data_encoding
...     e = tr.stats.su.endian
...     # Also do something meaningful with each Trace.
...     print(int(tr.data.sum()))
-26121
Parameters:
  • file – Open file like object or a string which will be assumed to be a filename.

  • endian (str) – String that determines the endianness of the file. Either ‘>’ for big endian or ‘<’ for little endian. If it is None, obspy.io.segy will try to autodetect the endianness. The endianness is always valid for the whole file.

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