-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGOESpolling.py
33 lines (24 loc) · 1009 Bytes
/
GOESpolling.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
import s3fs
import numpy as np
import os
# Use the anonymous credentials to access public data
fs = s3fs.S3FileSystem(anon=True)
# Get latest scan from bucket
# satellite=goes16 or goes17; domain=FULLDISK, CONUS, M1, or M2
def getLatestScan(satellite, product, domain, channel, download=False, path=''):
# List contents of GOES bucket
goesData = np.array(fs.ls('s3://noaa-' + satellite + '/' + product + domain[0]))
# Get Latest Year
goesData = np.array(fs.ls(goesData[len(goesData)-1]))
# Get Latest Day
goesData = np.array(fs.ls(goesData[len(goesData)-1]))
# Get Latest Hour
goesData = np.array(fs.ls(goesData[len(goesData)-1]))
# Get Latest Scan
scanNum = int((len(goesData) / 16) * channel)-1
fileName=goesData[scanNum][goesData[scanNum].rindex('/'):]
# Download scan
if download and os.path.exists(path):
if os.path.exists(f'{path}/{fileName}') == False:
fs.get(goesData[scanNum], f'{path}/{fileName}')
return fileName