Write Suppport

The table below sumamrizes the current write options for SeisBase. Each function is described in detail in this chapter.

Structure/DescriptionOutput FormatFunction
GphysChannelASDFwrite_hdf5
GphysChannelSAC timeserieswritesac
GphysChannel channel metadataStationXMLwrite_sxml
GphysChannel instrument responseSAC polezerowritesacpz
GphysDataASDFwrite_hdf5
GphysDataSAC timeserieswritesac
GphysData channel metadataStationXMLwrite_sxml
GphysData instrument responseSAC polezerowritesacpz
SeisEventASDFwrite_hdf5
SeisEvent header and source infoASDF QuakeMLasdf_wqml
SeisEvent header and source infoQuakeMLwrite_qml
SeisEvent trace data onlySAC timeserieswritesac
Array{SeisEvent, 1}ASDF QuakeMLasdf_wqml
Array{SeisHdr, 1}QuakeMLwrite_qml
Array{SeisHdr, 1}, Array{SeisSrc, 1}ASDF QuakeMLasdf_wqml
Array{SeisHdr, 1}, Array{SeisSrc, 1}QuakeMLwrite_qml
SeisHdrQuakeMLwrite_qml
SeisHdr, SeisSrcASDF QuakeMLasdf_wqml
SeisHdr, SeisSrcQuakeMLwqml
any SeisBase structureSeisBase filewseis
primitive data type or arrayASDF AuxiliaryDataasdf_waux

Methods for SeisEvent, SeisHdr, or SeisSrc are part of submodule SeisBase.Quake. asdf_waux and asdf_wqml are part of SeisBase.SeisHDF.

Write Functions

Functions are organized by file format.

HDF5/ASDF

SeisBase.SeisHDF.write_hdf5Function
write_hdf5( hdf_out::String, S::GphysData[, KWs] )

Write data to file hdf_out from structure S in a seismic HDF5 format.

write_hdf5( hdf_out::String, W::SeisEvent[, KWs] )

Write data to file hdf_out from structure W in a seismic HDF5 format. If the format doesn't record event header and source info, only W.data is stored.

Keywords

GphysData

KWTypeDefaultMeaning
addBoolfalseAdd new traces to file as needed?
chansChanSpec1:S.nChannels to write to file
lenPeriodDay(1)Length of new traces added to file
ovrBoolfalseOverwrite data in existing traces?
tagString""Tag for trace names in ASDF volumes
vInteger0verbosity

SeisEvent

KWTypeDefaultMeaning
chansChanSpec1:S.data.nChannels to write to file
tagString""Tag for trace names in ASDF volumes
vInteger0verbosity

Write Methods

Add (add = true)

This KW determines the start and end times of all data in chans, and initializes new traces (filled with NaNs) of length = len.

ASDF behavior

Mode add=true follows these steps in this order:

  1. Determine times of all data in S[chans] and all traces in "Waveforms/".
  2. If data lie outside existing trace bounds, new traces are initialized.
  3. For each segment in S[chans]:
  • Merge the header data in S[chans] into the relevant station XML.
  • Overwrite part of the relevant trace in Waveforms/.

Thus, unless len exactly matches the time boundaries of each segment in S, the traces created will be intentionally larger.

Overwrite (ovr = true)

If ovr=true is specified, but add=false, write_hdf5 only overwrites existing data in hdf_out.

  • No new trace data objects are created in hdf_out.
  • No new file is created. If hdf_out doesn't exist, nothing happens.
  • If no traces in hdf_out overlap segments in S, hdf_out isn't modified.
  • In ASDF format, station XML is merged in channels that are partly overwritten.
Warning

add=true/ovr=true changes :t on file to begin at an exact sample time.

See also: read_hdf5

source

QuakeML

SeisBase.Quake.write_qmlFunction
write_qml(fname, Ev::SeisEvent; v::Integer=0)

Write event metadata from SeisEvent Ev to file fname.

write_qml(fname, SHDR::SeisHdr; v::Integer=0)
write_qml(fname, SHDR::Array{SeisHdr,1}; v::Integer=0)

Write QML to file fname from SHDR.

If fname exists, and is QuakeML, SeisBase appends the existing XML. If the file exists, but is NOT QuakeML, an error is thrown; the file isn't overwritten.

write_qml(fname, SHDR::SeisHdr, SSRC::SeisSrc; v::Integer=0)
write_qml(fname, SHDR::Array{SeisHdr,1}, SSRC::Array{SeisSrc,1}; v::Integer=0)

Write QML to file fname from SHDR and SSRC.

Warning

To write data from R ∈ SSRC, it must be true that R.eid == H.id for some H ∈ SHDR.

source

SAC

SeisBase.writesacFunction
writesac(S::Union{GphysData,GphysChannel}[, chans, nvhdr=6, fname="", v=0])

Write all data in SeisData structure S to auto-generated SAC files.

With any GphysChannel subtype, specifying fname = FF sets the filename to FF.

Keywords:

  • chans="CC" writes data from ChanSpec CC (GphysData only)
  • fname="FF" uses filename FF (GphysChannel only)
  • nvhdr is SAC NVHDR, the file header version (6 or 7). Default is 6.
  • v is verbosity.
source
writesac(W::SeisEvent[, v=0])

Write all data in SeisEvent structure W to auto-generated SAC files. Event header information is written from W.hdr; W.source is not used as there is no standard header position for event source information.

source
SeisBase.writesacpzFunction
writesacpz(pzfile::String, S::GphysData[, chans::ChanSpec=CC])

Write fields from SeisBase struct S into sacpz file pzfile. Uses information from fields :fs, :gain, :loc, :misc, :name, :resp, :units. Specify chans=CC to only write channels CC.

source

SeisBase Native

SeisBase.wseisFunction
wseis(fname, S)

Write SeisBase objects S to file. S can be a single object, multiple comma-delineated objects, or an array of objects.

source

Station XML

SeisBase.write_sxmlFunction
write_sxml(fname::String, S::GphysData[, chans=Cha])
write_sxml(fname::String, C::GphysChannel)

Write station XML from the fields of S or C to file fname.

Use keyword chans=Cha to restrict station XML write to Cha. This keyword can accept an Integer, UnitRange, or Array{Int64,1} as its argument.

source