Class Steim1

java.lang.Object
edu.iris.dmc.seedcodec.Steim1

public class Steim1 extends Object
Class for decoding or encoding Steim1-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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.
    encode(int[] samples, int frames)
    Abbreviated zero-bias version of encode().
    encode(int[] samples, int frames, int bias)
    Encode the array of integer values into a Steim 1 * compressed byte frame block.
    encode(int[] samples, int frames, int bias, int offset)
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Steim1

      public Steim1()
  • 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 decoded
      numSamples - the number of samples that can be decoded from array b
      swapBytes - 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

      public static int[] decode(byte[] b, int numSamples, boolean swapBytes) throws SteimException
      Abbreviated, zero-bias version of decode(). see edu.iris.Fissures.codec.Steim1#decode(byte[],int,boolean,int)
      Throws:
      SteimException
    • encode

      public static SteimFrameBlock encode(int[] samples, int frames, int bias) throws SteimException
      Encode the array of integer values into a Steim 1 * compressed byte frame block. For miniseed2 you should not create a byte block any greater than 63 64-byte frames. maxFrames=0 implies unlimited number of frames, usually for miniseed3. maxFrames 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 integers
      frames - the number of Steim frames to use in the encoding
      bias - 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 size
      SteimException - number of frames is a negative value
    • encode

      public static SteimFrameBlock encode(int[] samples, int frames, int bias, int offset) throws SteimException
      Throws:
      SteimException
    • encode

      public static SteimFrameBlock encode(int[] samples, int frames) throws SteimException
      Abbreviated zero-bias version of encode(). see edu.iris.Fissures.codec.Steim1#encode(int[],int,int)
      Throws:
      SteimException
    • 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 differences
      offset - index to begin reading compressed bytes for decoding
      swapBytes - reverse the endian-ness of the compressed bytes being read
      Returns:
      integer array of difference (and constant) values