Working with Data
This section is a tutorial for tracking and managing SeisBase data.
Creating Data Containers
Create a new, empty object using any of the following commands:
Object | Purpose |
---|---|
SeisChannel() | A single channel of univariate (usually time-series) data |
SeisData() | Multichannel univariate (usually time-series) data |
SeisHdr() | Header structure for discrete seismic events |
SeisEvent() | Discrete seismic events; includes SeisHdr and SeisData objects |
Acquiring Data
- Read files with
read_data<readdata>
- Make web requets with
get_data<getdata>
- Initiate real-time streaming sessions to SeisData objects with
seedlink<seedlink-section>
Keeping Track
A number of auxiliary functions exist to keep track of channels:
SeisBase.findchan
— Functionfindchan(id::String, S::GphysData)
Get all channel indices i
in S with id ∈ S.id[i]
Can do partial id matches, e.g. findchan(S, "UW.") returns indices to all channels whose IDs begin with "UW.".
SeisBase.findid
— Functionfindid(id::String, S::GphysData)
findid(S::GphysData, id::String)
Get the index of the first channel in S where id .== S.id
is true. Returns 0 for failure.
findid(S::GphysData, T::GphysData)
Get index corresponding to the first channel in T that matches each ID in S; equivalent to [findid(id,T) for id in S.id].
findid(C::SeisChannel, S::SeisData)
findid(S::SeisData, C::SeisChannel)
Get the index to the first channel c
in S where S.id[c]==C.id
.
Convention | Characters Removed:sup:¹ |
---|---|
"File" | "$*/:<>?@\^|~DEL |
"HTML" | "&';<>©DEL |
"Julia" | $\DEL |
"Markdown" | !#()*+-.[\]_`{} |
"SEED" | .DEL |
"Strict" | !"#$%&'()*+,-./:;<=>?@[\]^`{|}~DEL |
¹
DEL
here is \x7f (ASCII/Unicode U+007f).
SeisBase.timestamp
— Functiontimestamp()
timestamp(t::DateTime)
timestamp(t::Real)
timestamp(t::String)
Return current time formatted YYYY-mm-ddTHH:MM:SS.
SeisBase.track_off!
— Functionu = track_off!(S::SeisData)
Turn off tracking in S and return a boolean vector of which channels have been added or altered significantly.
SeisBase.track_on!
— Functiontrack_on!(S::SeisData)
Track changes to S.id, changes to channel structure of S, and the sizes of data vectors in S.x. Does not track data processing operations to any channel i unless length(S.x[i]) changes for channel i.
Warning: If you have or suspect gapped data in any channel, do not use ungap! while tracking is active.
Source Logging
The :src field records the last data source used to populate each channel; usually a file name or URL.
When a data source is added to a channel, including the first time data are added, it's also recorded in the :notes field. Use show_src(S, i) to print all data sources for channel S[i] to stdout (see below for details).
Channel Maintenance
A few functions exist specifically to simplify data maintenance:
SeisBase.prune!
— Functionprune!(S::SeisData)
Delete all channels from S that have no data (i.e. S.x is empty or non-existent).
SeisBase.pull
— FunctionT = pull(S::SeisData, id::String)
Extract the first channel with id = id
from S
and return it as a new SeisChannel structure. The corresponding channel in S
is deleted.
T = pull(S::SeisData, i::Union{Integer, UnitRange, Array{In64,1}}
Extract channel i
from S
as a new SeisChannel struct, deleting it from S
.
Taking Notes
Functions that add and process data note these operations in the :notes field of each object affected. One can also add custom notes with the note! command:
SeisBase.note!
— Functionnote!(S::SeisData, i::Int64, s::String)
Append s
with a timestamp to the :notes field of channel number i
of S
.
note!(S::SeisData, id::String, s::String)
As above for the first channel in S
whose id is an exact match to id
.
note!(S::SeisData, s::String)
Append s
to S.notes
and time stamp. If txt
contains a channel name or ID, only the channel mentioned is annotated; otherwise, all channels are annotated.
See also: clear_notes!
, show_processing
, show_src
, show_writes
SeisBase.clear_notes!
— Functionclear_notes!(S::GphysData)
Clear all notes from S
and leaves a note about this.
clear_notes!(S::SeisData, i::Int64, s::String)
Clear all notes from channel i
of S
and leaves a note about this.
clear_notes!(S::SeisData, id::String, s::String)
As above for the first channel in S
whose id is an exact match to id
.
See also: note!
, show_processing
, show_src
Checking Your Work
If you need to check what's been done to a channel, or the sources present in the channel data, these commands are helpful:
SeisBase.show_processing
— Functionshow_processing(S::GphysData)
show_processing(S::GphysData, i::Int64)
show_processing(C::GphysChannel)
Tabulate and print all processing steps in :notes
to stdout in human-readable format.
See also: show_src
, show_writes
, note!
, clear_notes!
SeisBase.show_src
— Functionshow_src(S::GphysData)
show_src(S::GphysData, i::Int64)
show_src(C::GphysChannel)
Tabulate and print all data sources logged in :notes
to stdout in human-readable format.
See also: show_processing
, show_writes
, note!
, clear_notes!
SeisBase.show_writes
— Functionshow_writes(S::GphysData)
show_writes(S::GphysData, i::Int64)
show_writes(C::GphysChannel)
Tabulate and print all data writes logged in :notes
to stdout in human-readable format.
See also: show_processing
, show_src
, note!
, clear_notes!