Skip to content

Commit

Permalink
bail out on missing "no image" tiles
Browse files Browse the repository at this point in the history
Using the UTC offset feature can result in "No Image" tiles. himawaripy
will get the timestamp of the latest sattelite image, subtract or add
the offset, and assume an image exists for the newly calculated time.
This is correct most of the time, but occasionally results in a
timestamp for which there is no satellite image. In this case, the
service returns black tiles with the text "No Image".

These blank "No Image" tiles are always 2867 bytes (regardless of the
quality level). Legitimate tiles are always a different size (smaller if
they are the solid black surrounding Earth, larger if they are part of
Earth). By checking the size of each tile immediately after download and
bailing out if the tile is 2867 bytes, we can avoid downloading the
remaining tiles and stitching them together into a large series of "No
Image".

Exiting the program here must be done with `os._exit()` because this
part is multi-threaded. I'm using exit code 3 just so to have a unique
reason so that other programs can understand why himawaripy exited at
this point.

I've been using this for about a week now and it works great. It is
refreshing to constantly have satellite photos and not see the
occasional "No Image" interruption.

The "No Image" issue was previously discussed in boramalper#82 and boramalper#68.
  • Loading branch information
pigmonkey committed Apr 1, 2018
1 parent 1091e40 commit 3149e82
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions himawaripy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def download_chunk(args):

tiledata = download(url)

# If the tile data is 2867 bytes, it is a blank "No Image" tile.
if tiledata.__sizeof__() == 2867:
print('No image available for {}.'.format(strftime("%Y/%m/%d %H:%M:%S", latest)))
os._exit(3)

with counter.get_lock():
counter.value += 1
if counter.value == level * level:
Expand Down

0 comments on commit 3149e82

Please sign in to comment.