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
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ dependencies = [
"numcodecs>=0.13.0,<0.16",
"numcodecs-combinators[xarray]~=0.2.4",
"numcodecs-observers~=0.1.1",
"numcodecs-wasm~=0.1.1",
"numcodecs-wasm~=0.1.3",
"numcodecs-wasm-bit-round~=0.2.0",
"numcodecs-wasm-fixed-offset-scale~=0.2.1",
"numcodecs-wasm-jpeg2000~=0.1.1",
"numcodecs-wasm-pco~=0.1.0",
"numcodecs-wasm-round~=0.2.0",
"numcodecs-wasm-sz3~=0.4.0",
"numcodecs-wasm-sz3~=0.5.0",
Comment thread
juntyr marked this conversation as resolved.
"numcodecs-wasm-tthresh~=0.1.0",
"numcodecs-wasm-uniform-noise~=0.2.0",
"numcodecs-wasm-zfp~=0.4.0",
Expand Down
3 changes: 2 additions & 1 deletion src/climatebenchpress/compressor/compressors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__all__ = ["BitRound", "BitRoundPco", "StochRound", "Sz3", "Tthresh", "Zfp"]
__all__ = ["BitRound", "BitRoundPco", "Jpeg2000", "StochRound", "Sz3", "Tthresh", "Zfp"]

from . import abc as abc
from .bitround import BitRound
from .bitround_pco import BitRoundPco
from .jpeg2000 import Jpeg2000
from .stochround import StochRound
from .sz3 import Sz3
from .tthresh import Tthresh
Expand Down
33 changes: 33 additions & 0 deletions src/climatebenchpress/compressor/compressors/jpeg2000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
__all__ = ["Jpeg2000"]

import numcodecs.astype
import numcodecs_wasm_fixed_offset_scale
import numcodecs_wasm_jpeg2000
import numcodecs_wasm_round
from numcodecs.abc import Codec
from numcodecs_combinators.stack import CodecStack

from .abc import Compressor


class Jpeg2000(Compressor):
name = "jpeg2000"
description = "JPEG 2000"

@staticmethod
def build() -> Codec:
precision = 0.01
rate = 10.0 # x10 factor compression

return CodecStack(
numcodecs_wasm_fixed_offset_scale.FixedOffsetScale(
offset=0,
scale=precision,
),
numcodecs_wasm_round.Round(precision=1),
numcodecs.astype.AsType(
encode_dtype="int32",
decode_dtype="float32",
),
numcodecs_wasm_jpeg2000.Jpeg2000(mode="rate", rate=rate),
)
Loading