SafeguardedCodec( codec=codec, # any numcodecs codec safeguards=[ # guarantee that the global minimum and maximum are preserved dict(kind="sign", offset="$x_min"), dict(kind="sign", offset="$x_max"), dict( kind="qoi_eb_pw", qoi=|\qu\qu\qu| # the above sign safeguards guarantee that # min(data) = min(corrected) and # max(data) = max(corrected) v["smin"] = c["$x_min"]; v["smax"] = c["$x_max"]; v["r"] = v["smax"] - v["smin"]; # re-scale to [0-1] and quantise to 256 bins v["sc_a2"] = round_ties_even( ((x - v["smin"])/v["r"]) * 255 )/255; # force the quantised value to stay the same return v["sc_a2"]; |\qu\qu\qu|, type="abs", eb=0, ), ], )