radioviz.services.xyz_format

XYZ image format helpers.

The XYZ binary format is defined as:

  • First 4 bytes: header containing height and width as two 16-bit unsigned integers (little endian)

  • Remaining bytes: pixel values as 16-bit unsigned integers (little endian)

Functions

decode_xyz_bytes(data)

Decode XYZ binary data into a 2D numpy array.

encode_xyz_array(arr)

Encode a 2D numpy array into XYZ binary data.

radioviz.services.xyz_format.decode_xyz_bytes(data: bytes) ndarray[source]

Decode XYZ binary data into a 2D numpy array.

Parameters:

data (bytes) – Raw XYZ file bytes

Returns:

Image array with shape (height, width)

Return type:

numpy.ndarray

The XYZ stream stores pixel rows and columns swapped, so the data is reshaped with (width, height) and returned in that orientation to preserve the instrument layout without an additional transpose.

radioviz.services.xyz_format.encode_xyz_array(arr: ndarray) bytes[source]

Encode a 2D numpy array into XYZ binary data.

Parameters:

arr (numpy.ndarray) – Image array to encode

Returns:

Encoded XYZ bytes

Return type:

bytes

When saving, the binary payload is emitted with the instrument’s column-major orientation (width first), so the header keeps (height, width) while the C-ordered buffer reflects the swapped axes.