Created
June 28, 2016 04:22
-
-
Save Akramz/9aac58dca2f948b64c408c98664a19ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import time | |
import os.path | |
from sys import exit | |
from subprocess import call | |
import datetime | |
import urllib | |
# years | |
years = [2016] | |
months = [range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32), | |
range(1, 32) | |
] | |
hours = ['00', '03', '06', '09', '12', '15', '18', '21'] | |
# get today | |
now_date = datetime.date.today() | |
i = 0 # number of empty files | |
for year in years: | |
for month, month_days in enumerate(months): | |
for day in month_days: | |
for hour in hours: | |
file_title = str(year) + '-' + str(month+1).zfill(2) + '-' + str(day).zfill(2) + '-' + str(hour) | |
saving_file = "/home/akram/datasets/clouds_images/" + file_title + ".jpeg" | |
saving_file_error = "/home/akram/datasets/clouds_images/" + file_title + ".txt" | |
print 'Date : ', file_title | |
if os.path.exists( saving_file ) == False: | |
try: | |
urllib.urlretrieve("http://www.ncdc.noaa.gov/gibbs/image/MSG-3/IR/" + file_title, saving_file) | |
except: | |
with open(saving_file_error, "a") as myfile: | |
myfile.write("error getting it (connection)!") | |
print "number of empty files removed : ", i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment