if (FALSE) {
# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")
# NOTE: The following trace has 1.728 million points.
# NOTE: Downloading and calculating PSD may take a while.
starttime <- as.POSIXct("2010-02-27",tz="GMT")
endtime <- as.POSIXct("2010-02-28",tz="GMT")
# Get the waveform
st <- getDataselect(iris,"IU","ANMO","00","BHZ",starttime,endtime)
# Make sure we're working with a single snclq
unique_ids <- uniqueIds(st)
if (length(unique_ids) > 1) {
stop(paste("PSDMetric: Stream has",unique_ids,"unique identifiers"))
}
snclq <- unique_ids[1]
# Calculate and plot the Power Spectral Density
psdList <- psdList(st)
# Create a Spectrum metric list
spectrumMetricList <- list()
index <- 1
for (psd in psdList) {
spectrumMetricList[[index]] <- new("SpectrumMetric", snclq=snclq,
starttime=psd$starttime, endtime=psd$endtime,
metricName="psd", freqs=psd$freq,
amps=psd$spec, phases=psd$freq*0)
index <- index + 1
}
# Show the XML version of the metric
bssXml <- spectrumMetric2Xml(spectrumMetricList)
cat(bssXml)
}
Run the code above in your browser using DataLab