-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgldas.py
More file actions
44 lines (33 loc) · 841 Bytes
/
gldas.py
File metadata and controls
44 lines (33 loc) · 841 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
import glob, time
import requests
import os.path
def download( url ):
filename = url[274:286]+".nc"
if os.path.isfile( "GLDAS_MOS025SUBP_3H/"+filename ):
print("Skipping "+filename)
else :
print("Downloading "+filename)
res = requests.get( url )
file = open( "GLDAS_MOS025SUBP_3H/"+filename , 'wb' ) # characters 263:270 contains datetime information
file.write( res.content )
file.close()
def bulkDownload( files ):
for file in files:
print("Reading "+file)
f = open( file )
text = f.read()
urls = text.split('\n')
for url in urls:
try:
download( url )
except requests.exceptions.MissingSchema:
pass
files = glob.glob("*.inp")
bulkDownload( files )
'''f = open("2002019.2100.inp")
text = f.read()
urls = text.split('\n')
for i in range(5069,5070):
download( urls[i] )
time.sleep(1)
'''