Mondaic
This API reference is not for the latest stable Salvus version.

salvus.project.tools.io.seisio.compression

SeisIO format decompression.

Classes

TraceCompression

class 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| ...`
Parameters
  • samples_per_trace int — The number of samples per trace.
  • samples_per_packet int — The number of samples per packet.
  • bytes_per_sample int — The number of bytes per sample.
Methods
decompress_trace()
def decompress_trace(self, data: numpy.ndarray) -> numpy.ndarray: ...

Decompress a single trace.

Parameters
  • data numpy.ndarray — The compressed data as a np.int8 byte array.
Returns numpy.ndarray — A np.float32 decompressed data array.
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.

Parameters
  • data numpy.ndarray — The compressed data.
  • bytes_per_sample int — The number of bytes per compressed sample.
  • buf Optional[numpy.ndarray] — Buffer (np.float32) to store the decompressed data. Will be created if it does not exist.
Returns numpy.ndarray