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

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

  • 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 {‘little’, ‘big’}, optional) Desired output byte order. 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.



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.