DASPack: Controlled data compression for Distributed Acoustic Sensing
Project description
DASPack: Controlled data compression for Distributed Acoustic Sensing
DASPack is a fast, open-source compressor for huge Distributed Acoustic Sensing (DAS) datasets.
It supports lossless and fixed-accuracy lossy modes, letting you store data with an exact bound on reconstruction error.
The core is written in Rust for speed and safety, with a thin Python API for convenient integration into your workflows.
DISCLAIMER: We are testing the code, official release will be by mid-august.
✨ Highlights
- Lossless or fixed-accuracy — pick zero error or a max absolute error and get exactly what you asked for.
- Multi-threaded — control the number of threads per encode/decode call.
- High throughput — 800 MB/s+ on an 8-core laptop in typical workloads.
- Self-describing streams — all parameters (codec, quantizer, shape) are stored in the bitstream; no sidecars needed.
- Pure Rust core — no unsafe C buffers exposed to user code.
- Python bindings — direct
encode/decodeinterface for NumPy arrays.
🚀 Quick start
1. Install (Python ≥ 3.9)
pip install daspack
# or, from source (Rust ≥ 1.74):
# maturin develop --release
2. Encode and store with h5py
You can store the compressed DASPack bitstream as raw bytes in HDF5:
import numpy as np, h5py
from daspack import DASCoder, Quantizer
# Example: lossless compression with 4 threads
data = np.random.randint(-1000, 1000, size=(4096, 8192), dtype=np.int32)
coder = DASCoder(threads=4)
# Encode in Lossless mode
stream = coder.encode(
data,
Quantizer.Lossless(),
blocksize=(1024, 1024),
levels=0,
order=0,
)
with h5py.File("example.h5", "w") as f:
f.create_dataset("compressed", data=np.frombuffer(stream, dtype=np.uint8))
3. Read and decode
import numpy as np, h5py
from daspack import DASCoder
coder = DASCoder(threads=4)
with h5py.File("example.h5") as f:
raw = f["compressed"][:].tobytes()
# Decode: dtype is inferred from the stream
restored = coder.decode(raw)
4. Lossy example with fixed error bound
import numpy as np
from daspack import DASCoder, Quantizer
# Generate some example data
data = np.random.uniform(-100, 100, size=(6, 8)).astype(np.float64)
coder = DASCoder(threads=2)
# Target: absolute error ≤ step/2
step = 0.5
# Encode with Uniform quantizer (lossy) and given step
stream = coder.encode(
data,
Quantizer.Uniform(step=step),
)
# Decode (dtype inferred from stream)
restored = coder.decode(stream)
# Verify bound
tol = step / 2 + 1e-12
max_err = np.max(np.abs(restored - data))
print(f"Max abs error: {max_err:.6f} (tolerance {tol})")
assert max_err <= tol
print("Original data:\n", data)
print("Restored data:\n", restored)
The expected output is
Max abs error: 0.250000 (tolerance 0.250000)
Original data:
[[ ... ]]
Restored data:
[[ ... ]]
⚙️ How it works
(float mode) Quantize → Wavelet (5/3) → 2-D LPC → Arithmetic coding
(int mode) Identity → Wavelet (5/3) → 2-D LPC → Arithmetic coding
The lossy path is bounded-error thanks to uniform quantization; the rest of the chain is perfectly reversible.
Read the paper (see citation below!) for more information 😄
📄 License
DASPack is released under the 3-Clause BSD License.
🤝 Contributing
Bug reports and pull requests are welcome. If you plan a large change, please open an issue first so we can discuss the design.
📣 Citing
If you use DASPack in academic work, please cite:
Seguí, A. et al. (2025). DASPack: Controlled Data Compression for Distributed Acoustic Sensing. Geophysical Journal International.
DOI: pending
Thanks for supporting open science!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file daspack_dev-0.0.1a0.tar.gz.
File metadata
- Download URL: daspack_dev-0.0.1a0.tar.gz
- Upload date:
- Size: 63.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0036a05a0dfe608e2409f8c23dfdc6a9afea32b83def137348533d38cc1b789
|
|
| MD5 |
c09aeccda57b5f46bb6524acf9cb1b4b
|
|
| BLAKE2b-256 |
989cc0adce7e5c6c286ef29d930efb8e5fb222a732f64b2d929b2132e0ee3d62
|
File details
Details for the file daspack_dev-0.0.1a0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: daspack_dev-0.0.1a0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 324.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f42f08335d38f9d3b6ccf2d956f2a4487fd157dde4406534ca4eed767d8ac15c
|
|
| MD5 |
3413e4c1c245983ebfe817a44735a422
|
|
| BLAKE2b-256 |
4d343d8b92f84f5602949eb699f91d26c4939014c2f799ae7f3d5b1e415876ef
|