obspy.io.sac.arrayio.write_sac

write_sac(dest, hf, hi, hs, data=None, byteorder=None)[source]

Write the header and (optionally) data arrays to a SAC binary file.

Parameters
  • dest (str or file) – Full path or File-like object to SAC binary file on disk.

  • hf (numpy.ndarray of floats) – SAC float header array

  • hi (numpy.ndarray of ints) – SAC int header array

  • hs (numpy.ndarray of str) – SAC string header array

  • data (numpy.ndarray of float32) – SAC data array, optional. If omitted or None, it is assumed that the user intends to overwrite/modify only the header arrays of an existing file. Equivalent to SAC’s “writehdr”.

  • byteorder (str, optional) – Desired output byte order {‘little’, ‘big’}. If omitted, arrays are written as they are. If data=None, better make sure the file you’re writing to has the same byte order as headers you’re writing.

Returns

None

Notes

A user can/should not _create_ a header-only binary file. Use mode ‘wb+’ for data=None (headonly) writing to just write over the header part of an existing binary file with data in it.