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 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
MSEED obspy.mseed obspy.mseed.core.writeMSEED()
SAC obspy.sac obspy.sac.core.writeSAC()
GSE2 obspy.gse2 obspy.gse2.core.writeGSE2()
SACXY obspy.sac obspy.sac.core.writeSACXY()
Q obspy.sh obspy.sh.core.writeQ()
SH_ASC obspy.sh obspy.sh.core.writeASC()
SLIST obspy.core obspy.core.ascii.writeSLIST()
TSPAIR obspy.core obspy.core.ascii.writeTSPAIR()
SEGY obspy.segy obspy.segy.core.writeSEGY()
SU obspy.segy obspy.segy.core.writeSU()
WAV obspy.wav obspy.wav.core.writeWAV()
PICKLE obspy.core obspy.core.stream.writePickle()

This Page