_write_segy(stream, filename, data_encoding=None, byteorder=None, textual_header_encoding=None, **kwargs)[source]

Writes a SEG Y file from given ObsPy Stream object.


This function should NOT be called directly, it registers via the the write() method of an ObsPy Stream object, call this instead.

  • stream (Stream) – The ObsPy Stream object to write.

  • filename (str) – Name of file to write.

  • data_encoding (int) –

    The data encoding is an integer with the following currently supported meaning:


    4 byte IBM floating points (float32)


    4 byte Integers (int32)


    2 byte Integer (int16)


    4 byte IEEE floating points (float32)

    The value in the brackets is the necessary dtype of the data. ObsPy will now automatically convert the data because data might change/loose precision during the conversion so the user has to take care of the correct dtype.

    If it is None, the value of the first Trace will be used for all consecutive Traces. If it is None for the first Trace, 1 (IBM floating point numbers) will be used. Different data encodings for different traces are currently not supported because these will most likely not be readable by other software.

  • byteorder (str or None) – Determines the endianness of the file. Either '>' for big endian or '<' for little endian. If is None, it will either be the endianness of the first Trace or if that is also not set, it will be big endian. A mix between little and big endian for the headers and traces is currently not supported.

  • textual_header_encoding (str or None) – The encoding of the textual header. Can be 'EBCDIC', 'ASCII' or None. If it is None, the textual_file_header_encoding attribute in the stats.segy dictionary of the first Trace is used and if that is not set, ASCII will be used.

This function will automatically set the data encoding field of the binary file header so the user does not need to worry about it.

The starttime of every trace is not a required field in the SEG Y specification. If the starttime of a trace is UTCDateTime(0) it will be interpreted as a not-set starttime and no time is written to the trace header. Every other time will be written.

SEG Y supports a sample interval from 1 to 65535 microseconds in steps of 1 microsecond. Larger intervals cannot be supported due to the definition of the SEG Y format. Therefore the smallest possible sampling rate is ~ 15.26 Hz. Please keep that in mind.