Skip to content

Commit

Permalink
Try a more clever handling of the case where more level-1b files exis…
Browse files Browse the repository at this point in the history
…t for given sat and orbit

Signed-off-by: Adam Dybbroe <adam.dybbroe@smhi.se>
  • Loading branch information
adybbroe committed Jan 10, 2015
1 parent 9bd4e6c commit f90e482
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions mpop/satin/aapp1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,31 @@ def load_avhrr(satscene, options):
file_list = glob.glob(filename)

if len(file_list) > 1:
raise IOError("More than one l1b file found: " + str(file_list))
LOGGER.info("More than one l1b file found: " + str(file_list))
# hrpt_noaa18_20150110_1658_49685.l1b
candidate = ('hrpt_' + satscene.fullname +
satscene.time_slot.strftime('_%Y%m%d_%H%M_') +
str(satscene.orbit) + '.l1b')
LOGGER.debug("Suggested filename = " + str(candidate))
candidate_found = False
for fname in file_list:
l1bname = os.path.basename(fname)
if l1bname == candidate:
filename = fname
candidate_found = True
LOGGER.info(
'The l1b file chosen is this: ' + str(filename))
break
if not candidate_found:
LOGGER.info("More than one l1b file found: " + str(file_list))
LOGGER.warning("Couldn't decide which one to take. " +
"Try take the first one: " + str(filename))
filename = file_list[0]

elif len(file_list) == 0:
raise IOError("No l1b file matching!: " + filename)

filename = file_list[0]
else:
filename = file_list[0]

LOGGER.debug("Loading from " + filename)
scene = AAPP1b(filename)
Expand Down

0 comments on commit f90e482

Please sign in to comment.