arlmet.record.Header#

class arlmet.record.Header(year, month, day, hour, forecast, level, grid, variable, exponent, precision, initial_value)[source]#

Fixed-width 50-byte header present at the start of every ARL record.

Headers are immutable value objects; use dataclasses.replace() to derive a modified copy.

Parameters:
  • year (int) – Valid time components stored in the record header.

  • month (int) – Valid time components stored in the record header.

  • day (int) – Valid time components stored in the record header.

  • hour (int) – Valid time components stored in the record header.

  • forecast (int) – Forecast hour associated with the record. The label holds two digits, so tobytes() writes min(forecast, 99), as HYSPLIT’s pakrec does (an index record keeps the full hour, up to 999, in its own field).

  • level (int) – ARL vertical level index: 0 for the surface, then 1 to MAX_LEVEL from the ground up. The header holds it in two characters.

  • grid (tuple[int, int]) – Thousands part of the x and y grid sizes, as stored in the header’s two grid characters ((1000, 0) for a 1799x799 grid, written A@; (0, 0) below 1000 points, written 99). The remainders live in the index record, whose nx/ny are the full sizes.

  • variable (str) – Four-character ARL variable name.

  • exponent (int) – Differential packing exponent.

  • precision (float) – Packed-data precision used during unpacking.

  • initial_value (float) – Initial grid value at the start of the differential packing stream.

Variables:
  • N_BYTES (int) – Fixed serialized size of the header.

  • MAX_LEVEL (int) – The highest level index the header’s two characters hold, 99.

Attributes

time

Timestamp reconstructed from the header date fields.

Methods

from_bytes(data)

Parse header from raw bytes.

tobytes()

Serialize the header to its fixed-width ASCII representation.