Created
October 30, 2013 18:10
-
-
Save tristanwietsma/7237299 to your computer and use it in GitHub Desktop.
Downloader for NEXRAD GeoTIFF composites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import exit, argv | |
import datetime, zipfile | |
import requests | |
def dlhook(r, *args, **kwargs): | |
print('GET %s'%str(r.url)) | |
base_url = "http://mesonet.agron.iastate.edu/request/gis/n0r2gtiff.php?dstr=%s" | |
def fetch(tme): | |
tm = tme.strftime('%Y%m%d%H%M') | |
url = base_url%tm | |
req = requests.get(url, hooks=dict(response=dlhook)) | |
with open('%s.zip'%tm, 'w') as myzip: | |
myzip.write(req.content) | |
def fetch_range(start, stop): | |
while start < stop: | |
fetch(start) | |
start += datetime.timedelta(seconds=5*60) | |
if __name__ == '__main__': | |
begin = datetime.datetime(2013, 1, 1) | |
end = datetime.datetime(2013, 1, 2) | |
fetch_range(begin, end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment