arlmet.concat#

arlmet.concat(paths, dest, *, sort=True)[source]#

Concatenate multiple ARL files into a single ARL file.

Each input is appended to the output byte-for-byte, preserving every record (including diff records and checksums) exactly. The inputs are first scanned to ensure they share one grid and vertical axis and do not repeat valid times, since a concatenated ARL file must be a single coherent record stream.

Parameters:
  • paths (iterable of path-like) – Input ARL files to join. Must contain at least one path. A bare string or path is rejected — wrap a single file in a list.

  • dest (path-like) – Output ARL file. Overwrites any existing file. Must not be one of paths.

  • sort (bool, default True) – Order the inputs by their earliest valid time before joining, so the output is chronological regardless of input order. When False, inputs are joined in the order given (like cat).

Returns:

The output path, Path(dest).

Return type:

pathlib.Path

Raises:
  • TypeError – If paths is a single path rather than an iterable of paths.

  • ValueError – If paths is empty, if dest is also an input, if any input is empty, if the inputs disagree on grid or vertical axis, or if the same valid time appears in more than one input.

Examples

Join three 6-hourly HRRR files into one daily file:

>>> import arlmet
>>> arlmet.concat(
...     ["20240101_00_hrrr", "20240101_06_hrrr", "20240101_12_hrrr"],
...     "20240101_hrrr",
... )

Combine every 6-hourly file for one day discovered by glob (sort=True orders them by valid time, so glob order does not matter):

>>> import glob
>>> arlmet.concat(glob.glob("20240101_*_hrrr"), "20240101_hrrr")