Include option for other GOES
authorEthan Nelson <git@ethan-nelson.com>
Sat, 1 Jun 2019 16:48:15 +0000 (11:48 -0500)
committerEthan Nelson <git@ethan-nelson.com>
Sat, 1 Jun 2019 16:48:15 +0000 (11:48 -0500)
README.md
pygoes.py

index 71ce710..2fac0c9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -8,9 +8,9 @@ The `example()` script contains an example sequence to use all of the functions.
 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.
 
@@ -20,8 +20,13 @@ This function takes the returned XML from `get_filenames` and extracts all of th
 
 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/"`.
index b5734f2..ba5d9a6 100644 (file)
--- a/pygoes.py
+++ b/pygoes.py
@@ -6,10 +6,8 @@ import requests
 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)
@@ -30,7 +28,7 @@ def parse_xml(content):
 
     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)