simplemseed.seedcodec

Seismic compression and decompression algorithms.

Ported from Java, https://github.com/crotwell/seedcodec/

Module Contents

Classes

EncodedDataSegment

A holder for compressed data independent of the file format.

Functions

arrayTypecodeFromMSeed

Get the typecode for a python array.array from the mseed encoding type.

canDecompress

True if the given encoding can be decompressed by this library.

decompress

Decompress the samples from the provided bytes and return an array of the decompressed values. Only 16 bit short, 32 bit int, 32 bit float and 64 bit double along with Steim1 and Steim2 are supported.

encode

Encode the given numpy.ndarray or array.array into bytes.

encodingName

Textual name for integer SEED encoding.

getFloat64

isFloatCompression

True if the compression is not representable by integers, so not compressable via the standard compression types.

isPrimitiveCompression

True if the compression is one of the primitive types, short, int float or double.

mseed3EncodingFromArrayTypecode

Get the mseed3 encoding type for a python array.arry typecode and itemsize.

mseed3EncodingFromNumpyDT

Get the mseed3 encoding for a numpy dtype code

numpyDTFromMseed3Encoding

Get a numpy dtype for a mseed3 encoding

Data

ASCII

BIG_ENDIAN

Data is big endian, 1

CDSN

DOUBLE

Encoding for 64 bit floating point

DWWSSN

FLOAT

Encoding for 32 bit floating point

INT24

Encoding for 24 bit integer

INTEGER

Encoding for 32 bit integer

LITTLE_ENDIAN

Data is little endian, 0

SHORT

Encoding for 16 bit integer

SRO

STEIM1

Encoding for Steim1 compression

STEIM2

Encoding for Steim2 compression

STEIM3

API

simplemseed.seedcodec.ASCII: int = 0
simplemseed.seedcodec.BIG_ENDIAN = 1

Data is big endian, 1

simplemseed.seedcodec.CDSN: int = 16
simplemseed.seedcodec.DOUBLE: int = 5

Encoding for 64 bit floating point

simplemseed.seedcodec.DWWSSN: int = 32
class simplemseed.seedcodec.EncodedDataSegment(compressionType, dataBytes: Union[bytes, bytearray], numSamples, littleEndian: bool)

A holder for compressed data independent of the file format.

Initialization

compressionType: int = None
dataBytes: Union[bytes, bytearray] = None
decode()
isFloatCompression() bool
littleEndian: bool = None
numSamples: int = None
simplemseed.seedcodec.FLOAT: int = 4

Encoding for 32 bit floating point

simplemseed.seedcodec.INT24: int = 2

Encoding for 24 bit integer

simplemseed.seedcodec.INTEGER: int = 3

Encoding for 32 bit integer

simplemseed.seedcodec.LITTLE_ENDIAN = 0

Data is little endian, 0

simplemseed.seedcodec.SHORT: int = 1

Encoding for 16 bit integer

simplemseed.seedcodec.SRO: int = 30
simplemseed.seedcodec.STEIM1: int = 10

Encoding for Steim1 compression

simplemseed.seedcodec.STEIM2: int = 11

Encoding for Steim2 compression

simplemseed.seedcodec.STEIM3: int = 19
simplemseed.seedcodec.arrayTypecodeFromMSeed(encoding: int) str

Get the typecode for a python array.array from the mseed encoding type.

simplemseed.seedcodec.canDecompress(encoding: int) bool

True if the given encoding can be decompressed by this library.

simplemseed.seedcodec.decompress(compressionType: int, dataBytes: bytearray, numSamples: int, littleEndian: bool) numpy.ndarray

Decompress the samples from the provided bytes and return an array of the decompressed values. Only 16 bit short, 32 bit int, 32 bit float and 64 bit double along with Steim1 and Steim2 are supported.

@param compressionType compression format as defined in SEED blockette 1000 @param dataBytes input bytes to be decoded @param numSamples the number of samples that can be decoded from array <b>b</b> @param littleEndian if True, dataBytes is little-endian (intel byte order) <b>b</b>. @returns array of length <b>numSamples</b>. @throws CodecException fail to decompress. @throws UnsupportedCompressionType unsupported compression type

simplemseed.seedcodec.encode(data, encoding=None, littleEndian=True)

Encode the given numpy.ndarray or array.array into bytes.

Note that currently no actual compression is done, the resulting bytes will occupy the same space, just converted for output. If encoding is not given, the encoding will be guessed from the array type. If endian is not given, defaults to little endian.

simplemseed.seedcodec.encodingName(encoding)

Textual name for integer SEED encoding.

simplemseed.seedcodec.getFloat64(dataBytes, offset, littleEndian)
simplemseed.seedcodec.isFloatCompression(compressionType: int) bool

True if the compression is not representable by integers, so not compressable via the standard compression types.

simplemseed.seedcodec.isPrimitiveCompression(compressionType: int) bool

True if the compression is one of the primitive types, short, int float or double.

simplemseed.seedcodec.mseed3EncodingFromArrayTypecode(typecode: str, itemsize: int) int

Get the mseed3 encoding type for a python array.arry typecode and itemsize.

simplemseed.seedcodec.mseed3EncodingFromNumpyDT(dt: numpy.dtype) int

Get the mseed3 encoding for a numpy dtype code

simplemseed.seedcodec.numpyDTFromMseed3Encoding(encoding: int)

Get a numpy dtype for a mseed3 encoding