obspy.core.stream.Stream.write

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

Saves stream into a file.

Parameters:
  • filename (string) The name of the file to write.
  • format (string) The format to write must be specified. One of "MSEED", "GSE2", "SAC", "SACXY", "Q", "SH_ASC", "SEGY", "SU", "WAV", "PICKLE". See the Supported Formats section below for a full 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("%s.MSEED" % tr.id, 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
MSEED obspy.mseed obspy.mseed.core.writeMSEED()
GSE2 obspy.gse2 obspy.gse2.core.writeGSE2()
SAC obspy.sac obspy.sac.core.writeSAC()
SACXY obspy.sac obspy.sac.core.writeSACXY()
Q obspy.sh obspy.sh.core.writeQ()
SH_ASC obspy.sh obspy.sh.core.writeASC()
SEGY obspy.segy obspy.segy.core.writeSEGY()
SLIST obspy.core obspy.core.ascii.writeSLIST()
SU obspy.segy obspy.segy.core.writeSU()
TSPAIR obspy.core obspy.core.ascii.writeTSPAIR()
WAV obspy.wav obspy.wav.core.writeWAV()
PICKLE obspy.core obspy.core.stream.readPickle()

This Page