Skip to content

Commit

Permalink
Fix ABI mid-latitude cyclone demo downloading wrong number of files
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Aug 3, 2020
1 parent f80c568 commit a8a08f9
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions satpy/demo/__init__.py
Expand Up @@ -56,18 +56,6 @@
LOG = logging.getLogger(__name__)


def _makedirs(directory, exist_ok=False):
"""Python 2.7 friendly os.makedirs.
After python 2.7 is dropped, just use `os.makedirs` with `existsok=True`.
"""
try:
os.makedirs(directory)
except OSError:
if not exist_ok:
raise


def get_us_midlatitude_cyclone_abi(base_dir='.', method=None, force=False):
"""Get GOES-16 ABI (CONUS sector) data from 2019-03-14 00:00Z.
Expand All @@ -90,16 +78,16 @@ def get_us_midlatitude_cyclone_abi(base_dir='.', method=None, force=False):
"implemented yet.".format(method))

from ._google_cloud_platform import get_bucket_files
patterns = ['gs://gcp-public-data-goes-16/ABI-L1b-RadC/2019/073/00/*0002*.nc']
patterns = ['gs://gcp-public-data-goes-16/ABI-L1b-RadC/2019/073/00/*s20190730002*.nc']
subdir = os.path.join(base_dir, 'abi_l1b', '20190314_us_midlatitude_cyclone')
_makedirs(subdir, exist_ok=True)
os.makedirs(subdir, exist_ok=True)
filenames = get_bucket_files(patterns, subdir, force=force)
assert len(filenames) == 16, "Not all files could be downloaded"
return filenames


def get_hurricane_florence_abi(base_dir='.', method=None, force=False,
channels=range(1, 17), num_frames=10):
channels=None, num_frames=10):
"""Get GOES-16 ABI (Meso sector) data from 2018-09-11 13:00Z to 17:00Z.
Args:
Expand All @@ -122,6 +110,8 @@ def get_hurricane_florence_abi(base_dir='.', method=None, force=False,
Total size (240 frames, all channels): ~3.5GB
"""
if channels is None:
channels = range(1, 17)
if method is None:
method = 'gcsfs'
if method not in ['gcsfs']:
Expand All @@ -145,7 +135,7 @@ def get_hurricane_florence_abi(base_dir='.', method=None, force=False,
'gs://gcp-public-data-goes-16/ABI-L1b-RadM/2018/254/16/*RadM1*C{:02d}*s201825416*.nc'.format(channel),
)]
subdir = os.path.join(base_dir, 'abi_l1b', '20180911_hurricane_florence_abi_l1b')
_makedirs(subdir, exist_ok=True)
os.makedirs(subdir, exist_ok=True)
filenames = get_bucket_files(patterns, subdir, force=force, pattern_slice=frame_slice)

actual_slice = frame_slice.indices(240) # 240 max frames
Expand Down

0 comments on commit a8a08f9

Please sign in to comment.