I still do not know what the first element of the head is, but I have found out what the three last ones are. They are 2**15 (almost always, don’t know when not), the size of the uncompressed array in bytes, the size of the compressed binary array after compression, but without considering base64 encoding!
The following example shows how to obtain the XML binary for the “Points” data array of the example, consisting of floats, i.e. float32, assuming that the header speficies header_type="UInt32"
:
import numpy as np
import base64
import zlib
arr = np.array([0, 0, 0, 1, 0, 0,
1, 1, 0, 0, 1, 1], dtype='float32')
arr_comp = zlib.compress(arr)
header = np.array([ 1, # apparently this is always the case, I think
2**15, # from what I have read, this is true in general
arr.nbytes, # the size of the array `arr` in bytes
len(arr_comp)], # the size of the compressed array
dtype='uint32')
# only use base64 encoding when writing to file
print(f'{(base64.b64encode(header_arr) + base64.b64encode(arr_comp)).decode("utf-8")}')
The output is as expected:
AQAAAACAAAAwAAAAEQAAAA==eJxjYEAGDfaobEw+ADwjA7w=