Skip to content

Commit fbcbc45

Browse files
add Int and Long packing for data arrays that have more than 65535 extent (#112)
1 parent aee5308 commit fbcbc45

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

python/idsse_common/idsse/common/sci/bit_pack.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818

1919

2020
class PackType(IntEnum):
21-
"""Enumerated type used to indicate if data is packed into a byte or short (16 bit)"""
21+
"""Enumerated type to mark if data is packed into a byte, short (16 bit), or int (32 bit)"""
2222

2323
BYTE = 8
2424
SHORT = 16
25+
INT = 32
2526

2627

2728
class PackInfo(NamedTuple):
@@ -294,8 +295,9 @@ def _pack_np_array_to_list(data: numpy.array, scale: float, offset: float) -> li
294295
# return numpy.trunc(dip_data)
295296

296297

297-
# private lookup for the max value possible for bit packing type
298-
_max_values = {PackType.BYTE: 255, PackType.SHORT: 65535}
298+
# private lookup for the max value possible for bit packing type.
299+
# this is just memoization of `math.pow(2, pack_type) - 1` for pack_type in PackType enum
300+
_max_values = {PackType.BYTE: 255, PackType.SHORT: 65535, PackType.INT: 4294967295}
299301

300302
_scale_lookup = {0: 1.0, 1: 0.1, 2: 0.01, 3: 0.001, 4: 0.0001, 5: 0.00001, 6: 0.000001}
301303

0 commit comments

Comments
 (0)