sacfiles: Read a SAC binary file

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Loads SAC (Seismic Analysis Code) data files [1], stored as either ASCII or binary format.

From [2]: [SAC] files contain a fixed length header section followed by one or two data sections. The header contains floating point, integer, logical, and character fields. Evenly spaced data files have only one data section which contains the dependent variable. Unevenly spaced data and spectral data files contain two data sections. For unevenly spaced data, the first data section contains the dependent variable and the second contains the independent variable. For spectral files the first component is either the amplitude or the real component and the second component is either the phase or imaginary component.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
read.sac(files, is.binary, endianness = c("auto", "little", "big"), ...)

.sacreader.asc(fi, na.value = c("-12345", "-12345.00"), amp.as.ts = TRUE)

.sacreader.bin(fi, endianness = c("little", "big"), na.value = -12345,
  amp.as.ts = TRUE)

## S3 method for class 'saclist'
c(..., recursive = FALSE)

## S3 method for class 'sac'
print(x, ...)

## S3 method for class 'saclist'
print(x, ...)

## S3 method for class 'saclist'
summary(object, ...)

## S3 method for class 'summary.saclist'
print(x, ...)

## S3 method for class 'saclist'
str(object, ...)

## S3 method for class 'saclist'
plot(x, ncol = 1, stat.annotate = TRUE, trim = 0,
  rel.time = NULL, apply.calib = TRUE, ...)

fstart(x, relative = FALSE)

## S3 method for class 'sac'
fstart(x, relative = NULL)

## S3 method for class 'saclist'
fstart(x, relative = FALSE)

sacunits(x)

## S3 method for class 'sac'
sacunits(x)

## S3 method for class 'saclist'
sacunits(x)

sync(x)

## S3 method for class 'saclist'
sync(x)

summaryStats(x, trim = 0, rel.time = NULL)

## S3 method for class 'sac'
summaryStats(x, trim = 0, rel.time = NULL)

## S3 method for class 'saclist'
summaryStats(x, trim = 0, rel.time = NULL)

Arguments

files

character; the file(s) to read in

is.binary

logical; are the sac files in files binary or ASCII?

endianness

character; specify the endianness of file. 'auto' uses the platform value, or 'little' and 'big' can be used to force a specific structure.

...

additional parameters; For read.sac: additional objects to the sac reader; for c.saclist: the objects to concatenate

fi

character; a single filename

na.value

the NA representation

amp.as.ts

logical; should the amplitudes be converted to a 'ts' object?

recursive

logical; From c: If recursive = TRUE, the function recursively descends through lists (and pairlists) combining all their elements into a vector.

x

an object to operate on.

object

an object to operate on.

ncol

numeric; the number of columns in the plot layout

stat.annotate

logical; should statistical annotations be shown?

trim

numeric; the fraction of data to trim from the start and end of the amplitude record for the statistical summary. Can be a two-length vector, but must be within [0,0.5].

rel.time

POSIXct; report the number of seconds relative to this

apply.calib

logical; should the calibration factor in the sac header be applied?

relative

logical; should the start times be relative to the minimum of the group?

Details

The ASCII reader (.sacreader.asc) is simply a series of read.table calls, and the binary reader (.sacreader.bin) uses readBin with the specified endianness.

Utility functions

sync: From documentation in the last available version of Rsac: Synchronizes the reference times of all files in a vector of SAC files. [...] This is useful if you are sending each file to a different plot but want the relative time to be consistent between the different plots.

sacunits: From documentation in the last available version of Rsac: Looks up the units of the [amplitudes in the] SAC record. The units in many seismic headers are notoriously unreliable, so care should be taken to find an independent source to confirm the units.

fstart: From documentation in the last available version of Rsac: Calculates the starting time [of the SAC data].

Value

A list of lists, with class 'saclist', where each item corresponds to the contents of each entry in files, each with class 'sac'.

Author(s)

A.J. Barbour modified code from the (now defunct) package Rsac, written originally by E.M. Thompson.

References

[1] http://www.iris.edu/software/sac/

[2] http://www.iris.edu/files/sac-manual/

See Also

irisws-package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
##
## Methods for .sac data
##
#
# Load pore pressure at B084 during the El Majoy Cucapah earthquake:
#
sacfi <- system.file("sac/elmayorB084_LDD.sac", package="irisws")
#   this is a little-endian sac file, so
#   must specify (your system may be 'big'!)
x1 <- read.sac(sacfi, is.binary=TRUE, endianness="little")
#   returns an object of class 'saclist'
plot(x1)
##
## SAC ASCII reader
##
sacascfi <- system.file("sac/elmayorB084_LDD.txt", package="irisws")
x2 <- read.sac(sacascfi, is.binary=FALSE)
plot(x2)  
all.equal(x1[1]$amp, x2[1]$amp) # they are equal, as expected
#
# Can also load a series of files:
#
sacfis <- rep(sacfi, 3)
x3 <- read.sac(sacfis, is.binary=TRUE, endianness="little")
plot(x3) # now there are three frames in the plot (all the same data, obviously)
#
# Utilities
#
c(x1)
sacunits(x1)


## End(Not run)

abarbour/irisws documentation built on May 10, 2019, 4:07 a.m.