Skip to content

Commit

Permalink
AVHRR EPS reader: add logic to deal with products where the line leng…
Browse files Browse the repository at this point in the history
…th is shorter than reported
  • Loading branch information
dimarash-hub committed Jan 11, 2022
1 parent 32e278b commit 5b9c8cf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions satpy/readers/eps_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,22 @@ def read_records(filename):
for dtype, count, rec_class in zip(dtypes, counts, classes):
fdes.seek(offset)
if rec_class == ('mdr', 2):
record = da.from_array(np.memmap(fdes, mode='r', dtype=dtype, shape=count, offset=offset),
chunks=(max_lines,))
try:
record = da.from_array(np.memmap(fdes, mode='r', dtype=dtype, shape=count, offset=offset),
chunks=(max_lines,))
except:
original_count = count
logger.debug("Warning! a mismatch between the reported length of a sensor line and the actual length was detected! Attempting to find the correct line length iteratively...")
while True:
try:
record = da.from_array(np.memmap(fdes, mode='r', dtype=dtype, shape=count-1, offset=offset), chunks=(max_lines,))
logger.debug("Found suitable line length")
break
except:
count=count-1
if original_count - count > 10:
logger.debug("Did not found suitable line length, skipping product...")
break
else:
record = np.fromfile(fdes, dtype=dtype, count=count)
offset += dtype.itemsize * count
Expand Down

0 comments on commit 5b9c8cf

Please sign in to comment.