Package edu.sc.seis.seisFile.sac
Class SacTimeSeries
- java.lang.Object
-
- edu.sc.seis.seisFile.sac.SacTimeSeries
-
public class SacTimeSeries extends java.lang.Object
Class that represents a sac file. All headers are have the same names as within the Sac program. Can read the whole file or just the header as well as write a file. This reflects the sac header as of version 101.4 in utils/sac.h Notes: Key to comment flags describing each field: Column 1: R required by SAC (blank) optional Column 2: A = settable from a priori knowledge D = available in data F = available in or derivable from SEED fixed data header T = available in SEED header tables (blank) = not directly available from SEED data, header tables, or elsewhere
-
-
Constructor Summary
Constructors Constructor Description SacTimeSeries()
SacTimeSeries(SacHeader header, float[] data)
create a new SAC timeseries from the given header and data.SacTimeSeries(java.io.DataInput inStream)
SacTimeSeries(java.io.File file)
SacTimeSeries(java.lang.String filename)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
appendData(java.io.File outfile, float[] data)
float[]
getAmp()
SacHeader
getHeader()
float[]
getImaginary()
int
getNumPtsRead()
float[]
getPhase()
float[]
getReal()
float[]
getX()
float[]
getY()
static void
main(java.lang.String[] args)
just for testing.void
printHeader(java.io.PrintWriter out)
void
read(java.io.DataInput dis)
void
read(java.io.File sacFile)
void
read(java.lang.String filename)
reads the sac file specified by the filename.protected void
readData(java.io.DataInput fis)
read the data portion of the given Filestatic void
readSomeData(java.io.DataInput dataIn, float[] data, boolean byteOrder)
reads data.length floats.void
setAmp(float[] amp)
void
setImaginary(float[] imaginary)
void
setPhase(float[] phase)
void
setReal(float[] real)
void
setX(float[] x)
void
setY(float[] y)
static int
skipSamples(java.io.DataInput dataIn, int samplesToSkip)
skips samplesToSkip data points.void
write(java.io.File file)
writes this object out as a sac file.void
write(java.lang.String filename)
writes this object out as a sac file.void
writeData(java.io.DataOutput dos)
-
-
-
Constructor Detail
-
SacTimeSeries
public SacTimeSeries()
-
SacTimeSeries
public SacTimeSeries(SacHeader header, float[] data)
create a new SAC timeseries from the given header and data. The header values related to the data are set correctly:- npts=data.length
- e=b+(npts-1)*delta
- iftype=ITIME
- leven=TRUE
- Parameters:
header
-data
-
-
SacTimeSeries
public SacTimeSeries(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
SacTimeSeries
public SacTimeSeries(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
SacTimeSeries
public SacTimeSeries(java.io.DataInput inStream) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getY
public float[] getY()
-
setY
public void setY(float[] y)
-
getX
public float[] getX()
-
setX
public void setX(float[] x)
-
getReal
public float[] getReal()
-
setReal
public void setReal(float[] real)
-
getImaginary
public float[] getImaginary()
-
setImaginary
public void setImaginary(float[] imaginary)
-
getAmp
public float[] getAmp()
-
setAmp
public void setAmp(float[] amp)
-
getPhase
public float[] getPhase()
-
setPhase
public void setPhase(float[] phase)
-
getHeader
public SacHeader getHeader()
-
printHeader
public void printHeader(java.io.PrintWriter out)
-
getNumPtsRead
public int getNumPtsRead()
-
read
public void read(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
reads the sac file specified by the filename. Only a very simple check is made to be sure the file really is a sac file.- Throws:
java.io.FileNotFoundException
- if the file cannot be foundjava.io.IOException
- if it isn't a sac file or if it happens :)
-
read
public void read(java.io.File sacFile) throws java.io.FileNotFoundException, java.io.IOException
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
read
public void read(java.io.DataInput dis) throws java.io.IOException
- Throws:
java.io.IOException
-
readData
protected void readData(java.io.DataInput fis) throws java.io.IOException
read the data portion of the given File- Throws:
java.io.IOException
-
readSomeData
public static void readSomeData(java.io.DataInput dataIn, float[] data, boolean byteOrder) throws java.io.IOException
reads data.length floats. It is up to the caller to insure that the type of SAC file (iftype = LEVEN, IRLIM, IAMPH) and how many data points remain are compatible with the size of the float array to be read.- Throws:
java.io.IOException
-
skipSamples
public static int skipSamples(java.io.DataInput dataIn, int samplesToSkip) throws java.io.IOException
skips samplesToSkip data points. It is up to the caller to insure that the type of SAC file (iftype = LEVEN, IRLIM, IAMPH) and how many data points remain are compatible with the size of the float array to be read.- Throws:
java.io.IOException
-
write
public void write(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
writes this object out as a sac file.- Throws:
java.io.FileNotFoundException
java.io.IOException
-
write
public void write(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
writes this object out as a sac file.- Throws:
java.io.FileNotFoundException
java.io.IOException
-
writeData
public void writeData(java.io.DataOutput dos) throws java.io.IOException
- Throws:
java.io.IOException
-
appendData
public static void appendData(java.io.File outfile, float[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args)
just for testing. Reads the filename given as the argument, writes out some header variables and then writes it back out as "outsacfile".
-
-