Last data update: 2014.03.03

R: Gap analysis
getGapsR Documentation

Gap analysis

Description

The getGaps method calculates data dropouts that occur within the requested time range associated with a Stream.

A Stream object returned by getDataselect contains a list of individual Trace objects, each of which is guaranteed to contain a continuous array of data in each Trace@data slot. Each TraceHeader also contains a starttime and an endtime defining a period of uninterrupted data collection.

Data dropouts are determined by examining the requestedStartime and requestedEndtime slots associated with the Stream and the starttime and endtime slots found in the each TraceHeader.

Usage

getGaps(x, min_gap)

Arguments

x

Stream object

min_gap

minimum gap (sec) below which gaps will be ignored (default=1/sampling_rate)

Details

This method first checks the SNCL id of each Trace to make sure they are identical and generates an error if they are not. Mismatches in the sampling_rate will also generate an error.

The data gaps (in seconds) within a Stream are determined and the associated sampling_rate is used to calculate the number of missing values in each gap. The length of the gaps and nsamples vectors in the returned list will be one more than the number of Traces (inital gap + gaps between traces + final gap).

Gaps smaller than min_gap are set to 0. Values of min_gap smaller than 1/sampling_rate will be ignored and the default value will be used instead.

Overlaps will appear as gaps with negative values.

Value

A list is returned with the following elements:

  • gaps numeric vector of data gaps within a Stream

  • nsamples number of missing samples associated with each gap

Author(s)

Jonathan Callahan jonathan.s.callahan@gmail.com

Examples

# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")

starttime <- as.POSIXct("2012-01-24", tz="GMT")
endtime <- as.POSIXct("2012-01-25", tz="GMT")

# Get the waveform
st <- getDataselect(iris,"AK","PIN","","VEA",starttime,endtime)

# Save the gap analysis in a variable
gapInfo <- getGaps(st)

# See what information is availble
names(gapInfo)

# Look at a histogram of data dropouts
hist(gapInfo$nsamples, breaks=50, 
     main="Data Gaps in AK.PIN..VEA during Jan 24, 2012",
     xlab="number of missing samples per gap")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IRISSeismic)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IRISSeismic/getGaps.Rd_%03d_medium.png", width=480, height=480)
> ### Name: getGaps
> ### Title: Gap analysis
> ### Aliases: getGaps getGaps,Stream,missing-method
> ###   getGaps,Stream,numeric-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> # Open a connection to IRIS DMC webservices
> iris <- new("IrisClient")
> 
> starttime <- as.POSIXct("2012-01-24", tz="GMT")
> endtime <- as.POSIXct("2012-01-25", tz="GMT")
> 
> # Get the waveform
> st <- getDataselect(iris,"AK","PIN","","VEA",starttime,endtime)
> 
> # Save the gap analysis in a variable
> gapInfo <- getGaps(st)
> 
> # See what information is availble
> names(gapInfo)
[1] "gaps"     "nsamples"
> 
> # Look at a histogram of data dropouts
> hist(gapInfo$nsamples, breaks=50, 
+      main="Data Gaps in AK.PIN..VEA during Jan 24, 2012",
+      xlab="number of missing samples per gap")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>