Skip to content
Merged
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 @@ -19,6 +19,7 @@ dependencies = [
"numcodecs-safeguards==0.1.0b2",
"numcodecs-wasm==0.2.2",
"numcodecs-wasm-bit-round==0.4.0",
"numcodecs-wasm-ebcc==0.3.0a0",
"numcodecs-wasm-fixed-offset-scale==0.4.0",
"numcodecs-wasm-jpeg2000==0.3.0",
"numcodecs-wasm-pco==0.3.0",
Expand Down
2 changes: 2 additions & 0 deletions src/climatebenchpress/compressor/compressors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__all__ = [
"BitRound",
"BitRoundPco",
"Ebcc",
"Jpeg2000",
"SafeguardedBitRoundPco",
"SafeguardedSperr",
Expand All @@ -20,6 +21,7 @@
from . import abc as abc
from .bitround import BitRound
from .bitround_pco import BitRoundPco
from .ebcc import Ebcc
from .jpeg2000 import Jpeg2000
from .safeguarded import (
SafeguardedBitRoundPco,
Expand Down
52 changes: 52 additions & 0 deletions src/climatebenchpress/compressor/compressors/ebcc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
__all__ = ["Ebcc"]

import numcodecs.astype
import numcodecs_wasm_ebcc
from numcodecs_combinators.stack import CodecStack

from .abc import Compressor


class Ebcc(Compressor):
"""EBCC compressor."""

name = "ebcc"
description = "EBCC"

@staticmethod
def abs_bound_codec(error_bound, dtype=None, **kwargs):
assert dtype is not None, "dtype must be provided"

return CodecStack(
# EBCC only supports float32 data
numcodecs.astype.AsType(
encode_dtype="float32",
decode_dtype=dtype.name,
),
numcodecs_wasm_ebcc.Ebcc(
# reasonable default recommended by Langwen Huang
base_cr=100,
residual="absolute",
error=error_bound,
chunk_shape="auto",
),
)

@staticmethod
def rel_bound_codec(error_bound, dtype=None, **kwargs):
assert dtype is not None, "dtype must be provided"

return CodecStack(
# EBCC only supports float32 data
numcodecs.astype.AsType(
encode_dtype="float32",
decode_dtype=dtype.name,
),
numcodecs_wasm_ebcc.Ebcc(
# reasonable default recommended by Langwen Huang
base_cr=100,
residual="relative",
error=error_bound,
chunk_shape="auto",
),
)
Loading