obspy.core.stream.Stream.write

Stream.write(filename, format, **kwargs)[source]

Save stream into a file.

Parameters:
  • filename (str) The name of the file to write.
  • format (str) The file format to use (e.g. "MSEED"). See the Supported Formats section below for a list of supported formats.
  • kwargs Additional keyword arguments passed to the underlying waveform writer method.

Example

>>> from obspy import read
>>> st = read()  
>>> st.write("example.mseed", format="MSEED")  

Writing single traces into files with meaningful filenames can be done e.g. using trace.id

>>> for tr in st: 
...     tr.write(tr.id + ".MSEED", format="MSEED") 

Supported Formats

Additional ObsPy modules extend the parameters of the write() method. The following table summarizes all known formats currently available for ObsPy.

Please refer to the Linked Function Call of each module for any extra options available.

Format Required Module Linked Function Call
GSE2 obspy.io.gse2 obspy.io.gse2.core._write_gse2()
MSEED obspy.io.mseed obspy.io.mseed.core._write_mseed()
PICKLE obspy.core.stream obspy.core.stream._write_pickle()
Q obspy.io.sh obspy.io.sh.core._write_q()
SAC obspy.io.sac obspy.io.sac.core._write_sac()
SACXY obspy.io.sac obspy.io.sac.core._write_sac_xy()
SEGY obspy.io.segy obspy.io.segy.core._write_segy()
SH_ASC obspy.io.sh obspy.io.sh.core._write_asc()
SLIST obspy.io.ascii obspy.io.ascii.core._write_slist()
SU obspy.io.segy obspy.io.segy.core._write_su()
TSPAIR obspy.io.ascii obspy.io.ascii.core._write_tspair()
WAV obspy.io.wav obspy.io.wav.core._write_wav()