arlmet.packing.unpack#

arlmet.packing.unpack(packed, nx, ny, precision, exponent, initial_value, *, window=None)[source]#

Unpack an ARL differential byte stream into a 2D field.

This is a translation of the HYSPLIT PAKINP routine and gives the same float32 values, bit for bit: the arithmetic is in single precision, in PAKINP’s order, and like PAKINP it sets a value smaller than precision to zero in every column but the first.

Parameters:
  • packed (bytes | bytearray | memoryview) – The packed byte array to be unpacked.

  • nx (int) – The number of columns in the full data grid.

  • ny (int) – The number of rows in the full data grid.

  • precision (float) – Precision of the packed data. Values with an absolute value smaller than this are set to zero, except in the first column (x = 0), which PAKINP leaves as it is.

  • exponent (int) – The packing scaling exponent.

  • initial_value (float) – The initial real value at the grid position (0,0).

  • window (GridWindow | None) – Rectangular grid window to unpack. When provided, only the requested subset is reconstructed.

Returns:

Unpacked float32 2D array with shape (ny, nx) or the requested windowed shape when window is provided.

Return type:

NDArray[single]