Package edu.iris.dmc.seedcodec
Class Steim2
java.lang.Object
edu.iris.dmc.seedcodec.Steim2
Class for decoding or encoding Steim2-compressed data blocks
to or from an array of integer values.
Steim compression scheme Copyrighted by Dr. Joseph Steim.
- Reference material found in:
- Appendix B of SEED Reference Manual, 2nd Ed., pp. 119-125 Federation of Digital Seismic Networks, et al. February, 1993
- Coding concepts gleaned from code written by:
- Guy Stewart, IRIS, 1991
- Tom McSweeney, IRIS, 2000
- Doug Neuhauser, UC Berkeley, 2010
- Kevin Frechette, ISTI, 2010
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
decode
(byte[] b, int numSamples, boolean swapBytes) Abbreviated, zero-bias version of decode().static int[]
decode
(byte[] b, int numSamples, boolean swapBytes, int bias) Decode the indicated number of samples from the provided byte array and return an integer array of the decompressed values.static SteimFrameBlock
encode
(int[] samples, int frames) Abbreviated zero-bias version of encode().static SteimFrameBlock
encode
(int[] samples, int frames, int bias) Encode the array of integer values into a Steim 2 * compressed byte frame block.static SteimFrameBlock
encode
(int[] samples, int frames, int bias, int samplesLength) Encode the array of integer values into a Steim 2 * compressed byte frame block.protected static int[]
extractSamples
(byte[] bytes, int offset, boolean swapBytes) Extracts differences from the next 64 byte frame of the given compressed byte array (starting at offset) and returns those differences in an int array.
-
Constructor Details
-
Steim2
public Steim2()
-
-
Method Details
-
decode
public static int[] decode(byte[] b, int numSamples, boolean swapBytes, int bias) throws SteimException Decode the indicated number of samples from the provided byte array and return an integer array of the decompressed values. Being differencing compression, there may be an offset carried over from a previous data record. This offset value can be placed in bias, otherwise leave the value as 0.- Parameters:
b
- input byte array to be decodednumSamples
- the number of samples that can be decoded from array bswapBytes
- if true, swap reverse the endian-ness of the elements of byte array b.bias
- the first difference value will be computed from this value. If set to 0, the method will attempt to use the X(0) constant instead.- Returns:
- int array of length numSamples.
- Throws:
SteimException
- - encoded data length is not multiple of 64 bytes.
-
decode
Abbreviated, zero-bias version of decode(). see edu.iris.Fissures.codec.Steim2#decode(byte[],int,boolean,int)- Throws:
SteimException
-
encode
Abbreviated zero-bias version of encode(). see edu.iris.Fissures.codec.Steim2#encode(int[],int,int)- Throws:
SteimException
-
encode
Encode the array of integer values into a Steim 2 * compressed byte frame block. This algorithm will not create a byte block any greater * than 63 64-byte frames. frames represents the number of frames to be written. This number should be determined from the desired logical record length minus the data offset from the record header (modulo 64) If samples is exhausted before all frames are filled, the remaining frames will be nulls. bias is a value carried over from a previous data record, representing X(-1)...set to 0 otherwise- Parameters:
samples
- the data points represented as signed integersframes
- the number of Steim frames to use in the encodingbias
- offset for use as a constant for the first difference, otherwise set to 0- Returns:
- SteimFrameBlock containing encoded byte array
- Throws:
SteimException
- samples array is zero sizeSteimException
- number of frames is not a positive valueSteimException
- cannot encode more than 63 frames
-
encode
public static SteimFrameBlock encode(int[] samples, int frames, int bias, int samplesLength) throws SteimException Encode the array of integer values into a Steim 2 * compressed byte frame block. For miniseed2 you should not create a byte block any greater than 63 64-byte frames. frames represents the number of frames to be written. This number should be determined from the desired logical record length minus the data offset from the record header (modulo 64) If samples is exhausted before all frames are filled, the remaining frames will be nulls. bias is a value carried over from a previous data record, representing X(-1)...set to 0 otherwise- Parameters:
samples
- the data points represented as signed integersframes
- the number of Steim frames to use in the encodingbias
- offset for use as a constant for the first difference, otherwise set to 0samplesLength
- the samples length- Returns:
- SteimFrameBlock containing encoded byte array
- Throws:
SteimException
- samples array is zero sizeSteimException
- number of frames is not a positive valueSteimException
- cannot encode more than 63 frames
-
extractSamples
protected static int[] extractSamples(byte[] bytes, int offset, boolean swapBytes) Extracts differences from the next 64 byte frame of the given compressed byte array (starting at offset) and returns those differences in an int array. An offset of 0 means that we are at the first frame, so include the header bytes in the returned int array...else, do not include the header bytes in the returned array.- Parameters:
bytes
- byte array of compressed data differencesoffset
- index to begin reading compressed bytes for decodingswapBytes
- reverse the endian-ness of the compressed bytes being read- Returns:
- integer array of difference (and constant) values
-