arlmet.File.check#

File.check()[source]#

Return what is wrong with this file that opening it does not catch.

Opening a file raises ARLFormatError when it is cut short. A file can also be damaged in ways that open cleanly: a time step written partway, a missing time step, or a record overwritten with other bytes. HYSPLIT then stops partway through a run or reads bad values. check looks for these the way HYSPLIT reads a file, time step by time step in file order (metset.f):

  • every time step has as many data records as the first, since HYSPLIT steps from one index record to the next by that count;

  • each time step is as far after the one before it on disk as the second is after the first. HYSPLIT stops when the spacing changes, and it finds a time step by its position in the file, so a time step repeated (some NOAA HRRR archive files repeat one byte for byte; opening skips the copy) or out of order makes it stop or read the wrong hours. A missing time step changes the spacing too;

  • every data record’s header can be read, and names the variable, level, and time its index record lists.

It reads each record’s 50-byte header, not its values, so it does not compare checksums. arlmet.DataRecord.verify_checksum() compares one record’s packed bytes with its stored checksum.

It also lists each record flagged missing (a negative forecast hour, or the name NULL, in its header), which arlmet reads as NaN: HYSPLIT skips such a record, and stops when a time step has more than 20 (metinp.f).

Returns:

One message per problem. Empty when none is found.

Return type:

list[str]

Raises:

ValueError – If the file is open for writing.

Examples

A time step written partway:

>>> with arlmet.File("20210226_18-23_hrrr") as met:
...     met.check()
['2021-02-26 19:00 has 43 of the 298 data records the first time step has.']