Write Suppport
The table below sumamrizes the current write options for SeisBase. Each function is described in detail in this chapter.
Structure/Description | Output Format | Function |
---|---|---|
GphysChannel | ASDF | write_hdf5 |
GphysChannel | SAC timeseries | writesac |
GphysChannel channel metadata | StationXML | write_sxml |
GphysChannel instrument response | SAC polezero | writesacpz |
GphysData | ASDF | write_hdf5 |
GphysData | SAC timeseries | writesac |
GphysData channel metadata | StationXML | write_sxml |
GphysData instrument response | SAC polezero | writesacpz |
SeisEvent | ASDF | write_hdf5 |
SeisEvent header and source info | ASDF QuakeML | asdf_wqml |
SeisEvent header and source info | QuakeML | write_qml |
SeisEvent trace data only | SAC timeseries | writesac |
Array{SeisEvent, 1} | ASDF QuakeML | asdf_wqml |
Array{SeisHdr, 1} | QuakeML | write_qml |
Array{SeisHdr, 1}, Array{SeisSrc, 1} | ASDF QuakeML | asdf_wqml |
Array{SeisHdr, 1}, Array{SeisSrc, 1} | QuakeML | write_qml |
SeisHdr | QuakeML | write_qml |
SeisHdr, SeisSrc | ASDF QuakeML | asdf_wqml |
SeisHdr, SeisSrc | QuakeML | wqml |
any SeisBase structure | SeisBase file | wseis |
primitive data type or array | ASDF AuxiliaryData | asdf_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_hdf5
— Functionwrite_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
KW | Type | Default | Meaning |
---|---|---|---|
add | Bool | false | Add new traces to file as needed? |
chans | ChanSpec | 1:S.n | Channels to write to file |
len | Period | Day(1) | Length of new traces added to file |
ovr | Bool | false | Overwrite data in existing traces? |
tag | String | "" | Tag for trace names in ASDF volumes |
v | Integer | 0 | verbosity |
SeisEvent
KW | Type | Default | Meaning |
---|---|---|---|
chans | ChanSpec | 1:S.data.n | Channels to write to file |
tag | String | "" | Tag for trace names in ASDF volumes |
v | Integer | 0 | verbosity |
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:
- Determine times of all data in
S[chans]
and all traces in "Waveforms/". - If data lie outside existing trace bounds, new traces are initialized.
- 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 inS
,hdf_out
isn't modified. - In ASDF format, station XML is merged in channels that are partly overwritten.
add=true
/ovr=true
changes :t
on file to begin at an exact sample time.
See also: read_hdf5
QuakeML
SeisBase.Quake.write_qml
— Functionwrite_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
.
To write data from R ∈ SSRC
, it must be true that R.eid == H.id
for some H ∈ SHDR
.
SAC
SeisBase.writesac
— Functionwritesac(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.
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.
SeisBase.writesacpz
— Functionwritesacpz(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
.
SeisBase Native
SeisBase.wseis
— Functionwseis(fname, S)
Write SeisBase objects S to file. S can be a single object, multiple comma-delineated objects, or an array of objects.
Station XML
SeisBase.write_sxml
— Functionwrite_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.