-
Notifications
You must be signed in to change notification settings - Fork 1
/
RRFS.py
executable file
·46 lines (40 loc) · 1.14 KB
/
RRFS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import argparse
import datetime
import logging
import numpy as np
import os
import pandas as pd
import pdb
import pygrib
import s3fs
import sys
import xarray
logging.basicConfig(level=logging.INFO)
# =============Arguments===================
parser = argparse.ArgumentParser(description = "Read AWS", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("itime", help='initialization time')
parser.add_argument("fhr", type=int, help='forecast hour')
parser.add_argument("-d", "--debug", action="store_true", help='debug mode')
args = parser.parse_args()
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)
fhr = args.fhr
itime = pd.to_datetime(args.itime)
odir = os.getenv("TMPDIR")
bucket = 's3://noaa-rrfs-pds'
fs = s3fs.S3FileSystem(anon=True)
url = os.path.join(
"noaa-rrfs-pds",
'rrfs_a',
"rrfs_a." +itime.strftime('%Y%m%d'),
itime.strftime('%H'),
"control"
)
files = fs.ls(url)
pdb.set_trace()
logging.info(f"{len(files)} {url} files")
logging.debug(files)
for f in files:
ofile = os.path.join(odir, os.path.basename(f))
fs.get(f,ofile)
logging.info(ofile)