Revision 9bcb2aa4
Added by Benoit Parmentier over 11 years ago
climate/research/oregon/modis-lst/LST_modis_downloading.py | ||
---|---|---|
32 | 32 |
import ftplib |
33 | 33 |
#import grass.script as gs |
34 | 34 |
import argparse |
35 |
|
|
35 |
import errno |
|
36 | 36 |
#from datetime import date |
37 | 37 |
#from datetime import datetime |
38 | 38 |
|
... | ... | |
177 | 177 |
hdfs.append(os.path.abspath(files[0])) |
178 | 178 |
return hdfs |
179 | 179 |
|
180 |
|
|
180 |
def create_dir_and_check_existence(path): |
|
181 |
try: |
|
182 |
os.makedirs(path) |
|
183 |
except OSError as exception: |
|
184 |
if exception.errno != errno.EEXIST: |
|
185 |
raise |
|
186 |
|
|
181 | 187 |
def main(): |
182 | 188 |
#from sys import argv # example client code |
183 | 189 |
#myargs = getopts(argv) |
184 | 190 |
|
185 |
import argparse |
|
191 |
#import argparse
|
|
186 | 192 |
parser = argparse.ArgumentParser() |
187 | 193 |
parser.add_argument("tiles", type=str, help="list of Modis tiles") |
188 | 194 |
parser.add_argument("start_year", type=int, help="start year") |
... | ... | |
198 | 204 |
|
199 | 205 |
tiles = myargs.tiles #These tiles correspond to Venezuela. |
200 | 206 |
start_year = myargs.start_year |
201 |
end_year = myargs.start_year
|
|
207 |
end_year = myargs.end_year
|
|
202 | 208 |
end_month = myargs.end_month |
203 | 209 |
start_month= myargs.start_month |
204 | 210 |
hdfdir = myargs.hdfdir |
... | ... | |
216 | 222 |
print 'this is the result',str(year_list) |
217 | 223 |
print(myargs) |
218 | 224 |
print(tiles) |
219 |
|
|
225 |
|
|
226 |
|
|
220 | 227 |
#tiles = ['h11v08','h11v07','h12v07','h12v08','h10v07','h10v08'] #These tiles correspond to Venezuela. |
221 | 228 |
#start_year = 2001 |
222 | 229 |
#end_year = 2010 |
... | ... | |
236 | 243 |
#tiles = ['h10v07','h10v08','h12v07'] |
237 | 244 |
if download==1: |
238 | 245 |
for tile in tiles: |
246 |
outDir = os.path.join(hdfdir,tile) |
|
247 |
create_dir_and_check_existence(outDir) |
|
248 |
|
|
239 | 249 |
for year in year_list: |
240 | 250 |
start_doy = 1 |
241 | 251 |
end_doy = 365 |
242 | 252 |
if calendar.isleap(year): |
243 | 253 |
end_doy=366 |
244 | 254 |
|
245 |
hdfs = download_mod11a1(hdfdir, tile, start_doy, end_doy, year)
|
|
255 |
hdfs = download_mod11a1(outDir, tile, start_doy, end_doy, year)
|
|
246 | 256 |
|
247 | 257 |
if __name__ == '__main__': |
248 | 258 |
main() |
Also available in: Unified diff
handling modis dowloading outputs