How to identify what ERA5 temporal resolution is used in a file

ERA5 data come in three temporal resolutions:

  • Hourly
  • Monthly averaged
  • Monthly synoptic averaged (by hour of the day)

If I am given an ERA5 file, is there a way to (programmatically) determine which type of temporal resolution is used in the file?

As an example, monthly averaged data have all temporal ordinates at 00:00 UTC. However, it is also possible to construct a file with monthly synoptic averaged data for the hour of 00:00 UTC only, or hourly data for 00:00 UTC only. Distinguishing between hourly data and monthly synoptic averaged data is more complicated because all combinations of years, months and hours of the day are possible. Obviously, the interpretation of the data will be rather different. Given that a request may have a non-contiguous set of years and/or months, I don't see a way of determining the temporal resolution by looking at the time series in the file.

One fool-proof test is that for hourly data: if any temporal ordinate is later in the month than 00:00 UTC on day 2 of the month, then the file contains hourly data. The only other identifying characteristic that I have been able to find is that monthly synoptic averaged data has the ordinate for 00:00 UTC for day 2 of the month, but preceding any other hours of the data which are for day 1 of the month (in other words, the "time" dimension is not monotonously increasing as day 2 data comes before day 1 data). This, however, is not a solution that works all the time, as the request may include only the hour 00:00 UTC or other hours but not 00:00 UTC.

Any pointers on how to approach this would be much appreciated. Using the NetCDF format.