spectrumMetric2Xml: Convert a SpectrumMetric into XML for the BSS

View source: R/Class-Metric.R

spectrumMetric2XmlR Documentation

Convert a SpectrumMetric into XML for the BSS

Description

The spectrumMetric2Xml function converts a SpectrumMetric into an XML structure appropriate for submitting to the MUSTANG Backend Storage System (BSS).

Usage

spectrumMetric2Xml(metricList)

Arguments

metricList

a list of SpectrumMetric objects

Value

A character string with BSS formatted XML is returned.

Author(s)

Jonathan Callahan jonathan@mazamascience.com

Examples

  ## Not run: 
# 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)
  
## End(Not run)

IRISMustangMetrics documentation built on April 28, 2022, 1:06 a.m.