arlmet.probe#

arlmet.probe(path)[source]#

Cheaply summarize an ARL file from its first two index records and its size.

Reads the first index record (arlmet.IndexRecord.from_position() at byte 0) to learn the file’s grid, source, forecast hour, and first valid time, and how many bytes one time step takes (its index record plus one data record per variable per level). A os.stat() then gives the file’s size, from which the number of time steps and whether the file is whole or truncated follow by division; when there are at least two, the second index record (at the byte offset the first time step’s length gives) gives the time step.

This is the cost of opening the file (the few small reads over the network it takes) without reading every index record, which is what arlmet.File.check() does for full validation. A probe never reads a data record, so it does not unpack or checksum any values.

Parameters:

path (str | PathLike[str]) – Location of the ARL file on disk.

Return type:

Probe

Raises:
  • ARLFormatError – If the file holds no index record (it may be empty or not ARL), or the first or second index record cannot be parsed.

  • OSError – If the file cannot be opened or stat’d.

See also

Probe

The returned summary.

arlmet.File.check

Full validation, by reading every index record.

arlmet.index

Indexes every time step of a whole directory.

Examples

>>> arlmet.probe("met.arl")
Probe(path=PosixPath('met.arl'), first=Timestamp('2024-07-18 00:00:00'),
step=Timedelta('0 days 03:00:00'), n_steps=2, grid=Grid(...), source='TEST',
forecast=0, whole=True)