setupDB: Set up a seismic data base

View source: R/setupDB.R

setupDBR Documentation

Set up a seismic data base

Description

Set up a data base storing the location and times for a set of seismic data.

Usage

setupDB(DB, token = TRUE, split = "\\.")

Arguments

DB
fn

full path to file

yr

year

jd

julian day

hr

hour

mi

minute

sec

second

dur

duration, seconds

origyr

origin time for epoch calculations

token

logical, use tokens in the file names of the fn's to extract station and component names for selection. default=TRUE

split

character string to split if using token, default is a period.

Details

If token is FALSE, then the station name and component are selected using substr, i.e. by column number.

Value

DB with epoch time and station information appended,

t1

epoch start time

t2

expoch end time = t1+nsamps*sample rate n seconds

sta

station

comp

component

Note

Program attaches station identification used for grepping.

Author(s)

Jonathan M. Lees<jonathan.lees@unc.edu>

See Also

EPOCHday, T12.pix, Mine.seis

Examples



##########  to illustrate, we make a set of individual seismograms
data(GH)
L1 = length(GH$JSTR)
DD = data.frame(GH$info)

GIVE = vector(mode='list')

for(i in 1:L1)
{
AA = DD[i,]
GIVE[[i]] = list(fn = AA$fn, sta =GH$STNS[i] , comp = GH$COMP[i], 
            dt = AA$dt, DATTIM = AA, N = AA$n1, units = NA, 
            coords = NA, amp = GH$JSTR[[i]]  )
}

###########  save the seismic data in a temporary directory
####   each trace in a separate file
tdir = tempdir()
for(i in 1:length(GIVE) )
{
    sig = GIVE[[i]]
  d1 =  dateStamp(sig$DATTIM)
   nam1 =  paste(d1,sig$sta, sig$comp, sep='_')
    nam2 = paste0(nam1, '.RDS')
    nam3 = paste(tdir, nam2, sep='/')
    saveRDS(file=nam3, sig) 
    }

########################  Now  read files and make the DataBase:
LF  = list.files(path=tdir,  pattern='.RDS', full.names=TRUE)
DB = FmakeDB(LF, kind=-1)
## IDB = infoDB(DB)

plotDB(DB)




RSEIS documentation built on Sept. 13, 2024, 1:09 a.m.