pytroll / pygac

A python package to read and calibrate NOAA and Metop AVHRR GAC and LAC data
https://pygac.readthedocs.org/
GNU General Public License v3.0
21 stars 27 forks source link

Method get_tle_lines() raises index error when tle lines are empty strings #94

Closed oliversus closed 3 years ago

oliversus commented 3 years ago

In pod_reader.py._compute_missing_lonlat(): Function get_tle_lines() will raise an IndexError if the next available tle line is not within a user-defined threshold of n days. Pygac should be able to handle this issue, as tle data are gappy, and a fix has been introduced to deal with such cases. In fact, before a recent commit (3f0430687), this error has been caught and tle lines were set to emtpy strings.

One could undo that commit, i.e. put that function back into a try clause like so:

        try:
            tle1, tle2 = self.get_tle_lines()
        except IndexError:
            tle1 = tle2 = ''

This would at least allow pygac to continue. However, this causes new problems in compute_pixels(), which calls pyorbital, thus initializing class Tle. Tle will be unhappy about tle lines being empty strings and thus raise IndexErrors.

As I do not know the code structure well enough: does it make sense to just quit compute_missing_lonlat when there are no tle data within the threshold? Or apply the tle fix here?