Learn R Programming

IRISMustangMetrics (version 1.0.0)

getSingleValueMetrics: Retrieve measurements from the MUSTANG BSS

Description

The getSingleValueMetrics method of the IrisClient makes a request of the MUSTANG database and returns a dataframe containing metrics that are stored as single values, e.g. sample_max, sample_min, etc..

Usage

getSingleValueMetrics(obj, network, station, location, channel, 
                           starttime, endtime, metricName, constraint, url)

Arguments

obj
an IrisClient object
network
a character string with the two letter seismic network code
station
a character string with the station code
location
a character string with the location code
channel
a character string with the three letter channel code
starttime
a POSIXct class specifying the starttime (GMT)
endtime
a POSIXct class specifying the endtime (GMT)
metricName
a character string containing one or more comma separated metric names
constraint
a character string containing value constraints
url
optional url of the MUSTANG measurements service

Value

  • A dataframe with the following columns:

    ~metricName~, value, snclq, starttime, endtime, loadtime

    The loadtime column contains the time at which this record was loaded into the database.

    The dataframe rows will be sorted by increasing starttime.

    The structure of this dataframe is appropriate for use with the ggplot2 plotting package.

Details

The default MUSTANG measurement service when url is not specified is:

http://service.iris.edu/mustang/measurements/1/query?

Data returned from MUSTANG are converted into an Rdataframe

The optional constraint parameter is used to add constraints to the query as defined in the href{http://service.iris.edu/mustang/measurements/1}{MUSTANG measurements web serivce documentation}. Any string passed in with the constraint parameter will be appended to the request url following an ampersand.

Error returns from the BSS will stop evaluation and generate an error message.

See Also

createBssUrl, getPsdMetrics

Examples

Run this code
# Open a connection to IRIS DMC webservices (including the BSS)
iris <- new("IrisClient", debug=TRUE)

starttime <- as.POSIXct("2013-06-01", tz="GMT")
endtime <- starttime + 30*24*3600
metricName <- "sample_max,sample_min,sample_mean"

# Get the measurement dataframe
juneStats <- getSingleValueMetrics(iris,"IU","ANMO","00","BHZ",
                                        starttime,endtime,metricName)

# Simple ggplot2 plot
library(ggplot2)
p <- ggplot(juneStats, aes(x=starttime,y=value, color=as.factor(metricName))) +
     geom_step()
print(p)

Run the code above in your browser using DataLab