def main(argv): inps = cmdLineParse() url_txt = inps.url_list_txt user_name = inps.user_name password = inps.password url_list = ut.read_txt2list(url_txt) parallel0 = inps.parallelNumb print('Download file list: ' + str(len(url_list))) print('Downloading data now, %s at a time.' % str(parallel0)) #create a queue for parallel downloading queue = Queue() #spawn a pool of threads, and pass them queue instance for i in range(parallel0): t = ThreadDownload(queue) t.setDaemon(True) t.start() #populate queue with data for d in sorted(url_list): queue.put([d, user_name, password]) #wait on the queue until everything has been processed queue.join()
def main(argv): inps = cmdLineParse() projectName = inps.projectName date = inps.date scratchDir = os.getenv('SCRATCHDIR') projectDir = scratchDir + '/' + projectName templateDir = os.getenv('TEMPLATEDIR') templateFile = templateDir + "/" + projectName + ".template" templateDict=ut.update_template(templateFile) slc_dir = projectDir + '/SLC' rslc_dir = projectDir + '/RSLC' down_dir = projectDir + '/DOWNLOAD' opod_dir = projectDir + '/OPOD' if not os.path.isdir(slc_dir): os.mkdir(slc_dir) if not os.path.isdir(opod_dir): os.mkdir(opod_dir) work_dir = slc_dir + '/' + date if not os.path.isdir(work_dir): os.mkdir(work_dir) os.chdir(work_dir) master_burst_numb = down_dir + '/master.burst_numb_table' if not os.path.isfile(master_burst_numb): call_str = 'get_master_burst_numb.py ' + projectDir os.system(call_str) t_date = 't_' + date call_str = 'ls ' + down_dir + '/S1*' + date + '*.zip > ' + t_date os.system(call_str) start_swath = templateDict['start_swath'] end_swath = templateDict['end_swath'] if (start_swath == '1') and (end_swath == '1'): k_swath = '1' elif (start_swath == '2') and (end_swath == '2'): k_swath = '2' elif (start_swath == '3') and (end_swath == '3'): k_swath = '3' elif (start_swath == '1') and (end_swath == '2'): k_swath = '4' elif (start_swath == '2') and (end_swath == '3'): k_swath = '5' elif (start_swath == '1') and (end_swath == '3'): k_swath = '0' raw_files = ut.read_txt2list(t_date) satellite = get_satellite(raw_files[0]) orbit_file = ut.download_s1_orbit(date,opod_dir,satellite=satellite) call_str = 'S1_import_SLC_from_zipfiles ' + t_date + ' ' + master_burst_numb + ' vv 0 ' + k_swath + ' ' + opod_dir + ' 1 1 ' os.system(call_str) os.chdir(work_dir) call_str = "rename 's/vv.slc.iw1/IW1.slc/g' *" os.system(call_str) call_str = "rename 's/vv.slc.iw2/IW2.slc/g' *" os.system(call_str) call_str = "rename 's/vv.slc.iw3/IW3.slc/g' *" os.system(call_str) call_str = "rename 's/.tops_par/.TOPS_par/g' *" os.system(call_str) SLC_Tab = work_dir + '/' + date+'_SLC_Tab' RSLC_Tab = work_dir + '/' + date+'_RSLC_Tab' SLC_list = glob.glob(work_dir + '/*IW*.slc') SLC_par_list = glob.glob(work_dir + '/*IW*.slc.par') TOP_par_list = glob.glob(work_dir + '/*IW*.slc.TOPS_par') if os.path.isfile(SLC_Tab): os.remove(SLC_Tab) if os.path.isfile(RSLC_Tab): os.remove(RSLC_Tab) SLC_list = sorted(SLC_list) SLC_par_list = sorted(SLC_par_list) TOP_par_list = sorted(TOP_par_list) for kk in range(len(SLC_list)): call_str = 'echo ' + SLC_list[kk] + ' ' + SLC_par_list[kk] + ' ' + TOP_par_list[kk] + ' >> ' + SLC_Tab os.system(call_str) call_str = 'echo ' + rslc_dir + '/' + date + '/' + os.path.basename(SLC_list[kk]).replace('.slc','.rslc') + ' ' + rslc_dir + '/' + date + '/'+ os.path.basename(SLC_par_list[kk]).replace('.slc','.rslc') + ' ' + rslc_dir + '/' + date + '/' + os.path.basename(TOP_par_list[kk]).replace('.slc','.rslc') + ' >> ' + RSLC_Tab os.system(call_str) BURST = SLC_par_list[kk].replace('slc.par','burst.par') KML = SLC_par_list[kk].replace('slc.par','kml') call_str = 'ScanSAR_burst_corners ' + SLC_par_list[kk] + ' ' + TOP_par_list[kk] + ' ' + KML + ' > ' +BURST os.system(call_str) print("Down to SLC for %s is done! " % date) sys.exit(1)
def main(argv): inps = cmdLineParse() projectName = inps.projectName scratchDir = os.getenv('SCRATCHDIR') projectDir = scratchDir + '/' + projectName templateDir = os.getenv('TEMPLATEDIR') templateFile = templateDir + "/" + projectName + ".template" templateDict=ut.update_template(templateFile) masterDate = templateDict['masterDate'] date = masterDate slc_dir = projectDir + '/SLC' down_dir = projectDir + '/DOWNLOAD' opod_dir = projectDir + '/OPOD' if not os.path.isdir(slc_dir): os.mkdir(slc_dir) if not os.path.isdir(opod_dir): os.mkdir(opod_dir) work_dir = slc_dir + '/' + date if not os.path.isdir(work_dir): os.mkdir(work_dir) work_dir = down_dir os.chdir(work_dir) t_date = down_dir + '/t_' + date t_burst_numb = down_dir + '/t_burst_numb_' + date call_str = 'ls ' + down_dir + '/S1*' + date + '*.zip > ' + t_date os.system(call_str) zip_files = ut.read_txt2list(t_date) print(zip_files) for i in range(len(zip_files)): call_str = 'S1_BURST_tab_from_zipfile - ' + zip_files[i] + ' - ' os.system(call_str) call_str = 'ls ' + down_dir + '/S1*' + date + '*.burst_number_table > ' + t_burst_numb os.system(call_str) burst_files = ut.read_txt2list(t_burst_numb) iw1_burst_node = [] iw2_burst_node = [] iw3_burst_node = [] print(burst_files) for i in range(len(burst_files)): print(burst_files[i]) iw1_first = ut.read_gamma_par(str(burst_files[i]),'read','iw1_first_burst') iw1_last = ut.read_gamma_par(str(burst_files[i]),'read','iw1_last_burst') iw1_burst_node.append(float(iw1_first)) iw1_burst_node.append(float(iw1_last)) iw2_first = ut.read_gamma_par(str(burst_files[i]),'read','iw2_first_burst') iw2_last = ut.read_gamma_par(str(burst_files[i]),'read','iw2_last_burst') iw2_burst_node.append(float(iw2_first)) iw2_burst_node.append(float(iw2_last)) iw3_first = ut.read_gamma_par(str(burst_files[i]),'read','iw3_first_burst') iw3_last = ut.read_gamma_par(str(burst_files[i]),'read','iw3_last_burst') iw3_burst_node.append(float(iw3_first)) iw3_burst_node.append(float(iw3_last)) if 'iw1_first_burst' in templateDict: IW1_0 = templateDict['iw1_first_burst'] else: IW1_0 = '1' if 'iw1_last_burst' in templateDict: IW1_1 = templateDict['iw1_last_burst'] else: IW1_1 = str(round(max(iw1_burst_node) - min(iw1_burst_node) + 1)) if 'iw2_first_burst' in templateDict: IW2_0 = templateDict['iw2_first_burst'] else: IW2_0 = '1' if 'iw2_last_burst' in templateDict: IW2_1 = templateDict['iw2_last_burst'] else: IW2_1 = str(round(max(iw2_burst_node) - min(iw2_burst_node) + 1)) if 'iw3_first_burst' in templateDict: IW3_0 = templateDict['iw3_first_burst'] else: IW3_0 = '1' if 'iw3_last_burst' in templateDict: IW3_1 = templateDict['iw3_last_burst'] else: IW3_1 = str(round(max(iw3_burst_node) - min(iw3_burst_node) + 1)) if int(IW1_1) > round(max(iw1_burst_node) - min(iw1_burst_node) + 1): IW1_1 = str(round(max(iw1_burst_node) - min(iw1_burst_node) + 1)) if int(IW2_1) > round(max(iw2_burst_node) - min(iw2_burst_node) + 1): IW2_1 = str(round(max(iw2_burst_node) - min(iw2_burst_node) + 1)) if int(IW3_1) > round(max(iw3_burst_node) - min(iw3_burst_node) + 1): IW3_1 = str(round(max(iw3_burst_node) - min(iw3_burst_node) + 1)) D_IW1_first = int(IW1_0) - 1 DD_IW1_numb = int(IW1_1) - int(IW1_0) + 1 D_IW2_first = int(IW2_0) - 1 DD_IW2_numb = int(IW2_1) - int(IW2_0) + 1 D_IW3_first = int(IW3_0) - 1 DD_IW3_numb = int(IW3_1) - int(IW3_0) + 1 master_busrt = down_dir + '/master.burst_numb_table' if os.path.isfile(master_busrt): os.remove(master_busrt) with open(master_busrt, 'a') as f: STR0 = 'iw1_number_of_bursts: ' + str(DD_IW1_numb) + '\n' STR00 = 'iw1_number_of_bursts: ' + str(DD_IW1_numb) print(STR00) f.write(STR0) STR0 = 'iw1_first_burst: ' + str(min(iw1_burst_node) + D_IW1_first) + '\n' STR00 = 'iw1_first_burst: ' + str(min(iw1_burst_node) + D_IW1_first) print(STR00) f.write(STR0) STR0 = 'iw1_last_burst: ' + str(min(iw1_burst_node) + DD_IW1_numb - 1) + '\n' STR00 = 'iw1_last_burst: ' + str(min(iw1_burst_node) + DD_IW1_numb - 1) print(STR00) f.write(STR0) STR0 = 'iw2_number_of_bursts: ' + str(DD_IW2_numb) + '\n' STR00 = 'iw2_number_of_bursts: ' + str(DD_IW2_numb) print(STR00) f.write(STR0) STR0 = 'iw2_first_burst: ' + str(min(iw2_burst_node) + D_IW1_first) + '\n' STR00 = 'iw2_first_burst: ' + str(min(iw2_burst_node) + D_IW1_first) print(STR00) f.write(STR0) STR0 = 'iw2_last_burst: ' + str(min(iw2_burst_node) + DD_IW2_numb - 1) + '\n' STR00 = 'iw2_last_burst: ' + str(min(iw2_burst_node) + DD_IW2_numb - 1) print(STR00) f.write(STR0) STR0 = 'iw3_number_of_bursts: ' + str(DD_IW3_numb) + '\n' STR00 = 'iw3_number_of_bursts: ' + str(DD_IW3_numb) print(STR00) f.write(STR0) STR0 = 'iw3_first_burst: ' + str(min(iw3_burst_node) + D_IW3_first) + '\n' STR00 = 'iw3_first_burst: ' + str(min(iw3_burst_node) + D_IW3_first) print(STR00) f.write(STR0) STR0 = 'iw3_last_burst: ' + str(min(iw3_burst_node) + DD_IW3_numb - 1) + '\n' STR00 = 'iw3_last_burst: ' + str(min(iw3_burst_node) + DD_IW3_numb - 1) print(STR00) f.write(STR0) print("Get burst number table for master date is done! ") sys.exit(1)