Skip to content
Snippets Groups Projects
Commit bebba5df authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Get rid of Enums and use a dictionary to define available lossy compressors,...

Get rid of Enums and use a dictionary to define available lossy compressors, methods and their respective ranges and types.
parent 63ad20ec
No related branches found
No related tags found
1 merge request!6Get rid of Enums and use a dictionary to define available lossy compressors,...
from enum import Enum, auto
class Compressors(Enum):
"""
List of supported compressors
"""
NONE = None
BLOSC = 32001
ZFP = 32013
SZ = 32017
SZ3 = 32024
ALL = auto()
class CompressionModes(Enum):
"""
List of supported compression Modes
"""
# ZFP Modes
RATE = auto()
PRECISION = auto()
ACCURACY = auto()
REVERSIBLE = auto()
EXPERT = auto()
# SZ Modes
ABS = auto()
REL = auto()
PW_REL = auto()
# SZ3 Modes
# ABS
# REL
PSNR = auto()
NORM2 = auto()
# BLOSC Modes
BLOSCLZ = auto()
LZ4 = auto()
LZ4HC = auto()
SNAPPY = auto()
ZLIB = auto()
ZSTD = auto()
# Other modes
ALL = auto()
NONE = None
compressor_aliases = {mode: str(mode).replace("Compressors.", "").lower() for mode in Compressors}
compression_mode_aliases = {mode: str(mode).replace("CompressionModes.", "").lower() for mode in CompressionModes}
# Dictionary of implemented lossy compressors and their respective modes and ranges.
# TODO: Would that be better to keep the definition of the available compressors and methods in a configuration file?
lossy_compressors_and_modes = {
"sz": {
"abs": {"range": [0, float('inf')], "type": float},
"rel": {"range": [0, 1], "type": float},
"pw_rel": {"range": [0, 1], "type": float},
},
"sz3": {
"abs": {"range": [0, float('inf')], "type": float},
"rel": {"range": [0, 1], "type": float},
"norm2": {"range": [0, 1], "type": float},
"psnr": {"range": [1, 120], "type": float},
},
"zfp": {
"rate": {"range": [0, 32], "type": float},
"precision": {"range": [1, 32], "type": int},
"accuracy": {"range": [0, float('inf')], "type": float},
}
}
# Create a list with the lossy compressors
lossy_compressors = [c for c in lossy_compressors_and_modes]
# Create a dictionary containing the available compression modes for each lossy compressor
lossy_compression_modes = {c: [k for k in lossy_compressors_and_modes[c]] for c in lossy_compressors}
# List of available BLOSC backends for lossless compression
lossless_backends = ['blosclz', 'lz4', 'lz4hc', 'snappy', 'zlib', 'zstd']
# Mappings between SZ modes and the keywords used in hdf5plugin
sz_mode_map = {
"abs": "absolute",
"rel": "relative",
"pw_rel": "pointwise_relative",
"psnr": "peak_signal_to_noise_ratio",
"norm2": "norm2",
}
# Mapping between compressor names and hdf5plugin classes
import hdf5plugin
compressor_map = {
"zfp": hdf5plugin.Zfp,
"sz": hdf5plugin.SZ,
"sz3": hdf5plugin.SZ3,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment