Functions
---------
-### `get_filenames(product, year, dayofyear, hour)`
+### `get_filenames(product, year, dayofyear, hour, AWS_URL)`
-This function queries AWS for a GOES product on a given hour and date (using day of year instead of month and day). For example, ABI Level 1b data at 02 UTC on January 3rd, 2018 would be called as `get_filenames('ABI-L1b-RadC', '2018', '003', '02')`.
+This function queries AWS for a GOES product on a given hour and date (using day of year instead of month and day). An optional `AWS_URL` can be set for archives besides GOES 16--see below for more info. For example, ABI Level 1b data at 02 UTC on January 3rd, 2018 would be called as `get_filenames('ABI-L1b-RadC', '2018', '003', '02')`.
The output is the returned XML body from the AWS query.
The output is a list of full file names on AWS for the given product, date, and hour.
-### `get_files(filelist, save_path='')`
+### `get_files(filelist, save_path='', AWS_URL)`
-This function downloads files supplied in a `filelist` list. An optional `save_path` will specify the path where files should be saved; by default, files will be downloaded into the current working directory.
+This function downloads files supplied in a `filelist` list. An optional `save_path` will specify the path where files should be saved; by default, files will be downloaded into the current working directory. An optional `AWS_URL` can be set for archives besides GOES 16--see below for more info.
The output is a list of files saved with their local paths.
+
+Custom `AWS_URL`
+---------------
+
+This script is really simple, so right now the url for AWS GOES data is hardcoded in as `"https://s3.amazonaws.com/noaa-goes16/"`. You can alter this url and pass it as an argument to the `get_filenames` and `get_files` functions. The most likely case for this is if you'd prefer to search for GOES 17 data, in which case you would supply `"https://s3.amazonaws.com/noaa-goes17/"`.
from io import BytesIO
import xml.etree.cElementTree as ElementTree
-AWS_URL = "https://s3.amazonaws.com/noaa-goes16/"
-
-def get_filenames(product, year, dayofyear, hour):
+def get_filenames(product, year, dayofyear, hour, AWS_URL="https://s3.amazonaws.com/noaa-goes16/"):
url = "%s?prefix=%s/%s/%s/%s/" % \
(AWS_URL, str(product), str(year), str(dayofyear).zfill(3), str(hour).zfill(2))
content = requests.get(url)
return filenames
-def get_files(filelist, save_path=''):
+def get_files(filelist, save_path='', AWS_URL="https://s3.amazonaws.com/noaa-goes16/"):
files = []
for filename in filelist:
content = requests.get(AWS_URL + filename)