diff --git a/pyproject.toml b/pyproject.toml index 8a92df2..b347656 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ dependencies = [ "numcodecs-wasm-tthresh~=0.2.0", "numcodecs-wasm-uniform-noise~=0.3.0", "numcodecs-wasm-zfp~=0.5.1", + "numcodecs-wasm-zfp-classic~=0.3.1", "numcodecs-wasm-zlib~=0.3.0", "pandas~=2.2", "scipy~=1.14", diff --git a/src/climatebenchpress/compressor/compressors/__init__.py b/src/climatebenchpress/compressor/compressors/__init__.py index f3e899c..4c58e4e 100644 --- a/src/climatebenchpress/compressor/compressors/__init__.py +++ b/src/climatebenchpress/compressor/compressors/__init__.py @@ -1,4 +1,13 @@ -__all__ = ["BitRound", "BitRoundPco", "Jpeg2000", "StochRound", "Sz3", "Tthresh", "Zfp"] +__all__ = [ + "BitRound", + "BitRoundPco", + "Jpeg2000", + "StochRound", + "Sz3", + "Tthresh", + "Zfp", + "ZfpRound", +] from . import abc as abc from .bitround import BitRound @@ -8,3 +17,4 @@ from .sz3 import Sz3 from .tthresh import Tthresh from .zfp import Zfp +from .zfp_round import ZfpRound diff --git a/src/climatebenchpress/compressor/compressors/zfp.py b/src/climatebenchpress/compressor/compressors/zfp.py index a6611b8..82bc23e 100644 --- a/src/climatebenchpress/compressor/compressors/zfp.py +++ b/src/climatebenchpress/compressor/compressors/zfp.py @@ -1,6 +1,6 @@ __all__ = ["Zfp"] -import numcodecs_wasm_zfp +import numcodecs_wasm_zfp_classic from .abc import Compressor @@ -19,4 +19,6 @@ class Zfp(Compressor): @staticmethod def abs_bound_codec(dtype, error_bound): - return numcodecs_wasm_zfp.Zfp(mode="fixed-accuracy", tolerance=error_bound) + return numcodecs_wasm_zfp_classic.ZfpClassic( + mode="fixed-accuracy", tolerance=error_bound + ) diff --git a/src/climatebenchpress/compressor/compressors/zfp_round.py b/src/climatebenchpress/compressor/compressors/zfp_round.py new file mode 100644 index 0000000..91e07ef --- /dev/null +++ b/src/climatebenchpress/compressor/compressors/zfp_round.py @@ -0,0 +1,22 @@ +__all__ = ["ZfpRound"] + +import numcodecs_wasm_zfp + +from .abc import Compressor + + +class ZfpRound(Compressor): + name = "zfp-round" + description = "ZFP-ROUND" + + # NOTE: + # ZFP mechanism for strictly supporting relative error bounds is to + # truncate the floating point bit representation and then use ZFP's lossless + # mode for compression. This is essentially equivalent to the BitRound + # compressors we are already implementing (with a difference what the lossless + # compression algorithm is). + # See https://zfp.readthedocs.io/en/release1.0.1/faq.html#q-relerr for more details. + + @staticmethod + def abs_bound_codec(dtype, error_bound): + return numcodecs_wasm_zfp.Zfp(mode="fixed-accuracy", tolerance=error_bound)