salvus.project.tools.io.seisio.compression
SeisIO format decompression.
Classes
TraceCompression
TraceCompressionclass TraceCompression(builtins.object):
def __init__(
self,
samples_per_trace: int,
samples_per_packet: int,
bytes_per_sample: int,
): ...Trace compression object.
The compression algorithm is intended for 32-bit floating point numbers and works by converting each 32-bit number to a 32-bit factor and a lower precision integer number. Thus it effectively compresses by reducing the dynamic range for each packet/block of samples.
The compression algorithm packages X samples up in a packet (self.packet is the number of samples per packet).
Layout per packet:
For bytes_per_sample == 4:
No compression - raw IEEE float 32 data
For `bytes_per_sample == 2` = 16 bit dynamic range per packet:
`| float32 factor | | int16 value | | int16 value| ...`
For `bytes_per_sample == 1` = 8 bit dynamic range per packet:
`| float32 factor | | int8 value | | int8 value| ...`samples_per_traceint — The number of samples per trace.samples_per_packetint — The number of samples per packet.bytes_per_sampleint — The number of bytes per sample.
decompress_trace()
decompress_trace()def decompress_trace(self, data: numpy.ndarray) -> numpy.ndarray: ...Decompress a single trace.
datanumpy.ndarray — The compressed data as a np.int8 byte array.
decompress_trace_dynamic_range()
decompress_trace_dynamic_range()def decompress_trace_dynamic_range(
self,
data: numpy.ndarray,
bytes_per_sample: int,
buf: Optional[numpy.ndarray] = None,
) -> numpy.ndarray: ...Decompress the 2 byte version of SeisIO’s compression.
The compression algorithm packages X samples up in a packet (self.packet is the number of samples per packet).
Packet layout: | float32 factor | | int16 value | | int16 value| …
The factor is then just multiplied with all values to yield the final value.
datanumpy.ndarray — The compressed data.bytes_per_sampleint — The number of bytes per compressed sample.bufOptional[numpy.ndarray] — Buffer (np.float32) to store the decompressed data. Will be created if it does not exist.