arlmet.concat#
- arlmet.concat(paths, dest, *, overwrite=True)[source]#
Concatenate multiple ARL files into a single ARL file.
Every time step of the inputs is copied to the output byte for byte, in valid-time order, preserving every record (including diff records and checksums) exactly. HYSPLIT finds a time step by its position in the file, so the output must hold its time steps in order: inputs whose hours interleave are merged hour by hour, and a time step an input repeats byte for byte (as some NOAA HRRR archive files do) is written once. The inputs are first scanned to ensure they share one grid, vertical axis and source ID and do not repeat valid times, since a concatenated ARL file must be a single coherent record stream.
- Parameters:
paths (
Iterable[str|PathLike[str]]) – 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 (
str|PathLike[str]) – Output ARL file. It is written to a hidden.partialfile beside it and renamed once complete, so it replaces an existing file only on success. Must not be one ofpaths.overwrite (
bool) – Replace an existingdest. With False an existingdestis returned as it is, without reading the inputs, so a rerun skips finished work; nothing checks that it came from the same inputs and arguments.
- Returns:
The output path,
Path(dest).- Return type:
- Raises:
TypeError – If
pathsis a single path rather than an iterable of paths.ValueError – If
pathsis empty, ifdestis also an input, if any input is empty, if the inputs disagree on grid, vertical axis or source ID, or if the same valid time appears in more than one input.
Examples
Join the files for 00 UTC and 06 UTC into one file:
>>> import arlmet >>> arlmet.concat(["met_00.arl", "met_06.arl"], "day.arl").name 'day.arl'
Combine every file discovered by glob (the output is in valid-time order, so glob order does not matter):
>>> import glob >>> arlmet.concat(glob.glob("met_*.arl"), "day_glob.arl").name 'day_glob.arl'