SpatioTemporal / STARE

SpatioTemporal Adaptive Resolution Encoding, a unifying index for geo-located data.
Other
10 stars 7 forks source link

TemporalIndex::fromJulianUTC throws exception for dubious year returned by ERFA #111

Closed michaelleerilee closed 1 year ago

michaelleerilee commented 1 year ago

Discovered via https://github.com/SpatioTemporal/pystare/issues/120. Crashes pystare.

Root cause: https://github.com/liberfa/erfa/blob/master/src/dat.c.

1) UTC began at 1960 January 1.0 (JD 2436934.5) and it is improper to call the function with an earlier date. If this is attempted, zero is returned together with a warning status. Because leap seconds cannot, in principle, be predicted in advance, a reliable check for dates beyond the valid range is impossible. To guard against gross errors, a year five or more after the release year of the present function (see the constant IYV) is considered dubious. In this case a warning status is returned but the result is computed in the normal way. For both too-early and too-late years, the warning status is +1. This is distinct from the error status -1, which signifies a year so early that JD could not be computed.

Fix

  1. Update the ERFA used by STARE.
  2. Return the ERFA-produced date instead of throwing an exception.
  3. Return the ERFA return code to flag dubious years or other exceptions.