Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies = [
"numcodecs-wasm-round~=0.4.0",
"numcodecs-wasm-sperr~=0.1.0",
"numcodecs-wasm-stochastic-rounding~=0.1.1",
"numcodecs-wasm-swizzle-reshape~=0.3.0",
"numcodecs-wasm-sz3~=0.6.0",
"numcodecs-wasm-tthresh~=0.2.0",
"numcodecs-wasm-zfp~=0.5.3",
Expand Down
4 changes: 4 additions & 0 deletions src/climatebenchpress/compressor/compressors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"BitRound",
"BitRoundPco",
"Jpeg2000",
"RP",
"RPDct",
"Sperr",
"StochRound",
"StochRoundPco",
Expand All @@ -15,6 +17,8 @@
from .bitround import BitRound
from .bitround_pco import BitRoundPco
from .jpeg2000 import Jpeg2000
from .rp import RP
from .rp_dct import RPDct
from .sperr import Sperr
from .stochround import StochRound
from .stochround_pco import StochRoundPco
Expand Down
21 changes: 21 additions & 0 deletions src/climatebenchpress/compressor/compressors/rp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__all__ = ["RP"]

import numcodecs_random_projection
import numcodecs_wasm_swizzle_reshape
from numcodecs_combinators.stack import CodecStack

from .abc import Compressor


class RP(Compressor):
name = "rp"
description = "Random Projection (Gaussian)"

@staticmethod
def abs_bound_codec(error_bound, **kwargs):
return CodecStack(
numcodecs_wasm_swizzle_reshape.SwizzleReshape(axes=[[0, 1, 2], [3, 4]]),
numcodecs_random_projection.RPCodec(
mae=error_bound, method="gaussian", seed=42, debug=True
),
)
21 changes: 21 additions & 0 deletions src/climatebenchpress/compressor/compressors/rp_dct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__all__ = ["RPDct"]

import numcodecs_random_projection
import numcodecs_wasm_swizzle_reshape
from numcodecs_combinators.stack import CodecStack

from .abc import Compressor


class RPDct(Compressor):
name = "rp-dct"
description = "Random Projection (DCT)"

@staticmethod
def abs_bound_codec(error_bound, **kwargs):
return CodecStack(
numcodecs_wasm_swizzle_reshape.SwizzleReshape(axes=[[0, 1, 2], [3, 4]]),
numcodecs_random_projection.RPCodec(
mae=error_bound, method="dct", seed=0, debug=True
),
)
Loading