obspy.core.stream.Stream.write

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

Save stream into a file.

Parameters:
  • filename (str) The name of the file to write.
  • format (str, optional) The file format to use (e.g. "MSEED"). See the Supported Formats section below for a list of supported formats. If format is set to None it will be deduced from file extension, whenever possible.
  • kwargs Additional keyword arguments passed to the underlying waveform writer method.

Example

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

The format argument can be omitted, and the file format will be deduced from file extension, whenever possible.

>>> st.write("example.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 Used Module Linked Function Call
AH obspy.io.ah obspy.io.ah.core._write_ah1()
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()