diff --git a/pyint/COREG_ALL_Gamma.py.bak b/pyint/COREG_ALL_Gamma.py.bak deleted file mode 100755 index 1017340..0000000 --- a/pyint/COREG_ALL_Gamma.py.bak +++ /dev/null @@ -1,252 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_coreg_all(projectName,master,slavelist,workdir): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - run_coreg_all = projectDir + "/run_coreg_all" - f_coreg = open(run_coreg_all,'w') - - for kk in range(len(slavelist)): - str_coreg = "GenOff_DEM_Gamma.py " + projectName + ' ' + master + ' ' + slavelist[kk] + ' ' + workdir + '\n' - f_coreg.write(str_coreg) - f_coreg.close() - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Coregistrate all of SAR images to one master image based on cross-correlation. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. -''' - -EXAMPLE = ''' - Usage: - COREG_ALL_Gamma.py projectName - - Examples: - COREG_ALL_Gamma.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Batch processing pegasus jobs.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('project',help='Project name of coregistration.') - - inps = parser.parse_args() - - if not inps.project: - parser.print_usage() - sys.exit(os.path.basename(sys.argv[0])+': error: project name should be provided.') - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - - projectName = inps.project - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDIR = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - - templateContents = read_template(templateFile) - if 'memory_Coreg' in templateContents : memory_Coreg = templateContents['memory_Coreg'] - else: memory_Coreg = '3700' - if 'walltime_Coreg' in templateContents : walltime_Coreg = templateContents['walltime_Coreg'] - else: walltime_Coreg = '1:00' - -##################### Extract SLC Date ################################# - - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - print "All of the available SAR acquisition datelist is :" - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - print ListSLC[kk] - str_slc = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc" - str_slc_par = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc.par" - SLCfile.append(str_slc) - SLCParfile.append(str_slc_par) - - if 'masterDate' in templateContents : - masterDate = templateContents['masterDate'] - if masterDate in Datelist: - print "masterDate: %s" % masterDate - else: - print "The selected masterdate %s is not in the date list!! " % masterDate - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - else: - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - - SLAVElist = Datelist - del SLAVElist[Datelist.index(masterDate)] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - if 'DEM' in templateContents : - DEM = templateContents['DEM'] - if not os.path.isfile(DEM): - print 'Provided DEM is not available, a new DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - else: - print 'DEM is not provided in the template file, a DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - - - run_coreg_all = projectDir + "/run_coreg_all" - if os.path.isfile(run_coreg_all): - os.remove(run_coreg_all) - - call_str ='rm job*' - os.system(call_str) - - write_run_coreg_all(projectName,masterDate,SLAVElist,rslcDir) - - call_str='$INT_SCR/createBatch.pl ' + projectDir+'/run_coreg_all memory=' + memory_Coreg + ' walltime=' + walltime_Coreg - os.system(call_str) - - - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - diff --git a/pyint/COREG_ALL_Sen_Gamma.py.bak b/pyint/COREG_ALL_Sen_Gamma.py.bak deleted file mode 100755 index d82f323..0000000 --- a/pyint/COREG_ALL_Sen_Gamma.py.bak +++ /dev/null @@ -1,265 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_coreg_all(projectName,master,slavelist,workdir): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - run_coreg_all = workdir + "/run_coreg_all" - f_coreg = open(run_coreg_all,'w') - - for kk in range(len(slavelist)): - str_coreg = "GenOff_DEM_Sen_Gamma.py " + projectName + ' ' + master + ' ' + slavelist[kk] + ' ' + workdir +'/' + slavelist[kk] + '\n' - f_coreg.write(str_coreg) - f_coreg.close() - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Coregistrate all of SAR images to one master image based on cross-correlation. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. -''' - -EXAMPLE = ''' - Usage: - COREG_ALL_Sen_Gamma.py projectName - - Examples: - COREG_ALL_Sen_Gamma.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Batch processing pegasus jobs.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('project',help='Project name of coregistration.') - - inps = parser.parse_args() - - if not inps.project: - parser.print_usage() - sys.exit(os.path.basename(sys.argv[0])+': error: project name should be provided.') - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - - projectName = inps.project - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDIR = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - templateContents = read_template(templateFile) - if 'memory_Coreg' in templateContents : memory_Coreg = templateContents['memory_Coreg'] - else: memory_Coreg = '5000' - if 'walltime_Coreg' in templateContents : walltime_Coreg = templateContents['walltime_Coreg'] - else: walltime_Coreg = '2:00' - -##################### Extract SLC Date ################################# - - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - print "All of the available SAR acquisition datelist is :" - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - print ListSLC[kk] - str_slc = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc" - str_slc_par = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc.par" - SLCfile.append(str_slc) - SLCParfile.append(str_slc_par) - - if 'masterDate' in templateContents : - masterDate = templateContents['masterDate'] - if masterDate in Datelist: - print "masterDate: %s" % masterDate - else: - print "The selected masterdate %s is not in the date list!! " % masterDate - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - else: - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - - SLAVElist = Datelist - del SLAVElist[Datelist.index(masterDate)] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - if 'DEM' in templateContents : - DEM = templateContents['DEM'] - if not os.path.isfile(DEM): - print 'Provided DEM is not available, a new DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - else: - print 'DEM is not provided in the template file, a DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - - masterRdcDEM = scratchDir + '/' + projectName + "/PROCESS/DEM/sim_" + masterDate + "_" + rlks + "rlks.rdc.dem" - - if not os.path.isfile(masterRdcDEM): - call_str = 'Generate_RdcDEM_Sen_Gamma.py ' + projectName + ' ' + masterDate - os.system(call_str) - - run_coreg_all = projectDir + "/run_coreg_all" - if os.path.isfile(run_coreg_all): - os.remove(run_coreg_all) - - - write_run_coreg_all(projectName,masterDate,SLAVElist,rslcDir) - - call_str = 'rm job*' - os.system(call_str) - - call_str='$INT_SCR/createBatch.pl ' + rslcDir+'/run_coreg_all memory=' + memory_Coreg + ' walltime=' + walltime_Coreg - os.system(call_str) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - diff --git a/pyint/Check_Common_Burst.py.bak b/pyint/Check_Common_Burst.py.bak deleted file mode 100755 index d8895c0..0000000 --- a/pyint/Check_Common_Burst.py.bak +++ /dev/null @@ -1,204 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - return min(Mindex) , max(Mindex), min(Sindex),max(Sindex) - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Check the common bursts for S1 TOPs. -''' - -EXAMPLE = ''' - Usage: - Common_Burst_check.py igramDir - - Examples: - Check_Common_Burst.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('igramDir',help='Interferogram directory name.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - igramDir = inps.igramDir - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - #MBurst_Par = slcDir + '/' + Mdate + '/' + - BURST = processDir + '/' + igramDir + '/' + Mdate + '_' + Sdate + '.common_burst' - if os.path.isfile(BURST): - os.remove(BURST) - - for kk in range(3): - MBURST = MslcDir + '/' + Mdate + '.IW' + str(kk+1)+'.burst.par' - SBURST = SslcDir + '/' + Sdate + '.IW' + str(kk+1)+'.burst.par' - fm = open(MBURST,'r') - fs = open(SBURST,'r') - Mtt =workDir + '/Mtt' - Stt =workDir + '/Stt' - fm0 = open(Mtt,'w') - fs0 = open(Stt,'w') - for line in fm: - if 'Burst:' in line: - #print line - fm0.writelines(line) - fm0.close() - fm.close() - - for line in fs: - if 'Burst:' in line: - #print line - fs0.writelines(line) - fs0.close() - fs.close() - - MM = np.loadtxt(Mtt,dtype=str) - La_M = MM[:,2] - - SM = np.loadtxt(Stt,dtype=str) - La_S = SM[:,2] - - PP = common_burst(La_M,La_S) - - print 'Common bursts of swath' + str(kk+1) + ' : (master) ' + str(PP[0]) + ' ' + str(PP[1]) + ' (slave) ' + str(PP[2]) + ' ' + str(PP[3]) - call_str = 'echo ' + str(PP[0]) + ' ' + str(PP[1]) + ' ' + str(PP[2]) + ' ' + str(PP[3]) + ' >>' + BURST - os.system(call_str) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Check_Common_Burst_All.py.bak b/pyint/Check_Common_Burst_All.py.bak deleted file mode 100755 index 97fd8ac..0000000 --- a/pyint/Check_Common_Burst_All.py.bak +++ /dev/null @@ -1,244 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst_Ref(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - M1 = min(Mindex) - M2 = max(Mindex) - - S1 = min(Sindex) - S2 = max(Sindex) - - if M1==1: S1 = S1 - else: - S1=1-M1+1 - M1=1 - - - if M2 ==len(La_M): S2 = S2 - else: - S2 = S2 + len(La_M) - M2 - M2 = len(La_M) - - - return M1 , M2, S1, S2 - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Check the common bursts for S1 TOPs for the whole project based on master date. -''' - -EXAMPLE = ''' - Usage: - Common_Burst_check_All.py projectName - - Examples: - Check_Common_Burst_All.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - map(str,Datelist) - - if 'masterDate' in templateContents: - masterDate0 = templateContents['masterDate'] - if masterDate0 in Datelist: - masterDate = masterDate0 - print "masterDate : " + masterDate0 - else: - masterDate=Datelist[0] - print "The selected masterDate is not included in above datelist !!" - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - call_str = 'echo masterDate = ' + masterDate + ' >> ' + templateFile - os.system(call_str) - - else: - masterDate=Datelist[0] - print "masterDate is not found in template!!! " - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - call_str = 'echo masterDate = ' + masterDate + ' >> ' + templateFile - os.system(call_str) - - Mdate = masterDate - for kk in Datelist: - Sdate = kk - workDir = rslcDir + '/' + kk - if not os.path.isdir(workDir): - call_str = 'mkdir ' + workDir - os.system(call_str) - - call_str = 'Check_Common_Burst_Ref.py ' + projectName + ' ' + Mdate + ' ' + Sdate + ' --dir ' + workDir - os.system(call_str) - - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Check_Common_Burst_Ref.py.bak b/pyint/Check_Common_Burst_Ref.py.bak deleted file mode 100755 index 83b6a81..0000000 --- a/pyint/Check_Common_Burst_Ref.py.bak +++ /dev/null @@ -1,222 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst_Ref(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - M1 = min(Mindex) - M2 = max(Mindex) - - S1 = min(Sindex) - S2 = max(Sindex) - - if M1==1: S1 = S1 - else: - S1=1-M1+1 - M1=1 - - - if M2 ==len(La_M): S2 = S2 - else: - S2 = S2 + len(La_M) - M2 - M2 = len(La_M) - - - return M1 , M2, S1, S2 - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Check the common bursts for S1 TOPs. -''' - -EXAMPLE = ''' - Usage: - Common_Burst_check_Ref.py projectName Mdate Sdate - - Examples: - Check_Common_Burst_Ref.py PacayaT163TsxHhA 131021 131101 -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - parser.add_argument('RefDate',help='Referred date, i.e., master date.') - parser.add_argument('SlaveDate',help='Slave date.') - parser.add_argument('--dir',dest='workdir', help='work directory.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - Mdate = inps.RefDate - Sdate = inps.SlaveDate - - if inps.workdir: workDir =inps.workdir - else: workDir = os.getcwd() - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - #MBurst_Par = slcDir + '/' + Mdate + '/' + - BURST = workDir + '/' + Mdate + '_' + Sdate + '.common_burst_ref' - if os.path.isfile(BURST): - os.remove(BURST) - - for kk in range(3): - MBURST = MslcDir + '/' + Mdate + '.IW' + str(kk+1)+'.burst.par' - SBURST = SslcDir + '/' + Sdate + '.IW' + str(kk+1)+'.burst.par' - fm = open(MBURST,'r') - fs = open(SBURST,'r') - Mtt =workDir + '/Mtt' - Stt =workDir + '/Stt' - fm0 = open(Mtt,'w') - fs0 = open(Stt,'w') - for line in fm: - if 'Burst:' in line: - #print line - fm0.writelines(line) - fm0.close() - fm.close() - - for line in fs: - if 'Burst:' in line: - #print line - fs0.writelines(line) - fs0.close() - fs.close() - - MM = np.loadtxt(Mtt,dtype=str) - La_M = MM[:,2] - - SM = np.loadtxt(Stt,dtype=str) - La_S = SM[:,2] - - PP = common_burst_Ref(La_M,La_S) - - print 'Common bursts of swath' + str(kk+1) + ' : (master) ' + str(PP[0]) + ' ' + str(PP[1]) + ' (slave) ' + str(PP[2]) + ' ' + str(PP[3]) - call_str = 'echo ' + str(PP[0]) + ' ' + str(PP[1]) + ' ' + str(PP[2]) + ' ' + str(PP[3]) + ' >>' + BURST - os.system(call_str) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/CoregistSLC_DEM_Gamma.py.bak b/pyint/CoregistSLC_DEM_Gamma.py.bak deleted file mode 100755 index 74cb6ea..0000000 --- a/pyint/CoregistSLC_DEM_Gamma.py.bak +++ /dev/null @@ -1,379 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Coregistrate all of SAR images to one master image based on cross-correlation. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. -''' - -EXAMPLE = ''' - Usage: - CoregistSLC_DEM_Gamma.py igramDir - - Examples: - CoregistSLC_DEM_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Batch processing pegasus jobs.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('igramDir',help='Interferogram directory name.') - - inps = parser.parse_args() - - if not inps.igramDir: - parser.print_usage() - sys.exit(os.path.basename(sys.argv[0])+': error: Interferogram interferogram directory name should be provided.') - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - igramDir = inps.igramDir - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - demDir = processDir + '/DEM' - - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '32' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - masterDate = templateContents['masterDate'] -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = rslcDir + "/" + Mdate + ".rslc" - MslcPar = rslcDir + "/" + Mdate + ".rslc.par" - SslcImg = rslcDir + "/" + Sdate + ".rslc" - SslcPar = rslcDir + "/" + Sdate + ".rslc.par" - -# output slcs - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - Srslc0Img = workDir + "/" + Sdate + ".rslc0" - Srslc0Par = workDir + "/" + Sdate + ".rslc0.par" -# output multi-looked amplitude - - MamprlksImg = workDir + "/" + Mdate + "_" + rlks+"rlks.amp" - MamprlksPar = workDir + "/" + Mdate + "_" + rlks+"rlks.amp.par" - SamprlksImg = workDir + "/" + Sdate + "_" + rlks+"rlks.amp" - SamprlksPar = workDir + "/" + Sdate + "_" + rlks+"rlks.amp.par" - - OFFSTD = workDir + "/" + Mdate + "-" + Sdate + ".off_std" - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - HGTSIM = demDir + '/sim_' + masterDate + '_'+rlks+'rlks.rdc.dem' - if not os.path.isfile(HGTSIM): - call_str = 'Generate_RdcDEM_Gamma.py ' + projectName + ' ' + masterDate - os.system(call_str) - - lt0 = workDir + "/lt0" - lt1 = workDir + "/lt1" - mli0 = workDir + "/mli0" - diff0 = workDir + "/diff0" - offs0 = workDir + "/offs0" - snr0 = workDir + "/snr0" - offsets0 = workDir + "/offsets0" - coffs0 = workDir + "/coffs0" - coffsets0 = workDir + "/coffsets0" - off = workDir + "/" + IFGPair + ".off" - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - - if os.path.isfile(diff0): - os.remove(diff0) - if os.path.isfile(off): - os.remove(off) - -# real processing - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + SslcImg + " " + SslcPar + " " + SamprlksImg + " " + SamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = "$GAMMA_BIN/rdc_trans " + MamprlksPar + " " + HGTSIM + " " + SamprlksPar + " " + lt0 - os.system(call_str) - - width_Mamp = UseGamma(MamprlksPar, 'read', 'range_samples') - width_Samp = UseGamma(SamprlksPar, 'read', 'range_samples') - line_Samp = UseGamma(SamprlksPar, 'read', 'azimuth_lines') - - call_str = "$GAMMA_BIN/geocode " + lt0 + " " + MamprlksImg + " " + width_Mamp + " " + mli0 + " " + width_Samp + " " + line_Samp + " 2 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/create_diff_par " + SamprlksPar + " - " + diff0 + " 1 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/init_offsetm " + mli0 + " " + SamprlksImg + " " + diff0 + " 1 1" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " 256 256 " + offsets0 + " 2 32 32" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 4" - os.system(call_str) - - call_str = "$GAMMA_BIN/gc_map_fine " + lt0 + " " + width_Mamp + " " + diff0 + " " + lt1 - os.system(call_str) - - - call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " - " + Srslc0Img + " " + Srslc0Par - os.system(call_str) - - -# further refinement processing for resampled SLC - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + Srslc0Par + " " + off + " 1 - - 0" - os.system(call_str) - - #call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " 128 128 " + offsets + " 2 32 64" - #os.system(call_str) - - #call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3" - #os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3 >" + OFFSTD - os.system(call_str) - -############################################ Resampling ############################################ - - - for i in range(len(Suffix)): - if not INF=='IFG': - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - -######################## Resampling Slave Image #################### - - call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " " + off + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - - os.remove(lt0) - os.remove(lt1) - os.remove(mli0) - os.remove(diff0) - os.remove(offs0) - os.remove(snr0) - os.remove(offsets0) - os.remove(coffs0) - os.remove(coffsets0) - os.remove(off) - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) - os.remove(Srslc0Img) - os.remove(Srslc0Par) - - print "Coregistration with DEM is done!" - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/CoregistSLC_init_Gamma.py.bak b/pyint/CoregistSLC_init_Gamma.py.bak deleted file mode 100755 index 78552d8..0000000 --- a/pyint/CoregistSLC_init_Gamma.py.bak +++ /dev/null @@ -1,308 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Coregistration of SAR images based on cross-correlation by using GAMMA. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. - - usage: - - CoregistSLC_init_Gamma.py igramDir - - e.g. CoregistSLC_init_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CoregistSLC_init_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CoregistSLC_init_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'rlks4cor' in templateContents: rlks4cor = templateContents['rlks4cor'] - else: rlks4cor = '4' - if 'azlks4cor' in templateContents: azlks4cor = templateContents['azlks4cor'] - else: azlks4cor = '4' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# input files definition - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = rslcDir +'/'+ Mdate + ".rslc" - MslcPar = rslcDir +'/'+ Mdate + ".rslc.par" - SslcImg = rslcDir +'/'+ Sdate + ".rslc" - SslcPar = rslcDir +'/'+ Sdate + ".rslc.par" - - -# output files of coregistration - - off = workDir + "/" + IFGPair + ".init_off" - offs = workDir + "/" + IFGPair +".offs" - snr = workDir + "/" + IFGPair +".snr" - offsets = workDir + "/" + IFGPair + ".offsets" - coffs = workDir + "/" + IFGPair + ".coffs" - coffsets = workDir + "/" + IFGPair + ".coffsets" - off_std = workDir + "/" + IFGPair + ".off_std" - -################################### start to coregistrate ########################################## - if os.path.isfile(off): - os.remove(off) - - - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + SslcPar + " " + off + " 1 - - 0" - os.system(call_str) - - if coregCoarse == 'both': - print 'init offset estimation by both orbit and ampcor' - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - - elif coregCoarse == 'orbit': - print 'init offset estimation by orbit only' - - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - elif coregCoarse == 'ampcor': - print 'init offset estimation by ampcor only' - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - -######################## 1st time ############################ - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 "+ rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 3" - os.system(call_str) - -######################## 2nd time ############################# - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 4 >" + off_std - os.system(call_str) - - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) - - -############################################### Resampling #################################### - - for i in range(len(Suffix)): - if not INF=='IFG': - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - if not ( os.path.isfile(MslcImg) and os.path.isfile(MslcPar) and os.path.isfile(SslcImg) and os.path.isfile(SslcPar) ): - call_str = INF + '_SLC_Gamma.py ' + igramDir - os.system(call_str) - - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - -######################## Resampling Slave Image #################### - - - - call_str = "$GAMMA_BIN/SLC_interp " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - - - print "Coregistration without DEM is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Coregist_all_Gamma.py.bak b/pyint/Coregist_all_Gamma.py.bak deleted file mode 100755 index 9f0c2ea..0000000 --- a/pyint/Coregist_all_Gamma.py.bak +++ /dev/null @@ -1,415 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Coregistrate all SAR or interferograms to a master one # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import re - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Coregistrate all SAR or interferograms to one master data - - usage: - - Coregist_all_Gamma.py igramDir - - e.g. Coregist_all_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Coregist_all_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Coregist_all_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/PROCESS/RSLC" - workDir = processDir + '/' + igramDir - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - Moff = rslcDir +"/"+ masterDate + '-' + Mdate + '.off' - Soff = rslcDir +"/"+ masterDate + '-' + Sdate + '.off' - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) -# definition of intermediate and output file variables for slc images and parameters - - BaseslcDir = slcDir + "/" + masterDate - BaseslcImg = BaseslcDir + '/' + masterDate + '.slc' - BaseslcPar = BaseslcDir + '/' + masterDate + '.slc.par' - Baseslc4Par = workDir + '/' + masterDate + '.slc4.par' - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - -#################################### Start to Coregisrtate ######################################### - -# definition of parameter variables which may be included in the Template file - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'rlks4cor' in templateContents: rlks4cor = templateContents['rlks4cor'] - else: rlks4cor = '4' - if 'azlks4cor' in templateContents: azlks4cor = templateContents['azlks4cor'] - else: azlks4cor = '4' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - -### post coregistration for master image - - if not (Mdate == masterDate or os.path.isfile(Moff)): - print "post_coregistration would start for " + Mdate - call_str = "$GAMMA_BIN/create_offset " + BaseslcPar + " " + MslcPar + " " + Moff + " 1 - - 0" - os.system(call_str) - - if coregCoarse == 'both': - print 'init offset estimation by both orbit and ampcor' - call_str = '$GAMMA_BIN/init_offset_orbit '+ BaseslcPar + ' ' + MslcPar + ' ' + Moff - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + MslcImg + ' ' + BaseslcPar + ' ' + MslcPar + ' ' + Moff + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + MslcImg + ' ' + BaseslcPar + ' ' + MslcPar + ' ' + Moff + ' 1 1 - - ' - os.system(call_str) - - elif coregCoarse == 'orbit': - print 'init offset estimation by orbit only' - call_str = '$GAMMA_BIN/init_offset_orbit '+ BaseslcPar + ' ' + MslcPar + ' ' + Moff - os.system(call_str) - - elif coregCoarse == 'ampcor': - print 'init offset estimation by ampcor only' - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + MslcImg + ' ' + BaseslcPar + ' ' + MslcPar + ' ' + Moff + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + MslcImg + ' ' + BaseslcPar + ' ' + MslcPar + ' ' + Moff + ' 1 1 - - ' - os.system(call_str) -########## Refined Coregistration #### - call_str = "$GAMMA_BIN/offset_pwr " + BaseslcImg + ' ' + MslcImg + ' ' + BaseslcPar + ' ' + MslcPar + " " + Moff + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 "+ rsample4cor + " " + azsample4cor - os.system(call_str) - call_str = "$GAMMA_BIN/offset_fit " " " + offs + " " + snr + " " + Moff + " " + coffs + " " + coffsets + " - 3" - os.system(call_str) - - - call_str = "$GAMMA_BIN/offset_pwr " + BaseslcImg + " " + MslcImg + " " + BaseslcPar + " " + MslcPar + " " + Moff + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - call_str = "$GAMMA_BIN/offset_fit " " " + offs + " " + snr + " " + Moff + " " + coffs + " " + coffsets + " - 4" - os.system(call_str) - - - if not ( Sdate == masterDate or os.path.isfile(Soff)): - print "post_coregistration would start for " + Sdate - call_str = "$GAMMA_BIN/create_offset " + BaseslcPar + " " + SslcPar + " " + Soff + " 1 - - 0" - os.system(call_str) - - if coregCoarse == 'both': - print 'init offset estimation by both orbit and ampcor' - call_str = '$GAMMA_BIN/init_offset_orbit '+ BaseslcPar + ' ' + SslcPar + ' ' + Soff - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + SslcImg + ' ' + BaseslcPar + ' ' + SslcPar + ' ' + Soff + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + SslcImg + ' ' + BaseslcPar + ' ' + SslcPar + ' ' + Soff + ' 1 1 - - ' - os.system(call_str) - - elif coregCoarse == 'orbit': - print 'init offset estimation by orbit only' - call_str = '$GAMMA_BIN/init_offset_orbit '+ BaseslcPar + ' ' + SslcPar + ' ' + Soff - os.system(call_str) - - elif coregCoarse == 'ampcor': - print 'init offset estimation by ampcor only' - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + SslcImg + ' ' + BaseslcPar + ' ' + SslcPar + ' ' + Soff + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ BaseslcImg + ' ' + SslcImg + ' ' + BaseslcPar + ' ' + SslcPar + ' ' + Soff + ' 1 1 - - ' - os.system(call_str) -### Refined Coregistration ## - call_str = "$GAMMA_BIN/offset_pwr " + BaseslcImg + ' ' + SslcImg + ' ' + BaseslcPar + ' ' + SslcPar + " " + Soff + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 "+ rsample4cor + " " + azsample4cor - os.system(call_str) - call_str = "$GAMMA_BIN/offset_fit " " " + offs + " " + snr + " " + Soff + " " + coffs + " " + coffsets + " - 3" - os.system(call_str) - - - call_str = "$GAMMA_BIN/offset_pwr " + BaseslcImg + " " + SslcImg + " " + BaseslcPar + " " + SslcPar + " " + Soff + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - call_str = "$GAMMA_BIN/offset_fit " " " + offs + " " + snr + " " + Soff + " " + coffs + " " + coffsets + " - 4" - os.system(call_str) - - -############################################## Resampling ##################################################### - - for i in range(len(Suffix)): - if not INF=='IFG': - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int.par' - - rINT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.rint' - rINTpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.rint.par' - - MrslcImg = rslcDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = rslcDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = rslcDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = rslcDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = rslcDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = rslcDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = rslcDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = rslcDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - -#### detect the choice for resampling ####### - if not (Mdate == masterDate or os.path.isfile(MrslcImg)): - call_str = "$GAMMA_BIN/SLC_interp " + MslcImg + " " + BaseslcPar + " " + MslcPar + " " + Moff + " " + MrslcImg + " " + MrslcPar - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - else: - if not os.path.isfile(MrslcImg): - call_str = 'cp ' + MslcImg + ' ' + MrslcImg - os.system(call_str) - - call_str = 'cp ' + MslcPar + ' ' + MrslcPar - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - -##################################### - - if not (Sdate == masterDate or os.path.isfile(SrslcImg) ): - call_str = "$GAMMA_BIN/SLC_interp " + SslcImg + " " + BaseslcPar + " " + SslcPar + " " + Soff + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - else: - if not os.path.isfile(SrslcImg): - call_str = 'cp ' + SslcImg + ' ' + SrslcImg - os.system(call_str) - - call_str = 'cp ' + SslcPar + ' ' + SrslcPar - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - -################################################################### - - call_str = 'cp ' + MamprlksImg + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + MamprlksPar + ' ' + workDir - os.system(call_str) - - call_str = 'cp ' + SamprlksImg + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + SamprlksPar + ' ' + workDir - os.system(call_str) - - call_str = 'cp ' + MrslcPar + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + SrslcPar + ' ' + workDir - os.system(call_str) - -### post coregistration for interferogram - - fin = open(BaseslcPar,"r") - fout = open(Baseslc4Par,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() - - fin = open(MrslcPar,"r") - fout = open(INTpar,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() - - if (masterDate != Mdate): - call_str = "$GAMMA_BIN/SLC_interp " + INT + " " + Baseslc4Par + " " + INTpar + " " + Moff + " " + rINT + " " + rINTpar - os.system(call_str) - os.rename(rINT, INT) - - os.remove(snr) - os.remove(offsets) - os.remove(offs) - #os.remove(off) - os.remove(coffsets) - os.remove(coffs) - - print "Coregistrate "+ igramDir +" to " + masterDate +" is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/CreateRdcDem_Gamma.py.bak b/pyint/CreateRdcDem_Gamma.py.bak deleted file mode 100755 index f96932c..0000000 --- a/pyint/CreateRdcDem_Gamma.py.bak +++ /dev/null @@ -1,300 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Coregistration of SAR images based on cross-correlation with DEM assisstance # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Coregistration of SAR images based on cross-correlation by using GAMMA. - With or without DEM assisstance can be chosen. - - usage: - - CreateRdcDem_Gamma.py igramDir - - e.g. CreateRdcDem_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CreateRdcDem_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CreateRdcDem_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - dem=templateContents['DEM'] - demPar = dem + ".par" - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - -# Parameter setting for simPhase - - - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - if 'Simphase_rlks' in templateContents: rlksSimphase = templateContents['Simphase_rlks'] - else: rlksSimphase = '2' - if 'Simphase_azlks' in templateContents: azlksSimphase = templateContents['Simphase_azlks'] - else: azlksSimphase = '2' - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - if 'Simphase_patch' in templateContents: patchSimphase = templateContents['Simphase_patch'] - else: patchSimphase = '512' - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '512' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '512' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - -# Definition of file - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - - MslcImg = MslcDir + '/' + Mdate + '.slc' - MslcPar = MslcDir + '/' + Mdate + '.slc.par' - SslcImg = SslcDir + '/' + Sdate + '.slc' - SslcPar = SslcDir + '/' + Sdate + '.slc.par' - - MrslcImg = workDir + '/' + Mdate + '.rslc' - MrslcPar = workDir + '/' + Mdate + '.rslc.par' - SrslcImg = workDir + '/' + Sdate + '.rslc' - SrslcPar = workDir + '/' + Sdate + '.rslc.par' - - - BLANK = workDir + '/' + Mdate + '-' + Sdate + '.blk' - - MamprlksImg = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - SamprlksImg = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp' - SamprlksPar = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp.par' - - BASE = workDir + '/' + Mdate + '-' + Sdate + '.bas' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + '.bas_ref' - - UTMDEMpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.pix' - LSMAP = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.offs' - SIMSNR = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.rdc.dem' - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_unw' - - - - if not (os.path.isdir(simDir)): - os.makedirs(simDir) - - createBlankFile(BLANK) - - -### remove DEM look up table if it existed for considering gamma overlapping - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - if os.path.isfile(MrslcImg): - call_str = "$GAMMA_BIN/multi_look " + MrslcImg + " " + MrslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - else: - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - os.system(call_str) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + rlksSimphase + ' ' + azlksSimphase + ' ' + rposSimphase + ' ' + azposSimphase + ' - - - ' + patchSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + rwinSimphase + ' ' + azwinSimphase + ' ' + SIMOFFSET # + ' 1 - - ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5' - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/CreateRdcDem_Sen_Gamma.py.bak b/pyint/CreateRdcDem_Sen_Gamma.py.bak deleted file mode 100755 index f9695e7..0000000 --- a/pyint/CreateRdcDem_Sen_Gamma.py.bak +++ /dev/null @@ -1,271 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : FMarch, 2017 # -# # -# Create DEM in Radar coordinates for Sentinel-1 date # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Create DEM in Radar coordinates for Sentinel-1 date - - usage: - - CreateRdcDem_Sen_Gamma.py igramDir - - e.g. CreateRdcDem_Sen_Gamma.py IFG_PacayaT163S1A_131021-131101_0011_-0007 - e.g. CreateRdcDem_Sen_Gamma.py MAI_PacayaT163S1A_131021-131101_0011_-0007 - e.g. CreateRdcDem_Sen_Gamma.py RSI_PacayaT163S1A_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - if not os.path.isdir(workDir): - call_str = 'mkdir ' + workDir - os.system(call_str) - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - os.system(call_str) - - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - os.system(call_str) - - dem=templateContents['DEM'] - demPar = dem + ".par" - -# Parameter setting for simPhase - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - if 'Simphase_rlks' in templateContents: rlksSimphase = templateContents['Simphase_rlks'] - else: rlksSimphase = '2' - if 'Simphase_azlks' in templateContents: azlksSimphase = templateContents['Simphase_azlks'] - else: azlksSimphase = '2' - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - if 'Simphase_patch' in templateContents: patchSimphase = templateContents['Simphase_patch'] - else: patchSimphase = '512' - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '512' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '512' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: SW = '1' - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: EW = '3' - if 'Start_Burst' in templateContents: SB = templateContents['Start_Burst'] - else: SB = '1' - -# Definition of file - - MamprlksImg = workDir + '/'+Mdate + '_' + rlks + 'rlks' + '.amp' - MamprlksPar = workDir + '/'+Mdate + '_' + rlks + 'rlks' + '.amp.par' - - - UTMDEMpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.pix' - LSMAP = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.offs' - SIMSNR = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.rdc.dem' - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sim_unw' - BLANK = workDir + '/' + Mdate + '-' + Sdate + '.blank' - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP - os.system(call_str) - - createBlankFile(BLANK) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + rlksSimphase + ' ' + azlksSimphase + ' ' + rposSimphase + ' ' + azposSimphase + ' - - - ' + patchSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + rwinSimphase + ' ' + azwinSimphase + ' ' + SIMOFFSET # + ' 1 - - ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5' - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/CreateRdcDem_Sub_Gammapy.py.bak b/pyint/CreateRdcDem_Sub_Gammapy.py.bak deleted file mode 100755 index 6930f71..0000000 --- a/pyint/CreateRdcDem_Sub_Gammapy.py.bak +++ /dev/null @@ -1,337 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Coregistration of SAR images based on cross-correlation with DEM assisstance # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def GetSubset(Subset): - Dx = Subset.split('[')[1].split(']')[0].split(',')[0] - Dy = Subset.split('[')[1].split(']')[0].split(',')[1] - - x1 = Dx.split(':')[0] - x2 = Dx.split(':')[1] - - y1 = Dy.split(':')[0] - y2 = Dy.split(':')[1] - - return x1,x2,y1,y2 - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generate Subset Lookup-table and RDC-DEM - - usage: - - CreateRdcDem_Sub_Gamma.py igramDir - - e.g. CreateRdcDem_Sub_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CreateRdcDem_Sub_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. CreateRdcDem_Sub_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - dem=templateContents['DEM'] - demPar = dem + ".par" - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - -# Parameter setting for simPhase - - - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - if 'Simphase_rlks' in templateContents: rlksSimphase = templateContents['Simphase_rlks'] - else: rlksSimphase = '2' - if 'Simphase_azlks' in templateContents: azlksSimphase = templateContents['Simphase_azlks'] - else: azlksSimphase = '2' - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - if 'Simphase_patch' in templateContents: patchSimphase = templateContents['Simphase_patch'] - else: patchSimphase = '512' - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '512' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '512' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - -# Definition of file - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - - MslcImg = MslcDir + '/' + Mdate + '.slc' - MslcPar = MslcDir + '/' + Mdate + '.slc.par' - SslcImg = SslcDir + '/' + Sdate + '.slc' - SslcPar = SslcDir + '/' + Sdate + '.slc.par' - - MrslcImg = workDir + '/' + Mdate + '.rslc' - MrslcPar = workDir + '/' + Mdate + '.rslc.par' - SrslcImg = workDir + '/' + Sdate + '.rslc' - SrslcPar = workDir + '/' + Sdate + '.rslc.par' - - MrslcSubImg = workDir + '/' + Mdate + '.sub.rslc' - MrslcSubPar = workDir + '/' + Mdate + '.sub.rslc.par' - - MslcSubImg = workDir + '/' + Mdate + '.sub.slc' - MslcSubPar = workDir + '/' + Mdate + '.sub.slc.par' - - - BLANK = workDir + '/' + Mdate + '-' + Sdate + '.blk' - - - MamprlksImg0 = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar0 = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - SamprlksImg0 = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp' - SamprlksPar0 = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp.par' - - MamprlksImg = workDir + '/' + Mdate + '_' + rlks + 'rlks.sub.amp' - MamprlksPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.sub.amp.par' - SamprlksImg = workDir + '/' + Sdate + '_' + rlks + 'rlks.sub.amp' - SamprlksPar = workDir + '/' + Sdate + '_' + rlks + 'rlks.sub.amp.par' - - BASE = workDir + '/' + Mdate + '-' + Sdate + '.bas' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + '.bas_ref' - - UTMDEMpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.pix' - LSMAP = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.offs' - SIMSNR = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.rdc.dem' - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_'+ rlks + 'rlks.sub.sim_unw' - - SubStr = templateContents['Subset_Rdc'] - SubXY = GetSubset(SubStr) - Rg1 = SubXY[0] - Rg2 = SubXY[1] - Az1 = SubXY[2] - Az2 = SubXY[3] - - NR = str(int(Rg2) - int(Rg1)) - NA = str(int(Az2) - int(Az1)) - - if not (os.path.isdir(simDir)): - os.makedirs(simDir) - - createBlankFile(BLANK) - - -### remove DEM look up table if it existed for considering gamma overlapping - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - -#################################### Copy MLI ####################################### - - call_str= '$GAMMA_BIN/MLI_copy ' + MamprlksImg0 + ' ' + MamprlksPar0 + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + Rg1 + ' ' + NR + ' ' + Az1 + ' ' + NA - os.system(call_str) -####################################################################################### - - - - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - os.system(call_str) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - if os.path.isfile(SIMDIFFpar): - os.remove(SIMDIFFpar) - - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + rlksSimphase + ' ' + azlksSimphase + ' ' + rposSimphase + ' ' + azposSimphase + ' - - - 64 ' - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + ' 64 64 ' + SIMOFFSET # + ' 1 - - ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5' - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/DiffPhase_Gamma.py.bak b/pyint/DiffPhase_Gamma.py.bak deleted file mode 100755 index 4188de9..0000000 --- a/pyint/DiffPhase_Gamma.py.bak +++ /dev/null @@ -1,284 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Removing topography and flattening phase from original interferogram. # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Romoving topography phase and flattening phase from original interferogram. - - usage: - - diffPhase_gamma.py igramDir - - e.g. diffPhase_gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. diffPhase_gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. diffPhase_gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -# subtract simulated interferometric phase process - -# Parameter setting for diffPhase - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - demDir = scratchDir + '/' + projectName + "/PROCESS" + "/DEM" - - - - if 'Igram_Cor_Rwin' in templateContents: rWinCor = templateContents['Igram_Cor_Rwin'] - else: rWinCor = '5' - if 'Igram_Cor_Awin' in templateContents: aWinCor = templateContents['Igram_Cor_Awin'] - else: aWinCor = '5' - - - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Diff_FilterMethod' in templateContents: strFilterMethod = templateContents['Diff_FilterMethod'] - else: strFilterMethod = "adpt_filt" - strFilterMethodDiff = strFilterMethod - - if 'Diff_FilterStrength' in templateContents: - strFilterStrengeh = templateContents['Diff_FilterStrength'] - fFiltLengthDiff = strFilterStrengeh.split('/')[0] - nFiltWindowDiff = strFilterStrengeh.split('/')[1] - else: - fFiltLengthDiff = '-' - nFiltWindowDiff='-' - if 'Diff_FFTLength' in templateContents: nAzfftDiff = templateContents['Diff_FFTLength'] - else: nAzfftDiff = '512' - - -######################## Start to process differential Interferometry ######################## - - BLANK = workDir + '/' + Mdate + '-' + Sdate + '.blk' - createBlankFile(BLANK) - - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.sim_unw' - HGTSIM = demDir + '/sim_' + Mdate +'_' + rlks + 'rlks.rdc.dem' - GCP = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.gcp' - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' - - DIFFpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.diff.par' - - DIFFINTlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - DIFFINTFFTlks = DIFFINTlks.replace('diff_', 'diff_sim_') - - CORDIFFlks = workDir+'/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORDIFFFILTlks = workDir+'/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - if os.path.isfile(OFFlks): - call_str = '$GAMMA_BIN/create_diff_par ' + OFFlks + ' ' + OFFlks + ' ' + DIFFpar + ' 0 0 ' - os.system(call_str) - call_str = '$GAMMA_BIN/extract_gcp ' + HGTSIM + ' ' + OFFlks + ' ' + GCP - os.system(call_str) - else: - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + DIFFpar + ' 1 0 ' - os.system(call_str) - - - call_str = '$GAMMA_BIN/sub_phase ' + INTlks + ' ' + SIMUNW + ' ' + DIFFpar + ' ' + DIFFINTlks + ' 1' - os.system(call_str) - - if not flatteningDiff == 'orbit': - call_str = '$GAMMA_BIN/base_est_fft ' + DIFFINTlks + ' ' + MrslcPar + ' ' + OFFlks + ' ' + BASE_REF + ' ' + nAzfftDiff - os.system(call_str) - - call_str = '$GAMMA_BIN/ph_slope_base ' + DIFFINTlks + ' ' + MrslcPar + ' ' + OFFlks + ' ' + BASE_REF + ' ' + DIFFINTFFTlks - os.system(call_str) - - DIFFINTlks = DIFFINTFFTlks - call_str = '$GAMMA_BIN/base_add ' + BASE + ' ' + BASE_REF + ' ' + BASE + '.tmp' - os.system(call_str) - - os.rename(BASE+'.tmp', BASE) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + DIFFINTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(DIFFINTlks, DIFFINTlks) - - DIFFINTFILTlks = DIFFINTlks.replace('diff_', 'diff_filt_') - call_str = '$GAMMA_BIN/adf ' + DIFFINTlks + ' ' + DIFFINTFILTlks + ' ' + CORFILTlks + ' ' + nWidth + ' 0.5' - os.system(call_str) - - if strFilterMethodDiff == 'adapt_filt': - call_str = '$GAMMA_BIN/adapt_filt ' + DIFFINTlks + ' ' + DIFFINTFILTlks + ' ' + nWidth + ' ' + fFiltLengthDiff + ' ' + nFiltWindowDiff - os.system(call_str) - -################ calculate coherence based on differential interferogram #################################### - - call_str = '$GAMMA_BIN/cc_wave '+ DIFFINTlks + ' ' + MamprlksImg + ' ' + SamprlksImg + ' ' + CORDIFFlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc ' + CORDIFFlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(CORDIFFlks, CORDIFFlks) - - call_str = '$GAMMA_BIN/cc_wave '+ DIFFINTFILTlks + ' ' + MamprlksImg + ' ' + SamprlksImg + ' ' + CORDIFFFILTlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc ' + CORDIFFFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(CORDIFFFILTlks, CORDIFFFILTlks) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + DIFFINTFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(DIFFINTFILTlks, DIFFINTFILTlks) - - print "Subtraction of topography and flattening phase is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/DiffPhase_Sen_Gamma.py.bak b/pyint/DiffPhase_Sen_Gamma.py.bak deleted file mode 100755 index ccf47d6..0000000 --- a/pyint/DiffPhase_Sen_Gamma.py.bak +++ /dev/null @@ -1,193 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : FMarch, 2017 # -# # -# Generating differential interferograms for sentinel-1A/B # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generating the differential interferograms for Sentinel-1A/B - - usage: - - DiffPhase_Sen_Gamma.py igramDir - - e.g. DiffPhase_Sen_Gamma.py IFG_PacayaT163S1A_131021-131101_0011_-0007 - e.g. DiffPhase_Sen_Gamma.py MAI_PacayaT163S1A_131021-131101_0011_-0007 - e.g. DiffPhase_Sen_Gamma.py RSI_PacayaT163S1A_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/DEM" - #if not os.path.isdir(simDir): - # call_str='mkdir ' + simDir - # os.system(call_str) - - #simDir = simDir + '/sim_' + Mdate + '-' + Sdate - #if not os.path.isdir(simDir): - # call_str='mkdir ' + simDir - # os.system(call_str) - - - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: SW = '1' - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: EW = '3' - -# Definition of file - MslcDir = rslcDir + '/' + Mdate - SslcDir = rslcDir + '/' + Sdate - - - SLC1_INF_tab = MslcDir + '/' + Mdate + '_SLC_Tab' - SLC2_INF_tab = SslcDir + '/' + Sdate + '_SLC_Tab' - - HGTSIM = simDir + '/sim_' + Mdate + '_' + rlks + 'rlks.rdc.dem' - if not os.path.isfile(HGTSIM): - call_str = 'CreateRdcDem_Sen_Gamma.py ' + igramDir - os.system(call_str) - - RSLC_tab = workDir + '/' + Sdate + '_RSLC_tab' - if os.path.isfile(RSLC_tab): - os.remove(RSLC_tab) - - BURST = SslcDir + '/' + Sdate + '_Burst_Tab' - AA = np.loadtxt(BURST) - if EW==SW: - AA = AA.reshape([1,2]) - - for kk in range(int(EW)-int(SW)+1): - ii = int(int(kk) + 1) - SB2=AA[ii-1,0] - EB2=AA[ii-1,1] - call_str = 'echo ' + workDir + '/'+ Sdate+ '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+str(int(SW)+kk)+ '.rslc' + ' ' + workDir + '/' + Sdate + '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+ str(int(SW)+kk)+ '.rslc.par' + ' ' + workDir + '/'+ Sdate+'_'+ str(int(SB2)) + str(int(EB2)) + '.IW'+str(int(SW)+kk)+ '.rslc.TOPS_par >>' + RSLC_tab - os.system(call_str) - - - os.chdir(workDir) - call_str = 'S1_coreg_TOPS ' + SLC1_INF_tab + ' ' + Mdate + ' ' + SLC2_INF_tab + ' ' + Sdate + ' ' + RSLC_tab + ' ' + HGTSIM + ' ' + rlks + ' ' + azlks + ' - - 0.6 0.01 1.2 1' - os.system(call_str) - - - print "Generating differential S1 interferogram is done !!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Down2SLC_Sen_All.py.bak b/pyint/Down2SLC_Sen_All.py.bak deleted file mode 100755 index 8455efd..0000000 --- a/pyint/Down2SLC_Sen_All.py.bak +++ /dev/null @@ -1,190 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################## -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Generate Sentinel SLC from the downloaded data # -# # -################################################################################## -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Downloading Sentinel-1A/B data based on ssara - - usage: - - Down2SLC_Sen_All.py ProjectName - - e.g. Down2SLC_Sen_All.py CotopaxiT120SenVVA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - projectName = sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - - projectDir = scratchDir + '/' + projectName - downDir = scratchDir + '/' + projectName + "/DOWNLOAD" - - os.chdir(downDir) - - call_str = 'ls > ttt0' - os.system(call_str) - - - call_str = 'grep .zip ttt0 > ttt' - os.system(call_str) - ZIP = np.loadtxt('ttt',dtype = np.str) - N = ZIP.size - DATE = [] - - if N>1: - for i in range(N): - RAWNAME = ZIP[i] - Date = RAWNAME[19:25] - if (not (Date in DATE)) and len(Date)>0: - DATE.append(Date) - - call_str = 'grep SAFE ttt0 > ttt' - os.system(call_str) - SAFE = np.loadtxt('ttt',dtype = np.str) - N = SAFE.size - - if N >1: - for i in range(N): - RAWNAME = SAFE[i] - Date = RAWNAME[19:25] - if (not (Date in DATE)) and len(Date)>0: - DATE.append(Date) - - N = len(DATE) - - run_down2slc_sen = downDir + '/run_down2slc_sen' - f_down2slc =open(run_down2slc_sen,'w') - - for i in range(N): - str_script = 'Down2SLC_Sen_Gamma.py ' + projectName + ' ' + DATE[i] + '\n' - f_down2slc.write(str_script) - print 'Add download raw S1 data: ' + DATE[i] - f_down2slc.close() - - print '' - print 'Start processing down2sl for project: ' + projectName - - call_str='$INT_SCR/createBatch.pl ' + run_down2slc_sen + ' memory=7000 walltime=0:30' - os.system(call_str) - - print "Down to SLC for project %s is done! " % projectName - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pyint/Down2SLC_Sen_Gamma.py.bak b/pyint/Down2SLC_Sen_Gamma.py.bak deleted file mode 100755 index 9c5fa08..0000000 --- a/pyint/Down2SLC_Sen_Gamma.py.bak +++ /dev/null @@ -1,241 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################## -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Generate Sentinel SLC from the downloaded data # -# # -################################################################################## -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close - -def rm(TXT): - call_str = 'rm ' + TXT - os.system(call_str) - -def usage(): - print ''' -****************************************************************************************************** - - Downloading Sentinel-1A/B data based on ssara - - usage: - - Down2SLC_Sen_Gamma.py ProjectName DownName - - e.g. Down2SLC_Sen_Gamma.py CotopaxiT120SenVVA 170118 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==3: - projectName = sys.argv[1] - Date = sys.argv[2] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - - projectDir = scratchDir + '/' + projectName - downDir = scratchDir + '/' + projectName + "/DOWNLOAD" - slcDir = scratchDir + '/' + projectName + '/SLC' - - if not os.path.isdir(slcDir): - call_str= 'mkdir ' +slcDir - os.system(call_str) - - os.chdir(downDir) - - - t0 = 't0_' + Date - call_str = 'ls >' + t0 - os.system(call_str) - - tt = 'tt_' + Date - call_str = "grep " + Date + ' ' + t0 + '> ' + tt - os.system(call_str) - - ts = 'ts_' + Date - call_str = "grep SAFE " + tt + ' >' + ts - os.system(call_str) - - tz = 'tz_' + Date - call_str = "grep zip " + tt + " > " + tz - os.system(call_str) - - A1= np.loadtxt(ts,dtype=np.str) - Na1 = A1.size - - A2= np.loadtxt(tz,dtype=np.str) - Na2 = A2.size - - rm(t0);rm(tt);rm(ts);rm(tz) - - if Na1 == 0: - if Na2 > 0: - if Na2 == 1: - downName = str(A2) - else: - downName = str(A2[0]) - FileDir = downDir + '/' + downName - RAWNAME = downName.split('.')[0]+'.SAFE' - call_str = 'unzip '+ FileDir - os.system(call_str) - - else: - if Na1 == 1: - RAWNAME = str(A1) - else: - RAWNAME = str(A1[0]) - - print RAWNAME - RAWFILEDir = downDir + '/'+str(RAWNAME) - - - Date = RAWNAME[19:25] - DateDir = slcDir + '/'+Date - - if not os.path.isdir(DateDir): - call_str='mkdir '+DateDir - os.system(call_str) - - measureDir = RAWFILEDir + '/measurement' - annotatDir = RAWFILEDir + '/annotation' - calibraDir = RAWFILEDir + '/annotation/calibration' - - MM = glob.glob(measureDir + '/*vv*tiff') -# MEASURE = glob.glob(measureDir + '/*vv*tiff') -# ANNOTAT = glob.glob(annotatDir + '/*vv*xml' ) -# CALIBRA = glob.glob(calibraDir+'/calibration*vv*') -# NOISE = glob.glob(calibraDir+'/noise*vv*') - - SLC_Tab = DateDir + '/' + Date+'_SLC_Tab' - TEST = DateDir + '/' + Date + '.IW1.slc' - - if not os.path.isfile(TEST): - if os.path.isfile(SLC_Tab): - os.remove(SLC_Tab) - for kk in range(len(MM)): - SLC = DateDir + '/' + Date + '.IW' + str(kk+1)+'.slc' - SLCPar = DateDir + '/' + Date + '.IW' + str(kk+1)+'.slc.par' - TOPPar = DateDir + '/' + Date + '.IW' + str(kk+1)+'.slc.TOPS_par' - BURST = DateDir + '/' + Date + '.IW' + str(kk+1)+'.burst.par' - - if os.path.isfile(BURST): - os.remove(BURST) - call_str = 'echo ' + SLC + ' ' + SLCPar + ' ' + TOPPar + ' >> ' + SLC_Tab - os.system(call_str) - - MEASURE = glob.glob(measureDir + '/*iw' + str(kk+1) + '*vv*tiff') - ANNOTAT = glob.glob(annotatDir + '/*iw' + str(kk+1) + '*vv*xml' ) - CALIBRA = glob.glob(calibraDir+'/calibration*'+ 'iw' + str(kk+1) + '*vv*') - NOISE = glob.glob(calibraDir+'/noise*' + 'iw' + str(kk+1) + '*vv*') - - #call_str = 'S1_burstloc ' + ANNOTAT[0] + '> ' +BURST - #os.system(call_str) - - if int(Date) > 180311: - call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[0] + ' ' + CALIBRA[0] + ' - ' + SLCPar + ' ' + SLC + ' ' + TOPPar - else: - call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[0] + ' ' + CALIBRA[0] + ' ' + NOISE[0] + ' ' + SLCPar + ' ' + SLC + ' ' + TOPPar - - os.system(call_str) - - call_str = 'SLC_burst_corners ' + SLCPar + ' ' + TOPPar + ' > ' +BURST - os.system(call_str) - - TSLC = DateDir + '/' + Date + '.slc' - TSLCPar = DateDir + '/' + Date + '.slc.par' - - TMLI = DateDir + '/' + Date + '_20rlks.amp' - TMLIPar = DateDir + '/' + Date + '_20rlks.amp.par' - - call_str = 'SLC_mosaic_S1_TOPS ' + SLC_Tab + ' ' + TSLC + ' ' + TSLCPar + ' 10 2' - os.system(call_str) - - call_str = 'multi_look ' + TSLC + ' ' + TSLCPar + ' ' + TMLI + ' ' + TMLIPar + ' 20 4' - os.system(call_str) - - nWidth = UseGamma(TMLIPar, 'read','range_samples:') - call_str = 'raspwr ' + TMLI + ' ' + nWidth + ' - - - - - - - ' - os.system(call_str) - - ras2jpg(TMLI,TMLI) - - print "Down to SLC for %s is done! " % Date - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - diff --git a/pyint/DownloadSen.py.bak b/pyint/DownloadSen.py.bak deleted file mode 100755 index faee368..0000000 --- a/pyint/DownloadSen.py.bak +++ /dev/null @@ -1,153 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Downloading Sentinel-1A/B data from ASF which is supported by WInSAR. - Scripts ssara_federated_query.py from SSARA software is called, - which is developed by Scott Baker from UNAVCO. - So you should install SSARA and register a WInSAR account to use this script. - usage: - - DownloadSen.py ProjectName - - e.g. DownloadSen.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - projectName = sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - downDir = scratchDir + '/' + projectName + "/DOWNLOAD" - - if not os.path.isdir(projectDir): - call_str = 'mkdir ' + projectDir - os.system(call_str) - - if not os.path.isdir(downDir): - call_str = 'mkdir ' + downDir - os.system(call_str) - - os.chdir(downDir) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - Track = templateContents['Track'] - Frame = templateContents['Frame'] - - if 'Startdate' in templateContents: - Startdate = templateContents['Startdate'] - STARTSTR = ' -s ' + Startdate - else: - STARTSTR = '' - - - if 'Enddate' in templateContents: - Enddate = templateContents['Enddate'] - ENDSTR = ' -e ' + Enddate - else: - ENDSTR = '' - - - - SSARA_STRA = 'ssara_federated_query.py -p Sentinel-1A -r ' + Track + ' -f '+ Frame + STARTSTR + ENDSTR + ' --print --download --parallel=10' - print SSARA_STRA - os.system(SSARA_STRA) - - - SSARA_STRB ='ssara_federated_query.py -p Sentinel-1B -r ' + Track + ' -f '+ Frame + STARTSTR + ENDSTR + ' --print --download --parallel=10' - print SSARA_STRB - os.system(SSARA_STRB) - - - print "Downloading Sentinel-1A/B during %s and %s is done " % ( Startdate, Enddate ) - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - diff --git a/pyint/Extract_Burst_Slave.py.bak b/pyint/Extract_Burst_Slave.py.bak deleted file mode 100755 index 389a4fc..0000000 --- a/pyint/Extract_Burst_Slave.py.bak +++ /dev/null @@ -1,304 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def write_template(File,STR): - f = open(File, 'a') - f.writelines(STR) - f.close() - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def GetDatelist(projectName): - - scratchDir = os.getenv('SCRATCHDIR') - slcDir = scratchDir + '/' + projectName + "/SLC" - ListSLC = os.listdir(slcDir) - - Datelist = [] - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - map(str,Datelist) - - return Datelist - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Extract the common bursts for S1 TOPs based on one master image. -''' - -EXAMPLE = ''' - Usage: - Extract_Burst_Slave.py projectName 170115 - - Examples: - Extract_Burst_Slave.py PacayaT163TsxHhA 170115 -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - parser.add_argument('Sdate',help='Slave date.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - Sdate = inps.Sdate - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - Mdate = templateContents['masterDate'] - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - #MBurst_Par = slcDir + '/' + Mdate + '/' + - workDir = rslcDir + '/' + Sdate - BURST = workDir + '/' + Mdate + '_' + Sdate + '.common_burst_ref' - - MslcImg = workDir + '/'+Mdate + '.slc' - MslcPar = workDir + '/'+Mdate + '.slc.par' - - MamprlksImg = workDir + '/'+Mdate + '_' + rlks + 'rlks' + '.amp' - MamprlksPar = workDir + '/'+Mdate + '_' + rlks +'rlks' + '.amp.par' - - SslcImg = workDir + '/'+ Sdate + '.slc' - SslcPar = workDir + '/'+ Sdate + '.slc.par' - - SamprlksImg = workDir + '/'+ Sdate + '_' + rlks + 'rlks' + '.amp' - SamprlksPar = workDir + '/'+ Sdate + '_' + rlks + 'rlks' + '.amp.par' - - if not os.path.isfile(BURST): - call_str = 'Check_Common_Burst_All.py ' + projectName - os.system(call_str) - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: - SW = '1' - STR = 'Start_Swath = ' + SW + '\n' - write_template(templateFile,STR) - - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: - EW = '3' - STR = 'End_Swath = ' + EW + '\n' - write_template(templateFile,STR) - - AA = np.loadtxt(BURST) - - if 'Start_Burst' in templateContents: SB = templateContents['Start_Burst'] - else: - SB = '1' - STR = 'Start_Burst = ' + SB + '\n' - write_template(templateFile,STR) - - if 'End_Burst' in templateContents: EB = templateContents['End_Burst'] - else: - EB = '20' - #STR = 'End_Burst = ' + EB + '\n' - #write_template(templateFile,STR) - - #SLC1_tab = workDir + '/' + Mdate + '_SLC_Tab0' - SLC2_tab = workDir + '/' + Sdate + '_SLC_Tab0' - - #SLC1_INF_tab = workDir + '/' + Mdate + '_SLC_Tab' - SLC2_INF_tab = workDir + '/' + Sdate + '_SLC_Tab' - SLC2_RSLC_tab = workDir + '/' + Sdate + '_RSLC_Tab' - - - #BURST1_tab = workDir + '/' + Mdate + '_Burst_Tab' - BURST2_tab = workDir + '/' + Sdate + '_Burst_Tab' - - #if os.path.isfile(SLC1_tab): - # os.remove(SLC1_tab) - - if os.path.isfile(SLC2_tab): - os.remove(SLC2_tab) - - #if os.path.isfile(SLC1_INF_tab): - # os.remove(SLC1_INF_tab) - - if os.path.isfile(SLC2_INF_tab): - os.remove(SLC2_INF_tab) - - if os.path.isfile(SLC2_RSLC_tab): - os.remove(SLC2_RSLC_tab) - - #if os.path.isfile(BURST1_tab): - # os.remove(BURST1_tab) - - if os.path.isfile(BURST2_tab): - os.remove(BURST2_tab) - - for kk in range(int(EW)-int(SW)+1): - #call_str = 'echo ' + MslcDir + '/' + Mdate+'.IW'+str(int(SW)+kk) + '.slc' + ' ' + MslcDir + '/'+ Mdate + '.IW'+str(int(SW)+kk) +'.slc.par' + ' ' + MslcDir + '/'+ Mdate+'.IW'+str(int(SW)+kk) + '.slc.TOPS_par >>' + SLC1_tab - #os.system(call_str) - - call_str = 'echo ' + SslcDir + '/' + Sdate+'.IW'+str(int(SW)+kk) + '.slc' + ' ' + SslcDir + '/'+ Sdate + '.IW'+str(int(SW)+kk) +'.slc.par' + ' ' + SslcDir + '/'+ Sdate+'.IW'+str(int(SW)+kk) + '.slc.TOPS_par >>' + SLC2_tab - os.system(call_str) - - ii = int(SW) + kk - SB1=AA[ii-1,0] - EB1=AA[ii-1,1] - - SB2=AA[ii-1,2] - EB2=AA[ii-1,3] - - if not int(SB)==1: - SB2 = SB2 + int(SB)-1 - if not int(EB)==20: - EB2 = SB2 + int(EB) - int(SB) - - #call_str = 'echo ' + workDir + '/'+ Mdate+ '_'+ str(int(SB1)) + str(int(EB1)) +'.IW'+str(int(SW)+kk)+ '.slc' + ' ' + workDir + '/' + Mdate + '_'+ str(int(SB1)) + str(int(EB1)) +'.IW'+ str(int(SW)+kk)+ '.slc.par' + ' ' + workDir + '/'+ Mdate+'_'+ str(int(SB1)) + str(int(EB1)) + '.IW'+str(int(SW)+kk)+ '.slc.TOPS_par >>' + SLC1_INF_tab - #os.system(call_str) - - - call_str = 'echo ' + workDir + '/'+ Sdate+ '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+str(int(SW)+kk)+ '.slc' + ' ' + workDir + '/' + Sdate + '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+ str(int(SW)+kk)+ '.slc.par' + ' ' + workDir + '/'+ Sdate+'_'+ str(int(SB2)) + str(int(EB2)) + '.IW'+str(int(SW)+kk)+ '.slc.TOPS_par >>' + SLC2_INF_tab - os.system(call_str) - - call_str = 'echo ' + workDir + '/'+ Sdate+ '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+str(int(SW)+kk)+ '.rslc' + ' ' + workDir + '/' + Sdate + '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+ str(int(SW)+kk)+ '.rslc.par' + ' ' + workDir + '/'+ Sdate+'_'+ str(int(SB2)) + str(int(EB2)) + '.IW'+str(int(SW)+kk)+ '.rslc.TOPS_par >>' + SLC2_RSLC_tab - os.system(call_str) - - #call_str = 'echo ' + str(int(SB1)) + ' ' + str(int(EB1)) + ' >>' + BURST1_tab - #os.system(call_str) - - call_str = 'echo ' + str(int(SB2)) + ' ' + str(int(EB2)) + ' >>' + BURST2_tab - os.system(call_str) - - #call_str = 'SLC_copy_S1_TOPS ' + SLC1_tab + ' ' + SLC1_INF_tab + ' ' + BURST1_tab - #os.system(call_str) - - call_str = 'SLC_copy_S1_TOPS ' + SLC2_tab + ' ' + SLC2_INF_tab + ' ' + BURST2_tab - os.system(call_str) - - #call_str = 'SLC_mosaic_S1_TOPS ' + SLC1_INF_tab + ' ' + MslcImg + ' ' + MslcPar + ' ' + rlks + ' ' +azlks - #os.system(call_str) - - #call_str = '$GAMMA_BIN/multi_look ' + MslcImg + ' ' + MslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - #os.system(call_str) - - #nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - #call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - #os.system(call_str) - #ras2jpg(MamprlksImg, MamprlksImg) - - call_str = 'SLC_mosaic_S1_TOPS ' + SLC2_INF_tab + ' ' + SslcImg + ' ' + SslcPar + ' ' + rlks + ' ' +azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SslcImg + ' ' + SslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(SamprlksPar, 'read', 'range_samples') - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Extract_Burst_Slave_All.py.bak b/pyint/Extract_Burst_Slave_All.py.bak deleted file mode 100755 index 2457454..0000000 --- a/pyint/Extract_Burst_Slave_All.py.bak +++ /dev/null @@ -1,204 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_extract_burst_all(projectName,datelist): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - slcDir = projectDir + '/SLC' - run_extract_burst_all = slcDir + "/run_extract_burst_all" - f_extract = open(run_extract_burst_all,'w') - - for kk in range(len(datelist)): - str_extract = "Extract_Burst_Slave.py " + projectName + ' ' + datelist[kk] + '\n' - f_extract.write(str_extract) - f_extract.close() - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Extract common TOPS burst (Sentinel-1) for the whole project based on one master date. - ps: Before using Extract_Burst_Slave_All.py, you should run Check_Common_Burst_All.py. - -''' - -EXAMPLE = ''' - Usage: - Extract_Burst_Slave_All.py projectName - - Examples: - Extract_Burst_Slave_All.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Batch processing pegasus jobs.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('project',help='Project name of coregistration.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - - projectName = inps.project - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDIR = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - templateContents = read_template(templateFile) - if 'memory_Extract' in templateContents : memory_Extract = templateContents['memory_Extract'] - else: memory_Extract = '7000' - if 'walltime_Extract' in templateContents : walltime_Extract = templateContents['walltime_Extract'] - else: walltime_Extract = '0:30' - -##################### Extract SLC Date ################################# - - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - print "All of the available SAR acquisition datelist is :" - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - print ListSLC[kk] - str_slc = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc" - str_slc_par = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc.par" - SLCfile.append(str_slc) - SLCParfile.append(str_slc_par) - - - #SLAVElist = Datelist - #del SLAVElist[Datelist.index(masterDate)] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - - write_run_extract_burst_all(projectName,Datelist) - call_str = 'rm ' + slcDir + '/job*' - os.system(call_str) - - call_str = 'rm ' + slcDir + '/z_output*' - os.system(call_str) - - call_str='$INT_SCR/createBatch.pl ' + slcDir+'/run_extract_burst_all memory=' +memory_Extract + ' walltime=' + walltime_Extract - os.system(call_str) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Extract_Common_Burst.py.bak b/pyint/Extract_Common_Burst.py.bak deleted file mode 100755 index fb99168..0000000 --- a/pyint/Extract_Common_Burst.py.bak +++ /dev/null @@ -1,282 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def write_template(File,STR): - f = open(File, 'a') - f.writelines(STR) - f.close() - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def GetDatelist(projectName): - - scratchDir = os.getenv('SCRATCHDIR') - slcDir = scratchDir + '/' + projectName + "/SLC" - ListSLC = os.listdir(slcDir) - - Datelist = [] - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - map(str,Datelist) - - return Datelist - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Extract the common bursts for S1 TOPs. -''' - -EXAMPLE = ''' - Usage: - Extract_Common_Burst.py igramDir - - Examples: - Extract_Common_Burst.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('igramDir',help='Interferogram directory name.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - igramDir = inps.igramDir - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - #MBurst_Par = slcDir + '/' + Mdate + '/' + - BURST = processDir + '/' + igramDir + '/' + Mdate + '_' + Sdate + '.common_burst' - - MslcImg = workDir + '/'+Mdate + '.slc' - MslcPar = workDir + '/'+Mdate + '.slc.par' - - MamprlksImg = workDir + '/'+Mdate + '_' + rlks + 'rlks' + '.amp' - MamprlksPar = workDir + '/'+Mdate + '_' + rlks +'rlks' + '.amp.par' - - SslcImg = workDir + '/'+ Sdate + '.slc' - SslcPar = workDir + '/'+ Sdate + '.slc.par' - - SamprlksImg = workDir + '/'+ Sdate + '_' + rlks + 'rlks' + '.amp' - SamprlksPar = workDir + '/'+ Sdate + '_' + rlks + 'rlks' + '.amp.par' - - if not os.path.isfile(BURST): - call_str = 'Check_Common_Burst.py ' + igramDir - os.system(call_str) - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: - SW = '1' - STR = 'Start_Swath = ' + SW + '\n' - write_template(templateFile,STR) - - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: - EW = '3' - STR = 'End_Swath = ' + EW + '\n' - write_template(templateFile,STR) - - AA = np.loadtxt(BURST) - - SLC1_tab = workDir + '/' + Mdate + '_SLC_Tab0' - SLC2_tab = workDir + '/' + Sdate + '_SLC_Tab0' - - SLC1_INF_tab = workDir + '/' + Mdate + '_SLC_Tab' - SLC2_INF_tab = workDir + '/' + Sdate + '_SLC_Tab' - - BURST1_tab = workDir + '/' + Mdate + '_Burst_Tab' - BURST2_tab = workDir + '/' + Sdate + '_Burst_Tab' - - if os.path.isfile(SLC1_tab): - os.remove(SLC1_tab) - - if os.path.isfile(SLC2_tab): - os.remove(SLC2_tab) - - if os.path.isfile(SLC1_INF_tab): - os.remove(SLC1_INF_tab) - - if os.path.isfile(SLC2_INF_tab): - os.remove(SLC2_INF_tab) - - if os.path.isfile(BURST1_tab): - os.remove(BURST1_tab) - - if os.path.isfile(BURST2_tab): - os.remove(BURST2_tab) - - for kk in range(int(EW)-int(SW)+1): - call_str = 'echo ' + MslcDir + '/' + Mdate+'.IW'+str(int(SW)+kk) + '.slc' + ' ' + MslcDir + '/'+ Mdate + '.IW'+str(int(SW)+kk) +'.slc.par' + ' ' + MslcDir + '/'+ Mdate+'.IW'+str(int(SW)+kk) + '.slc.TOPS_par >>' + SLC1_tab - os.system(call_str) - - call_str = 'echo ' + SslcDir + '/' + Sdate+'.IW'+str(int(SW)+kk) + '.slc' + ' ' + SslcDir + '/'+ Sdate + '.IW'+str(int(SW)+kk) +'.slc.par' + ' ' + SslcDir + '/'+ Sdate+'.IW'+str(int(SW)+kk) + '.slc.TOPS_par >>' + SLC2_tab - os.system(call_str) - - ii = kk + 1 - SB1=AA[ii-1,0] - EB1=AA[ii-1,1] - - SB2=AA[ii-1,2] - EB2=AA[ii-1,3] - - call_str = 'echo ' + workDir + '/'+ Mdate+ '_'+ str(int(SB1)) + str(int(EB1)) +'.IW'+str(int(SW)+kk)+ '.slc' + ' ' + workDir + '/' + Mdate + '_'+ str(int(SB1)) + str(int(EB1)) +'.IW'+ str(int(SW)+kk)+ '.slc.par' + ' ' + workDir + '/'+ Mdate+'_'+ str(int(SB1)) + str(int(EB1)) + '.IW'+str(int(SW)+kk)+ '.slc.TOPS_par >>' + SLC1_INF_tab - os.system(call_str) - - - call_str = 'echo ' + workDir + '/'+ Sdate+ '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+str(int(SW)+kk)+ '.slc' + ' ' + workDir + '/' + Sdate + '_'+ str(int(SB2)) + str(int(EB2)) +'.IW'+ str(int(SW)+kk)+ '.slc.par' + ' ' + workDir + '/'+ Sdate+'_'+ str(int(SB2)) + str(int(EB2)) + '.IW'+str(int(SW)+kk)+ '.slc.TOPS_par >>' + SLC2_INF_tab - os.system(call_str) - - call_str = 'echo ' + str(int(SB1)) + ' ' + str(int(EB1)) + ' >>' + BURST1_tab - os.system(call_str) - - call_str = 'echo ' + str(int(SB2)) + ' ' + str(int(EB2)) + ' >>' + BURST2_tab - os.system(call_str) - - call_str = 'SLC_copy_S1_TOPS ' + SLC1_tab + ' ' + SLC1_INF_tab + ' ' + BURST1_tab - os.system(call_str) - - call_str = 'SLC_copy_S1_TOPS ' + SLC2_tab + ' ' + SLC2_INF_tab + ' ' + BURST2_tab - os.system(call_str) - - call_str = 'SLC_mosaic_S1_TOPS ' + SLC1_INF_tab + ' ' + MslcImg + ' ' + MslcPar + ' ' + rlks + ' ' +azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + MslcImg + ' ' + MslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = 'SLC_mosaic_S1_TOPS ' + SLC2_INF_tab + ' ' + SslcImg + ' ' + SslcPar + ' ' + rlks + ' ' +azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SslcImg + ' ' + SslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(SamprlksPar, 'read', 'range_samples') - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenIgram_Gamma.py.bak b/pyint/GenIgram_Gamma.py.bak deleted file mode 100755 index 09a41eb..0000000 --- a/pyint/GenIgram_Gamma.py.bak +++ /dev/null @@ -1,303 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Generateing Interferograms based on GAMMA - - usage: - - GenIgram_Gamma.py igramDir - - e.g. GenIgram_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. GenIgram_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. GenIgram_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 - -******************************************************************************************************* - ''' - - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - if INF=='IFG' or INF=='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define Interferometry parameters ########################## - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# Parameter setting for Igram - - if 'Igram_Rlooks' in templateContents: rLooksIgram = templateContents['Igram_Rlooks'] - else: rLooksIgram = '4' - if 'Igram_Alooks' in templateContents: aLooksIgram = templateContents['Igram_Alooks'] - else: aLooksIgram = '4' - if 'Unify_master ' in templateContents: Unify_master = templateContents['Unify_master'] - else: Unify_master = '0' - - if 'Igram_Spsflg' in templateContents: spsflgIgram = templateContents['Igram_Spsflg'] - else: spsflgIgram = '1' - if 'Igram_Azfflg' in templateContents: azfflgIgram = templateContents['Igram_Azfflg'] - else: azfflgIgram = '1' - if 'Igram_Rp1flg' in templateContents: rp1flgIgram = templateContents['Igram_Rp1flg'] - else: rp1flgIgram = '1' - if 'Igram_Rp2flg' in templateContents: rp2flgIgram = templateContents['Igram_Rp2flg'] - else: rp2flgIgram = '1' - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - if 'Igram_Cor_Rwin' in templateContents: rWinCor = templateContents['Igram_Cor_Rwin'] - else: rWinCor = '5' - if 'Igram_Cor_Awin' in templateContents: aWinCor = templateContents['Igram_Cor_Awin'] - else: aWinCor = '5' - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Igram_FilterMethod' in templateContents: strFilterMethod = templateContents['Igram_FilterMethod'] - else: strFilterMethod = 'adapt_filt' - if 'Igram_FilterStrength' in templateContents: strFilterStrengeh = templateContents['Igram_FilterStrength'] - else: strFilterStrengeh = '0.8/4' - fFiltLength = strFilterStrengeh.split('/')[0] - nFiltWindow = strFilterStrengeh.split('/')[1] - if 'Igram_FFTLength' in templateContents: nAzfft = templateContents['Igram_FFTLength'] - else: nAzfft = '512' - - if 'Coreg_int' in templateContents: Coreg_int = templateContents['Coreg_int'] - else: Coreg_int = '1' - -############################### Interferometry Processing #################################################### - BLANK = workDir + '/' + Mdate + '-' + Sdate + '.blk' - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' -### start generation of interferogram with coregistered master and slave in each pair - - - if os.path.isfile(OFF): - os.remove(OFF) - - if not Coreg_int=='1': - MrslcImg = rslcDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = rslcDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = rslcDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = rslcDir + "/" + Sdate + Suffix[i]+".rslc.par" - - call_str = '$GAMMA_BIN/create_offset '+ MrslcPar + ' ' + SrslcPar + ' ' + OFF + ' 1 - - 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/SLC_intf '+ MrslcImg + ' ' + SrslcImg + ' ' + MrslcPar + ' ' + SrslcPar + ' ' + OFF + ' ' + INT + ' 1 1 - - ' + spsflgIgram + ' ' + azfflgIgram + ' ' + rp1flgIgram + ' ' + rp2flgIgram - os.system(call_str) - -### start co-registartion of raw interferogram w.r.t. master scene - - #if Unify_master == '1': - # call_str = "Resamp_all_Gamma.py " + igramDir ## after this step, all based on rslc - # os.system(call_str) - -### continue interferometric process with re-coregistered slc parameter w.r.t. master scene - - #if os.path.isfile(OFF): - # os.remove(OFF) - - #call_str = '$GAMMA_BIN/create_offset '+ MrslcPar + ' ' + SrslcPar + ' ' + OFF + ' 1 - - 0' - #os.system(call_str) ## update the OFF file, if do the last step "COREG_all_Flag" - - call_str = '$GAMMA_BIN/base_orbit '+ MrslcPar + ' ' + SrslcPar + ' ' + BASE - os.system(call_str) - -# if flagTDM == 'Y': ### flag for TanDEM-X bistatic mode case to conside half length of baseline -# call_str = '$INT_SCR/halfbase.pl ' + BASE; -# os.system(call_str) - - call_str = '$GAMMA_BIN/multi_cpx '+ INT + ' ' + OFF + ' ' + INTlks + ' ' + OFFlks + ' ' + rlks + ' ' + azlks - os.system(call_str) -######################## flatten phase remove ################################ - - call_str = '$GAMMA_BIN/ph_slope_base '+ INTlks + ' ' + MrslcPar + ' ' + OFFlks + ' ' + BASE + ' ' + FLTlks - os.system(call_str) - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - - call_str = '$GAMMA_BIN/cc_wave '+ INTlks + ' ' + MamprlksImg + ' ' + SamprlksImg + ' ' + CORlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc ' + CORlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(CORlks, CORlks) - - #if flatteningIgram == 'fft': - # call_str = '$GAMMA_BIN/base_est_fft ' + FLTlks + ' ' + MrslcPar + ' ' + OFFlks + ' ' + BASE_REF + ' ' + nAzfft - # os.system(call_str) - - # call_str = '$GAMMA_BIN/ph_slope_base ' + FLTlks + ' ' + MrslcPar + ' ' + OFFlks + ' ' + BASE_REF + ' ' + FLTFFTlks - # os.system(call_str) - - # FLTlks = FLTFFTlks - # call_str = '$GAMMA_BIN/base_add ' + BASE + ' ' + BASE_REF + ' ' + BASE + '.tmp' - # os.system(call_str) - # os.rename(BASE+'.tmp', BASE) - - # FLTFILTlks = FLTlks.replace('flat_', 'filt_') - -######################## filtering ################################ - #call_str = '$GAMMA_BIN/rasmph_pwr ' + FLTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - 2.0 0.3 - ' - #os.system(call_str) - #ras2jpg(FLTlks, FLTlks) - - #call_str = '$GAMMA_BIN/adf ' + FLTlks + ' ' + FLTFILTlks + ' ' + CORFILTlks + ' ' + nWidth + ' 0.5' - #os.system(call_str) - - #if strFilterMethod == 'adapt_filt': - # call_str = '$GAMMA_BIN/adapt_filt ' + FLTlks + ' ' + FLTFILTlks + ' ' + nWidth + ' ' + fFiltLength + ' ' + nFiltWindow - # os.system(call_str) - - #call_str = '$GAMMA_BIN/cc_wave '+ FLTFILTlks + ' ' + MamprlksImg + ' ' + SamprlksImg + ' ' + CORFILTlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - #os.system(call_str) - - #call_str = '$GAMMA_BIN/rasmph_pwr ' + FLTFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - 2.0 0.3 - ' - #os.system(call_str) - #ras2jpg(FLTFILTlks, FLTFILTlks) - - #call_str = '$GAMMA_BIN/rascc ' + CORFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - #os.system(call_str) - #ras2jpg(CORFILTlks, CORFILTlks) - - print "Interferogram generation is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenLT_Sen_Gamm.py.bak b/pyint/GenLT_Sen_Gamm.py.bak deleted file mode 100755 index 0434622..0000000 --- a/pyint/GenLT_Sen_Gamm.py.bak +++ /dev/null @@ -1,278 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Generate lookup table for Sentinel-1 data for resampling - - usage: - - GenLT_Sen_Gamm.py ProjectName Mdate Sdate workDir - - e.g. GenLT_Sen_Gamm.py PacayaT163TsxHhA 131021 131101 /Yunmeng/SCRATCH - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)>=4: - projectName = sys.argv[1] - Mdate = sys.argv[2] - Sdate = sys.argv[3] - if len(sys.argv)==5: - workDir = sys.argv[4] - else: - workDir = os.getcwd() - else: - usage();sys.exit(1) - - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - - - INF = 'IFG' - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - -# output slcs - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - Srslc0Img = workDir + "/" + Sdate + ".rslc0" - Srslc0Par = workDir + "/" + Sdate + ".rslc0.par" - -# output multi-looked amplitude - - MamprlksImg = workDir + "/" + Mdate + "_" + rlks+"rlks.amp" - MamprlksPar = workDir + "/" + Mdate + "_" + rlks+"rlks.amp.par" - SamprlksImg = workDir + "/" + Sdate + "_" + rlks+"rlks.amp" - SamprlksPar = workDir + "/" + Sdate + "_" + rlks+"rlks.amp.par" - OFFSTD = workDir + "/" + Mdate + '-' + Sdate +".off_std" - - simDir = scratchDir + '/' + projectName + "/SIM" - simDir = simDir + '/sim_' + Mdate - - HGTSIM = simDir + '/sim_' + Mdate + '_' + rlks+'rlks.rdc.dem' - - if not os.path.isfile(HGTSIM): - call_str= "Generate_RdcDEM_Gamma.py " + projectName + ' ' + Mdate - os.system(call_str) - - lt0 = workDir + "/lt0" - lt1 = workDir + "/" + Mdate + '.lt' - STD= workDir + "/" + Mdate + '.lt_std' - mli0 = workDir + "/mli0" - diff0 = workDir + "/diff0" - offs0 = workDir + "/offs0" - snr0 = workDir + "/snr0" - offsets0 = workDir + "/offsets0" - coffs0 = workDir + "/coffs0" - coffsets0 = workDir + "/coffsets0" - off = workDir + "/" + Mdate + "-" + Sdate + ".off" - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - - if os.path.isfile(diff0): - os.remove(diff0) - if os.path.isfile(off): - os.remove(off) - -# real processing - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + SslcImg + " " + SslcPar + " " + SamprlksImg + " " + SamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = "$GAMMA_BIN/rdc_trans " + MamprlksPar + " " + HGTSIM + " " + SamprlksPar + " " + lt0 - os.system(call_str) - - width_Mamp = UseGamma(MamprlksPar, 'read', 'range_samples') - width_Samp = UseGamma(SamprlksPar, 'read', 'range_samples') - line_Samp = UseGamma(SamprlksPar, 'read', 'azimuth_lines') - - call_str = "$GAMMA_BIN/geocode " + lt0 + " " + MamprlksImg + " " + width_Mamp + " " + mli0 + " " + width_Samp + " " + line_Samp + " 2 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/create_diff_par " + SamprlksPar + " - " + diff0 + " 1 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/init_offsetm " + mli0 + " " + SamprlksImg + " " + diff0 + " 2 2 - - - - - 512" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rwin4cor + " " + azwin4cor + " " + offsets0 + " 2 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rfwin4cor + " " + azfwin4cor + " " + offsets0 + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 4 >" + STD - os.system(call_str) - - - - call_str = "$GAMMA_BIN/gc_map_fine " + lt0 + " " + width_Mamp + " " + diff0 + " " + lt1 - os.system(call_str) - - - - os.remove(lt0) - os.remove(mli0) - os.remove(diff0) - os.remove(offs0) - os.remove(snr0) - os.remove(offsets0) - os.remove(coffs0) - os.remove(coffsets0) - - - print "Generate lookup table for resampling is done!" - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenOff_DEM_Gamma.py.bak b/pyint/GenOff_DEM_Gamma.py.bak deleted file mode 100755 index 044ec96..0000000 --- a/pyint/GenOff_DEM_Gamma.py.bak +++ /dev/null @@ -1,371 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Estimating the offsets of two SAR images based on cross-correlation. - - usage: - - GenOff_DEM_Gamma.py ProjectName Mdate Sdate workDir - - e.g. GenOff_DEM_Gamma.py PacayaT163TsxHhA 131021 131101 /Yunmeng/SCRATCH - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)>=4: - projectName = sys.argv[1] - Mdate = sys.argv[2] - Sdate = sys.argv[3] - if len(sys.argv)==5: - workDir = sys.argv[4] - else: - workDir = os.getcwd() - else: - usage();sys.exit(1) - - - workDir0 = workDir + '/' + Sdate - call_str ='mkdir ' + workDir0 - os.system(call_str) - workDir_Org = workDir - workDir = workDir0 - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - - - INF = 'IFG' - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - -# output slcs - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - Srslc0Img = workDir + "/" + Sdate + ".rslc0" - Srslc0Par = workDir + "/" + Sdate + ".rslc0.par" - -# output multi-looked amplitude - - MamprlksImg = workDir + "/" + Mdate + "_" + rlks+"rlks.amp" - MamprlksPar = workDir + "/" + Mdate + "_" + rlks+"rlks.amp.par" - SamprlksImg = workDir + "/" + Sdate + "_" + rlks+"rlks.amp" - SamprlksPar = workDir + "/" + Sdate + "_" + rlks+"rlks.amp.par" - OFFSTD = workDir + "/" + Mdate + '-' + Sdate +".off_std" - - simDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - - HGTSIM = simDir + '/sim_' + Mdate + '_' + rlks+'rlks.rdc.dem' - - if not os.path.isfile(HGTSIM): - call_str= "Generate_RdcDEM_Gamma.py " + projectName + ' ' + Mdate - os.system(call_str) - - lt0 = workDir + "/lt0" - lt1 = workDir + "/lt1" - mli0 = workDir + "/mli0" - diff0 = workDir + "/diff0" - offs0 = workDir + "/offs0" - snr0 = workDir + "/snr0" - offsets0 = workDir + "/offsets0" - coffs0 = workDir + "/coffs0" - coffsets0 = workDir + "/coffsets0" - off = workDir + "/" + Mdate + "-" + Sdate + ".off" - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - - if os.path.isfile(diff0): - os.remove(diff0) - if os.path.isfile(off): - os.remove(off) - -# real processing - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + SslcImg + " " + SslcPar + " " + SamprlksImg + " " + SamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = "$GAMMA_BIN/rdc_trans " + MamprlksPar + " " + HGTSIM + " " + SamprlksPar + " " + lt0 - os.system(call_str) - - width_Mamp = UseGamma(MamprlksPar, 'read', 'range_samples') - width_Samp = UseGamma(SamprlksPar, 'read', 'range_samples') - line_Samp = UseGamma(SamprlksPar, 'read', 'azimuth_lines') - - call_str = "$GAMMA_BIN/geocode " + lt0 + " " + MamprlksImg + " " + width_Mamp + " " + mli0 + " " + width_Samp + " " + line_Samp + " 2 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/create_diff_par " + SamprlksPar + " - " + diff0 + " 1 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/init_offsetm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + rlks + " " + azlks + " - - - - - 512" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rwin4cor + " " + azwin4cor + " " + offsets0 + " 2 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rfwin4cor + " " + azfwin4cor + " " + offsets0 + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 4" - os.system(call_str) - - - - call_str = "$GAMMA_BIN/gc_map_fine " + lt0 + " " + width_Mamp + " " + diff0 + " " + lt1 - os.system(call_str) - - - call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " - " + Srslc0Img + " " + Srslc0Par - os.system(call_str) - - -# further refinement processing for resampled SLC - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + Srslc0Par + " " + off + " 1 - - 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3 >" + OFFSTD - os.system(call_str) - -############################################ Resampling ############################################ - - - for i in range(len(Suffix)): - if not INF=='IFG': - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - -######################## Resampling Slave Image #################### - - call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " " + off + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - - #os.remove(lt0) - #os.remove(lt1) - #os.remove(mli0) - #os.remove(diff0) - os.remove(offs0) - os.remove(snr0) - os.remove(offsets0) - os.remove(coffs0) - os.remove(coffsets0) - os.remove(off) - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) - os.remove(Srslc0Img) - os.remove(Srslc0Par) - - call_str = 'mv ' + workDir+'/* ' + workDir_Org - os.system(call_str) - - call_str ='rm -rf ' + workDir - os.system(call_str) - - print "Coregistration with DEM is done!" - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenOff_DEM_Sen_Gamma.py.bak b/pyint/GenOff_DEM_Sen_Gamma.py.bak deleted file mode 100755 index 03ad698..0000000 --- a/pyint/GenOff_DEM_Sen_Gamma.py.bak +++ /dev/null @@ -1,374 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Estimating the offsets of two SAR images based on cross-correlation. - - usage: - - GenOff_DEM_Sen_Gamma.py ProjectName Mdate Sdate workDir - - e.g. GenOff_DEM_Sen_Gamma.py PacayaT163TsxHhA 131021 131101 /Yunmeng/SCRATCH - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)>=4: - projectName = sys.argv[1] - Mdate = sys.argv[2] - Sdate = sys.argv[3] - if len(sys.argv)==5: - workDir = sys.argv[4] - else: - workDir = os.getcwd() - else: - usage();sys.exit(1) - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - INF = 'IFG' - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# input slcs - - SslcDir = rslcDir + "/" + Sdate - MslcDir = rslcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - M_SLC_tab = MslcDir + "/" + Mdate + '_SLC_Tab' - M_RSLC_tab = MslcDir + "/" + Mdate + '_RSLC_Tab' - - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - S_SLC_tab = SslcDir + "/" + Sdate + '_SLC_Tab' - S_RSLC_tab = SslcDir + "/" + Sdate + '_RSLC_Tab' - -# output slcs - - MrslcImg = MslcDir + "/" + Mdate + ".rslc" - MrslcPar = MslcDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - Srslc0Img = workDir + "/" + Sdate + ".rslc0" - Srslc0Par = workDir + "/" + Sdate + ".rslc0.par" - -# output multi-looked amplitude - - MamprlksImg = workDir + "/" + Mdate + "_" + rlks+"rlks.amp" - MamprlksPar = workDir+ "/" + Mdate + "_" + rlks+"rlks.amp.par" - SamprlksImg = workDir + "/" + Sdate + "_" + rlks+"rlks.amp" - SamprlksPar = workDir + "/" + Sdate + "_" + rlks+"rlks.amp.par" - - #SramprlksImg = workDir + "/" + Sdate + "_" + rlks+"rlks.ramp" - #SramprlksPar = workDir + "/" + Sdate + "_" + rlks+"rlks.ramp.par" - OFFSTD = workDir + "/" + Mdate + '-' + Sdate +".off_std" - - demDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - #simDir = simDir + '/sim_' + Mdate - - HGTSIM = demDir + '/sim_' + Mdate + '_' + rlks+'rlks.rdc.dem' - - if not os.path.isfile(HGTSIM): - call_str= "Generate_RdcDEM_Gamma.py " + projectName + ' ' + Mdate - os.system(call_str) - - lt0 = workDir + "/lt0" - lt1 = workDir + "/" + Mdate + "-" + Sdate + ".lt" - if os.path.isfile(lt1): - os.remove(lt1) - - mli0 = workDir + "/mli0" - diff0 = workDir + "/diff0" - offs0 = workDir + "/offs0" - snr0 = workDir + "/snr0" - offsets0 = workDir + "/offsets0" - coffs0 = workDir + "/coffs0" - coffsets0 = workDir + "/coffsets0" - off = workDir + "/" + Mdate + "-" + Sdate + ".off" - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - - if os.path.isfile(diff0): - os.remove(diff0) - if os.path.isfile(off): - os.remove(off) - -# real processing - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + SslcImg + " " + SslcPar + " " + SamprlksImg + " " + SamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = "$GAMMA_BIN/rdc_trans " + MamprlksPar + " " + HGTSIM + " " + SamprlksPar + " " + lt0 - os.system(call_str) - - width_Mamp = UseGamma(MamprlksPar, 'read', 'range_samples') - width_Samp = UseGamma(SamprlksPar, 'read', 'range_samples') - line_Samp = UseGamma(SamprlksPar, 'read', 'azimuth_lines') - - call_str = "$GAMMA_BIN/geocode " + lt0 + " " + MamprlksImg + " " + width_Mamp + " " + mli0 + " " + width_Samp + " " + line_Samp + " 2 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/create_diff_par " + SamprlksPar + " - " + diff0 + " 1 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/init_offsetm " + mli0 + " " + SamprlksImg + " " + diff0 + " 2 2 - - - - - 512" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rwin4cor + " " + azwin4cor + " " + offsets0 + " 2 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwrm " + mli0 + " " + SamprlksImg + " " + diff0 + " " + offs0 + " " + snr0 + " " + rfwin4cor + " " + azfwin4cor + " " + offsets0 + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 4" - os.system(call_str) - - - - call_str = "$GAMMA_BIN/gc_map_fine " + lt0 + " " + width_Mamp + " " + diff0 + " " + lt1 - os.system(call_str) - - - #call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " - " + Srslc0Img + " " + Srslc0Par - #os.system(call_str) - - call_str = "$GAMMA_BIN/SLC_interp_lt_S1_TOPS " + S_SLC_tab + " " + SslcPar + " " + M_SLC_tab + " " + MslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " - " + S_RSLC_tab + " " + Srslc0Img + " " + Srslc0Par - os.system(call_str) - - -# further refinement processing for resampled SLC - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + Srslc0Par + " " + off + " 1 - - 0" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 1 " + rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3" - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 1 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3 >" + OFFSTD - os.system(call_str) - - -######################## Resampling Slave Image #################### - - #call_str = "$GAMMA_BIN/SLC_interp_lt " + SslcImg + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " " + off + " " + SrslcImg + " " + SrslcPar - #os.system(call_str) - - call_str = "$GAMMA_BIN/SLC_interp_lt_S1_TOPS " + S_SLC_tab + " " + SslcPar + " " + M_SLC_tab + " " + MslcPar + " " + lt1 + " " + MamprlksPar + " " + SamprlksPar + " " + off + " " + S_RSLC_tab + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - #call_str = "cp " + M_SLC_tab + " " + M_RSLC_tab - #os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - #MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - #MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - #call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - #os.system(call_str) - - #call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - #os.system(call_str) - - #nWidth = UseGamma(SamprlksPar, 'read', 'range_samples') - - #call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - #os.system(call_str) - #ras2jpg(MamprlksImg, MamprlksImg) - - #call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - #os.system(call_str) - #ras2jpg(SamprlksImg, SamprlksImg) - - - - os.remove(lt0) - #os.remove(lt1) - os.remove(mli0) - os.remove(diff0) - os.remove(offs0) - os.remove(snr0) - os.remove(offsets0) - os.remove(coffs0) - os.remove(coffsets0) - #os.remove(off) - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) - os.remove(Srslc0Img) - os.remove(Srslc0Par) - - #SS = glob.glob(workDir + '/*.rslc*') - - #for kk in SS: - # kk2 = kk.replace('.rslc','.slc') - # call_str = 'mv ' + kk + ' ' + kk2 - # os.system(call_str) - - os.chdir(workDir) - call_str = 'rm *IW*rslc*' - os.system(call_str) - - #call_str ='rm -rf ' + workDir - #os.system(call_str) - - print "Generate lookup table and off is done." - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenOff_Gamma.py.bak b/pyint/GenOff_Gamma.py.bak deleted file mode 100755 index 73c3395..0000000 --- a/pyint/GenOff_Gamma.py.bak +++ /dev/null @@ -1,348 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Estimating the offsets of two SAR images based on cross-correlation. - - usage: - - GenOff_Gamma.py ProjectName Mdate Sdate workDir - - e.g. GenOff_Gamma.py PacayaT163TsxHhA 131021 131101 /Yunmeng/SCRATCH - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)>=4: - projectName = sys.argv[1] - Mdate = sys.argv[2] - Sdate = sys.argv[3] - if len(sys.argv)==5: - workDir = sys.argv[4] - else: - workDir = os.getcwd() - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - IFGPair = Mdate + '-' + Sdate - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'JOB' in templateContents: JOB = templateContents['JOB'] - else: JOB = 'IFG' - - INF=JOB - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'rlks4cor' in templateContents: rlks4cor = templateContents['rlks4cor'] - else: rlks4cor = '4' - if 'azlks4cor' in templateContents: azlks4cor = templateContents['azlks4cor'] - else: azlks4cor = '4' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - -# input files definition - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks.ramp' - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks.ramp.par' - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks.ramp' - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks.ramp.par' - -# output files of coregistration - - off = workDir + "/" + IFGPair + ".off" - offs = workDir + "/" + IFGPair +".offs" - snr = workDir + "/" + IFGPair +".snr" - offsets = workDir + "/" + IFGPair + ".offsets" - coffs = workDir + "/" + IFGPair + ".coffs" - coffsets = workDir + "/" + IFGPair + ".coffsets" - off_std = workDir + "/" + IFGPair + ".off_std" - -################################### start to coregistrate ########################################## - if os.path.isfile(off): - os.remove(off) - - - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + SslcPar + " " + off + " 1 - - 0" - os.system(call_str) - - if coregCoarse == 'both': - print 'init offset estimation by both orbit and ampcor' - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - - elif coregCoarse == 'orbit': - print 'init offset estimation by orbit only' - - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - elif coregCoarse == 'ampcor': - print 'init offset estimation by ampcor only' - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - -######################## 1st time ############################ - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 "+ rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 3" - os.system(call_str) - -######################## 2nd time ############################# - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 4 >" + off_std - os.system(call_str) - - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) -############################################################################################################# - - - call_str = "$GAMMA_BIN/SLC_interp " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - -############################################################################################################### - if not INF == 'IFG': - for i in range(len(Suffix)): - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - if not ( os.path.isfile(MslcImg) and os.path.isfile(MslcPar) and os.path.isfile(SslcImg) and os.path.isfile(SslcPar) ): - call_str = INF + '_SLC_Gamma.py ' + igramDir - os.system(call_str) - - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - -######################## Resampling Slave Image #################### - - - - call_str = "$GAMMA_BIN/SLC_interp " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + SrslcImg + " " + SrslcPar - os.system(call_str) - - call_str = "cp " + MslcImg + " " + MrslcImg - os.system(call_str) - - call_str = "cp " + MslcPar + " " + MrslcPar - os.system(call_str) - - -#################### multi-looking for RSLC ######################################### - - call_str = '$GAMMA_BIN/multi_look ' + MrslcImg + ' ' + MrslcPar + ' ' + MamprlksImg + ' ' + MamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - call_str = '$GAMMA_BIN/multi_look ' + SrslcImg + ' ' + SrslcPar + ' ' + SamprlksImg + ' ' + SamprlksPar + ' ' + rlks + ' ' + azlks - os.system(call_str) - - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/raspwr ' + MamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(MamprlksImg, MamprlksImg) - - call_str = '$GAMMA_BIN/raspwr ' + SamprlksImg + ' ' + nWidth - os.system(call_str) - ras2jpg(SamprlksImg, SamprlksImg) - - print "Coregistrating for %s and %s images is done! " % ( Mdate, Sdate ) - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - \ No newline at end of file diff --git a/pyint/GenOff_Sen_All.py.bak b/pyint/GenOff_Sen_All.py.bak deleted file mode 100755 index 7935676..0000000 --- a/pyint/GenOff_Sen_All.py.bak +++ /dev/null @@ -1,164 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def usage(): - print ''' -****************************************************************************************************** - - Estimating the offsets of two SAR images based on cross-correlation. - - usage: - - GenOff_Sen_All.py ProjectName - - e.g. GenOff_Sen_All.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - projectName = sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - IFGPair = Mdate + '-' + Sdate - OFFDir = scratchDir + '/' + projectName + "/SLC/OFF" - - if not os.path.isdir(OFFDIR): - call_str = 'mkdir ' + OFFDIR - os.system(call_str); - - KK=os.listdir(slcDir) - Nm = [] - for ll in KK: - if is_numer(ll): - Nm.append(ll) - os.chdir(SLCPATH) - - if 'masterDate' in templateContents: - masterDate0 = templateContents['masterDate'] - if masterDate0 in Datelist: - masterDate = masterDate0 - print "masterDate : " + masterDate0 - else: - masterDate=Nm[0] - print "The selected masterDate is not included in above datelist !!" - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - - else: - masterDate=Nm[0] - print "masterDate is not found in template!!! " - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - - run_Genoff_Sen = OFFDIR + '/run_Genoff_Sen' - if os.path.isfile(run_Genoff_Sen): - call_str = 'rm ' + run_Genoff_Sen - os.system(call_str) - - for dd in Nm: - if dd != masterDate: - STR = 'GenOff_Sen_Gamma.py ' + projectName + ' ' + masterDate + ' ' + dd + ' ' + OFFDIR + '>> run_Genoff_Sen' - call_str = 'echo ' + STR - - call_str = 'BatchProcess.py -p ' + run_Genoff_Sen +' -m 3700 -t 1:00' - os.system(call_str) - - - print "Coregistrating for project %s is done! " % projectName - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - \ No newline at end of file diff --git a/pyint/GenOff_Sen_Gamma.py.bak b/pyint/GenOff_Sen_Gamma.py.bak deleted file mode 100755 index 97a5669..0000000 --- a/pyint/GenOff_Sen_Gamma.py.bak +++ /dev/null @@ -1,270 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Estimating the offsets of two SAR images based on cross-correlation. - - usage: - - GenOff_Sen_Gamma.py ProjectName Mdate Sdate workDir - - e.g. GenOff_Sen_Gamma.py PacayaT163TsxHhA 131021 131101 /Yunmeng/SCRATCH - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)>=4: - projectName = sys.argv[1] - Mdate = sys.argv[2] - Sdate = sys.argv[3] - if len(sys.argv)==5: - workDir = sys.argv[4] - else: - workDir = os.getcwd() - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - IFGPair = Mdate + '-' + Sdate - -################################# Define coregistration parameters ########################## - templateContents=read_template(templateFile) - - if 'JOB' in templateContents: JOB = templateContents['JOB'] - else: JOB = 'IFG' - - INF=JOB - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - - if 'Coreg_Coarse' in templateContents: coregCoarse = templateContents['Coreg_Coarse'] - else: coregCoarse = 'both' - - if 'rlks4cor' in templateContents: rlks4cor = templateContents['rlks4cor'] - else: rlks4cor = '4' - if 'azlks4cor' in templateContents: azlks4cor = templateContents['azlks4cor'] - else: azlks4cor = '4' - - if 'rwin4cor' in templateContents: rwin4cor = templateContents['rwin4cor'] - else: rwin4cor = '256' - if 'azwin4cor' in templateContents: azwin4cor = templateContents['azwin4cor'] - else: azwin4cor = '256' - if 'rsample4cor' in templateContents: rsample4cor = templateContents['rsample4cor'] - else: rsample4cor = '16' - if 'azsample4cor' in templateContents: azsample4cor = templateContents['azsample4cor'] - else: azsample4cor = '32' - - if ' rpos4cor' in templateContents: rpos4cor = templateContents[' rpos4cor'] - else: rpos4cor = ' - ' - if 'azpos4cor' in templateContents: azpos4cor = templateContents['azpos4cor'] - else: azpos4cor = ' - ' - - - - if 'rfwin4cor' in templateContents: rfwin4cor = templateContents['rfwin4cor'] - else: rfwin4cor = str(int(int(rwin4cor)/2)) - if 'azfwin4cor' in templateContents: azfwin4cor = templateContents['azfwin4cor'] - else: azfwin4cor = str(int(int(azwin4cor)/2)) - if 'rfsample4cor' in templateContents: rfsample4cor = templateContents['rfsample4cor'] - else: rfsample4cor = str(2*int(rsample4cor)) - if 'azfsample4cor' in templateContents: azfsample4cor = templateContents['azfsample4cor'] - else: azfsample4cor = str(2*int(azsample4cor)) - - if 'thresh4cor' in templateContents: thresh4cor = templateContents['thresh4cor'] - else: thresh4cor = ' - ' - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - - - -# input files definition - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks.ramp' - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks.ramp.par' - - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks.ramp' - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks.ramp.par' - -# output files of coregistration - - off = workDir + "/" + IFGPair + ".off" - offs = workDir + "/" + IFGPair +".offs" - snr = workDir + "/" + IFGPair +".snr" - offsets = workDir + "/" + IFGPair + ".offsets" - coffs = workDir + "/" + IFGPair + ".coffs" - coffsets = workDir + "/" + IFGPair + ".coffsets" - off_std = workDir + "/" + IFGPair + ".off_std" - -################################### start to coregistrate ########################################## - if os.path.isfile(off): - os.remove(off) - - - - call_str = "$GAMMA_BIN/create_offset " + MslcPar + " " + SslcPar + " " + off + " 1 - - 0" - os.system(call_str) - - if coregCoarse == 'both': - print 'init offset estimation by both orbit and ampcor' - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - - elif coregCoarse == 'orbit': - print 'init offset estimation by orbit only' - - call_str = '$GAMMA_BIN/init_offset_orbit '+ MslcPar + ' ' + SslcPar + ' ' + off - os.system(call_str) - - elif coregCoarse == 'ampcor': - print 'init offset estimation by ampcor only' - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' ' + rlks4cor + ' ' + azlks4cor + ' ' + rpos4cor + ' ' + azpos4cor - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offset '+ MslcImg + ' ' + SslcImg + ' ' + MslcPar + ' ' + SslcPar + ' ' + off + ' 1 1 - - ' - os.system(call_str) - -######################## 1st time ############################ - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rwin4cor + " " + azwin4cor + " " + offsets + " 2 "+ rsample4cor + " " + azsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 3" - os.system(call_str) - -######################## 2nd time ############################# - - call_str = "$GAMMA_BIN/offset_pwr " + MslcImg + " " + SslcImg + " " + MslcPar + " " + SslcPar + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor - os.system(call_str) - - call_str = "$GAMMA_BIN/offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " " + thresh4cor +" 4 >" + off_std - os.system(call_str) - - os.remove(offs) - os.remove(snr) - os.remove(offsets) - os.remove(coffs) - os.remove(coffsets) -############################################################################################################# - - - - - print "Coregistrating for %s and %s images is done! " % ( Mdate, Sdate ) - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - \ No newline at end of file diff --git a/pyint/GenerateRSC_Gamma.py.bak b/pyint/GenerateRSC_Gamma.py.bak deleted file mode 100755 index 912a6be..0000000 --- a/pyint/GenerateRSC_Gamma.py.bak +++ /dev/null @@ -1,386 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def UseGamma2(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[2].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Generate Roi_PAC RSC file based on GAMMA par file - - usage: - - GenerateRSC_Gamma.py igramDir - - e.g. GenerateRSC_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. GenerateRSC_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. GenerateRSC_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - TS_RSC = workDir + '/' + IFGPair + '_' + rlks + 'rlks.rsc' - OFF_STD = workDir + '/' + Mdate + '-' + Sdate + '.off_std' - - MRSLCPAR = workDir + '/' + Mdate + Suffix[0] + '.rslc.par' - MCORNER = workDir + '/' + Mdate + Suffix[0] + '.corner' - MLATLON = workDir + '/' + Mdate + Suffix[0] + '.latlon' - SRSLCPAR = workDir + '/' + Sdate + Suffix[0] + '.rslc.par' - - OFF = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[0] + '.off' - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base' - PBASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_perp' - PBASE_TXT = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_perp_txt' - BVH_TXT = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_vh_txt' - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - SLC_par = workDir + '/' + Mdate + '_' + rlks +'rlks.ramp.par' - SLC_par2 = workDir + '/' + Sdate + '_' + rlks +'rlks.ramp.par' - nWidth = UseGamma(SLC_par, 'read', 'range_samples:') - nLine = UseGamma(SLC_par, 'read', 'azimuth_lines:') - - f = open(TS_RSC,'w') - -# print 'FILE_LENGTH ' + nLine -# print 'WIDTH ' + nWidth - wstr = 'PROJECT ' + projectName + '\n' - f.write(wstr) - - wstr = 'FILE_LENGTH ' + nLine + '\n' - f.write(wstr) - wstr = 'WIDTH ' + nWidth + '\n' - f.write(wstr) - - freq_rd = UseGamma(SLC_par, 'read', 'radar_frequency:') - freq_rd = freq_rd.split(' ')[0] - wave = str((3*(10**8))/float(freq_rd)) -# print 'WAVELENGTH ' + wave - wstr = 'WAVELENGTH ' + wave + '\n' - f.write(wstr) - - Range_pix = UseGamma(SLC_par, 'read', 'range_pixel_spacing:') - RP = Range_pix.split('m')[0] - Azimuth_pix = UseGamma(SLC_par, 'read', 'azimuth_pixel_spacing:') - AP = Azimuth_pix.split('m')[0] - -# print 'RANGE_PIXEL_SIZE ' + RP - wstr = 'RANGE_PIXEL_SIZE ' + RP + '\n' - f.write(wstr) -# print 'AZIMUTH_PIXEL_SIZE ' + AP - wstr = 'AZIMUTH_PIXEL_SIZE ' + AP + '\n' - f.write(wstr) - - Earth_Radius = '6378135.33251539' -# print 'EARTH_RADIUS ' + Earth_Radius - wstr = 'EARTH_RADIUS ' + Earth_Radius + '\n' - f.write(wstr) - - - CentLine_UTC = UseGamma(SLC_par, 'read', 'center_time:') - CU = CentLine_UTC.split('s')[0] -# print 'CENTER_LINE_UTC ' + CU - wstr = 'CENTER_LINE_UTC ' + CU + '\n' - f.write(wstr) - - - SAR_TO_EC = UseGamma(SLC_par, 'read', 'sar_to_earth_center:') - SAR_TO_EC = SAR_TO_EC.split('m')[0] - - HEIGHT = str(float(SAR_TO_EC)-float(Earth_Radius)) - -# print 'HEIGHT ' + HEIGHT - wstr = 'HEIGHT ' + HEIGHT + '\n' - f.write(wstr) - - - HEADING = UseGamma(SLC_par, 'read', 'heading:') - HEADING = HEADING.split('degrees')[0] -# print 'HEADING ' + HEADING - wstr = 'HEADING ' + HEADING + '\n' - f.write(wstr) - - if float(HEADING) > 180.0 : - HD = abs(float(HEADING) -360) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - elif float(HEADING) < (-180.0): - HD = abs(float(HEADING) + 360) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - else: - HD = abs(float(HEADING)) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - -# print 'ORBIT_DIRECTION ' + ORBIT_DIRECTION - wstr = 'ORBIT_DIRECTION ' + ORBIT_DIRECTION + '\n' - f.write(wstr) - - - - PRF = UseGamma(SLC_par, 'read', 'prf:') - PRF = PRF.split('Hz')[0] -# print 'PRF ' + PRF - wstr = 'PRF ' + PRF + '\n' - f.write(wstr) - - wstr = 'DATE ' + masterDate + '\n' - f.write(wstr) - - Near_Range = UseGamma(SLC_par, 'read', 'near_range_slc:') - NR = Near_Range.split('m')[0] -# print 'STARTING_RANGE ' + NR - wstr = 'STARTING_RANGE ' + NR + '\n' - f.write(wstr) - - wstr = 'STARTING_RANGE1 ' + NR + '\n' - f.write(wstr) - - Near_Range = UseGamma(SLC_par2, 'read', 'near_range_slc:') - NR = Near_Range.split('m')[0] -# print 'STARTING_RANGE ' + NR - wstr = 'STARTING_RANGE2 ' + NR + '\n' - f.write(wstr) - - Center_Range = UseGamma(SLC_par, 'read', 'center_range_slc:') - Far_Range = UseGamma(SLC_par, 'read', 'far_range_slc:') - - call_str = 'base_orbit ' + MRSLCPAR + ' ' + SRSLCPAR + ' ' + BASE - os.system(call_str) - - call_str = 'base_perp ' + BASE + ' ' + MRSLCPAR + ' ' + OFF + ' >' + PBASE - os.system(call_str) - - #call_str ='cat ' + PBASE + ' | tail -n +13 | head -n 50 >' +PBASE_TXT Bug fix, 2018/06/19 Yunmeng - count = len(open(PBASE,'rU').readlines()) - call_str ='cat ' + PBASE + ' | tail -n +13 | head -n ' + str(int(count-18)) + ' > '+PBASE_TXT - os.system(call_str) - - BB=np.loadtxt(PBASE_TXT) - XX = BB[:,0] - XX = map(int,XX) - - BP0 = BB[:,7] - LA0 = BB[:,5] - XX = np.asarray(XX) - BP0 = np.asarray(BP0) - LA0 = np.asarray(LA0) - - ndx = np.where(XX==0) - BP =BP0[ndx] - LA = LA0[ndx] - - P_BASELINE_TOP_HDR = str(BP[0]) - P_BASELINE_BOTTOM_HDR = str(BP[len(BP)-1]) - - wstr = 'P_BASELINE_TOP_HDR ' + P_BASELINE_TOP_HDR + '\n' - f.write(wstr) - wstr = 'P_BASELINE_BOTTOM_HDR ' + P_BASELINE_BOTTOM_HDR + '\n' - f.write(wstr) - - wstr = 'LOOK_REF1 ' + str(LA[0]) + '\n' - f.write(wstr) - - wstr = 'LOOK_REF2 ' + str(LA[len(LA)-1]) + '\n' - f.write(wstr) - - call_str ='SLC_corners ' + MRSLCPAR + ' > ' + MCORNER - os.system(call_str) - call_str = "awk 'NR==3,NR==6 {print $3,$6} ' " + MCORNER + '> ' + MLATLON - os.system(call_str) - LL = np.loadtxt(MLATLON) - - wstr = 'LAT_REF1 ' + str(LL[0][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF1 ' + str(LL[0][1]) + '\n' - f.write(wstr) - - wstr = 'LAT_REF2 ' + str(LL[1][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF2 ' + str(LL[1][1]) + '\n' - f.write(wstr) - - - wstr = 'LAT_REF3 ' + str(LL[2][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF3 ' + str(LL[2][1]) + '\n' - f.write(wstr) - - wstr = 'LAT_REF4 ' + str(LL[3][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF4 ' + str(LL[3][1]) + '\n' - f.write(wstr) - - - call_str = "awk 'NR==1,NR==2 {print $3,$4}' " + BASE + " > " + BVH_TXT - os.system(call_str) - BVH=np.loadtxt(BVH_TXT) - - H_BASELINE_TOP_HDR = str(BVH[0][0]) -# print 'H_BASELINE_TOP_HDR ' + H_BASELINE_TOP_HDR - wstr = 'H_BASELINE_TOP_HDR ' + H_BASELINE_TOP_HDR + '\n' - f.write(wstr) - - H_BASELINE_RATE_HDR = str(BVH[1][0]) -# print 'H_BASELINE_RATE_HDR ' + H_BASELINE_RATE_HDR - wstr = 'H_BASELINE_RATE_HDR ' + H_BASELINE_RATE_HDR + '\n' - f.write(wstr) - - V_BASELINE_TOP_HDR = str(BVH[0][1]) -# print 'V_BASELINE_TOP_HDR ' + V_BASELINE_TOP_HDR - wstr = 'V_BASELINE_TOP_HDR ' + V_BASELINE_TOP_HDR + '\n' - f.write(wstr) - - V_BASELINE_RATE_HDR = str(BVH[1][1]) -# print 'V_BASELINE_RATE_HDR ' + V_BASELINE_RATE_HDR - wstr = 'V_BASELINE_RATE_HDR ' + V_BASELINE_RATE_HDR + '\n' - f.write(wstr) - - RR = UseGamma(OFF_STD,'read','final range offset poly. coeff.:') - cor_rg = RR.split(' ')[0] - - AA = UseGamma(OFF_STD,'read','final azimuth offset poly. coeff.:') - cor_az = AA.split(' ')[0] - - STDRR = UseGamma(OFF_STD,'read','final model fit std. dev. (samples) range:') - std_rg=STDRR.split(' ')[0] - - std_az = UseGamma2(OFF_STD,'read','final model fit std. dev. (samples) range:') - - wstr = 'RANGE_OFFSET ' + cor_az + '\n' - f.write(wstr) - wstr = 'RANGE_OFFSET_STD ' + std_rg + '\n' - f.write(wstr) - wstr = 'AZIMUTH_OFFSET ' + cor_az + '\n' - f.write(wstr) - wstr = 'AZIMUTH_OFFSET_STD ' + std_az + '\n' - f.write(wstr) - - f.close() - - sys.exit(1) - - -if __name__ == '__main__': - main(sys.argv[1:]) - - - - - - diff --git a/pyint/GenerateRSC_Gamma_All.py.bak b/pyint/GenerateRSC_Gamma_All.py.bak deleted file mode 100755 index 7a536d7..0000000 --- a/pyint/GenerateRSC_Gamma_All.py.bak +++ /dev/null @@ -1,200 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst_Ref(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - M1 = min(Mindex) - M2 = max(Mindex) - - S1 = min(Sindex) - S2 = max(Sindex) - - if M1==1: S1 = S1 - else: - S1=1-M1+1 - M1=1 - - - if M2 ==len(La_M): S2 = S2 - else: - S2 = S2 + len(La_M) - M2 - M2 = len(La_M) - - - return M1 , M2, S1, S2 - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Generate parameter file for the whole project. -''' - -EXAMPLE = ''' - Usage: - GenerateRSC_Sen_Gamma_All.py projectName - - Examples: - GenerateRSC_Sen_Gamma_All.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - IFGLIST = glob.glob(processDir+'/IFG*'+ projectName + '*') - - TT = 'out.txt' - if os.path.isfile(TT): - os.remove(TT) - for kk in IFGLIST: - print '>>> Process ' + os.path.basename(kk) - call_str = 'GenerateRSC_Gamma.py ' + os.path.basename(kk) + ' >> ' + TT - os.system(call_str) - - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/GenerateRSC_Sen_Gamma.py.bak b/pyint/GenerateRSC_Sen_Gamma.py.bak deleted file mode 100755 index 6d92919..0000000 --- a/pyint/GenerateRSC_Sen_Gamma.py.bak +++ /dev/null @@ -1,413 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def UseGamma2(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[2].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Generate Roi_PAC RSC file based on GAMMA par file - - usage: - - GenerateRSC_Gamma.py igramDir - - e.g. GenerateRSC_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. GenerateRSC_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. GenerateRSC_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if 'Resamp_All' in templateContents: Resamp_All = templateContents['Resamp_All'] - else: Resamp_All = '1' - - processDir = scratchDir + '/' + projectName + "/PROCESS" - workDir = processDir + '/' + igramDir - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - MslcDir = rslcDir + '/' + Mdate - SslcDir = rslcDir + '/' + Sdate - - MrslcImg = workDir + '/' + Mdate + '.rslc' - SrslcImg = workDir+ '/' + Sdate + '.rslc' - MrslcPar = workDir + '/' + Mdate + '.rslc.par' - SrslcPar = workDir + '/' + Sdate + '.rslc.par' - - masterDir = rslcDir + '/' + masterDate - TS_RSC = workDir + '/' + IFGPair + '_' + rlks + 'rlks.rsc' - - if os.path.isfile(TS_RSC): - os.remove(TS_RSC) - - OFF_STD = workDir + '/' + Mdate + '-' + Sdate + '.off_std' - - MCORNER = workDir + '/' + Mdate + Suffix[0] + '.corner' - MLATLON = workDir + '/' + Mdate + Suffix[0] + '.latlon' - - - OFF = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[0] + '.off' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base' - PBASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_perp' - PBASE_TXT = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_perp_txt' - BVH_TXT = workDir + '/' + Mdate + '-' + Sdate + Suffix[0] + '.base_vh_txt' - - - SLC_par = MslcDir + '/' + Mdate + '_' + rlks +'rlks.amp.par' - SLC_par2 = SslcDir + '/' + Sdate + '_' + rlks +'rlks.amp.par' - if Resamp_All =='1': - SLC_par = masterDir + '/' + masterDate + '_' + rlks +'rlks.amp.par' - MrslcImg = MslcDir + '/' + Mdate + '.rslc' - SrslcImg = SslcDir + '/' + Sdate + '.rslc' - MrslcPar = MslcDir + '/' + Mdate + '.rslc.par' - SrslcPar = SslcDir + '/' + Sdate + '.rslc.par' - - if os.path.isfile(OFF): - os.remove(OFF) - - call_str = 'create_offset ' + MrslcPar + ' ' + SrslcPar + ' ' + OFF + ' 1 ' + rlks + ' ' + azlks + ' 0' - os.system(call_str) - - nWidth = UseGamma(SLC_par, 'read', 'range_samples:') - nLine = UseGamma(SLC_par, 'read', 'azimuth_lines:') - - f = open(TS_RSC,'w') - -# print 'FILE_LENGTH ' + nLine -# print 'WIDTH ' + nWidth - wstr = 'PROJECT ' + projectName + '\n' - f.write(wstr) - - wstr = 'FILE_LENGTH ' + nLine + '\n' - f.write(wstr) - wstr = 'WIDTH ' + nWidth + '\n' - f.write(wstr) - - freq_rd = UseGamma(SLC_par, 'read', 'radar_frequency:') - freq_rd = freq_rd.split(' ')[0] - wave = str((3*(10**8))/float(freq_rd)) -# print 'WAVELENGTH ' + wave - wstr = 'WAVELENGTH ' + wave + '\n' - f.write(wstr) - - Range_pix = UseGamma(SLC_par, 'read', 'range_pixel_spacing:') - RP = Range_pix.split('m')[0] - Azimuth_pix = UseGamma(SLC_par, 'read', 'azimuth_pixel_spacing:') - AP = Azimuth_pix.split('m')[0] - -# print 'RANGE_PIXEL_SIZE ' + RP - wstr = 'RANGE_PIXEL_SIZE ' + RP + '\n' - f.write(wstr) -# print 'AZIMUTH_PIXEL_SIZE ' + AP - wstr = 'AZIMUTH_PIXEL_SIZE ' + AP + '\n' - f.write(wstr) - - Earth_Radius = '6378135.33251539' -# print 'EARTH_RADIUS ' + Earth_Radius - wstr = 'EARTH_RADIUS ' + Earth_Radius + '\n' - f.write(wstr) - - - CentLine_UTC = UseGamma(SLC_par, 'read', 'center_time:') - CU = CentLine_UTC.split('s')[0] -# print 'CENTER_LINE_UTC ' + CU - wstr = 'CENTER_LINE_UTC ' + CU + '\n' - f.write(wstr) - - - SAR_TO_EC = UseGamma(SLC_par, 'read', 'sar_to_earth_center:') - SAR_TO_EC = SAR_TO_EC.split('m')[0] - - HEIGHT = str(float(SAR_TO_EC)-float(Earth_Radius)) - -# print 'HEIGHT ' + HEIGHT - wstr = 'HEIGHT ' + HEIGHT + '\n' - f.write(wstr) - - - HEADING = UseGamma(SLC_par, 'read', 'heading:') - HEADING = HEADING.split('degrees')[0] -# print 'HEADING ' + HEADING - wstr = 'HEADING ' + HEADING + '\n' - f.write(wstr) - - if float(HEADING) > 180.0 : - HD = abs(float(HEADING) -360) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - elif float(HEADING) < (-180.0): - HD = abs(float(HEADING) + 360) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - else: - HD = abs(float(HEADING)) - if HD > 90: - ORBIT_DIRECTION = 'descending' - else: - ORBIT_DIRECTION = 'ascending' - -# print 'ORBIT_DIRECTION ' + ORBIT_DIRECTION - wstr = 'ORBIT_DIRECTION ' + ORBIT_DIRECTION + '\n' - f.write(wstr) - - - - PRF = UseGamma(SLC_par, 'read', 'prf:') - PRF = PRF.split('Hz')[0] -# print 'PRF ' + PRF - wstr = 'PRF ' + PRF + '\n' - f.write(wstr) - - wstr = 'DATE ' + masterDate + '\n' - f.write(wstr) - - Near_Range = UseGamma(SLC_par, 'read', 'near_range_slc:') - NR = Near_Range.split('m')[0] -# print 'STARTING_RANGE ' + NR - wstr = 'STARTING_RANGE ' + NR + '\n' - f.write(wstr) - - wstr = 'STARTING_RANGE1 ' + NR + '\n' - f.write(wstr) - - Near_Range = UseGamma(SLC_par2, 'read', 'near_range_slc:') - NR = Near_Range.split('m')[0] -# print 'STARTING_RANGE ' + NR - wstr = 'STARTING_RANGE2 ' + NR + '\n' - f.write(wstr) - - Center_Range = UseGamma(SLC_par, 'read', 'center_range_slc:') - Far_Range = UseGamma(SLC_par, 'read', 'far_range_slc:') - - call_str = 'base_orbit ' + MrslcPar + ' ' + SrslcPar + ' ' + BASE - os.system(call_str) - - call_str = 'base_perp ' + BASE + ' ' + MrslcPar + ' ' + OFF + ' >' + PBASE - os.system(call_str) - - count = len(open(PBASE,'rU').readlines()) - - #call_str ='cat ' + PBASE + ' | tail -n +13 | head -n 50 >' +PBASE_TXT - call_str ='cat ' + PBASE + ' | tail -n +13 | head -n ' + str(int(count-18)) + ' > '+PBASE_TXT - os.system(call_str) - - BB=np.loadtxt(PBASE_TXT) - XX = BB[:,0] - XX = map(int,XX) - - BP0 = BB[:,7] - LA0 = BB[:,5] - XX = np.asarray(XX) - BP0 = np.asarray(BP0) - LA0 = np.asarray(LA0) - - ndx = np.where(XX==0) - BP =BP0[ndx] - LA = LA0[ndx] - - P_BASELINE_TOP_HDR = str(BP[0]) - P_BASELINE_BOTTOM_HDR = str(BP[len(BP)-1]) - - wstr = 'P_BASELINE_TOP_HDR ' + P_BASELINE_TOP_HDR + '\n' - f.write(wstr) - wstr = 'P_BASELINE_BOTTOM_HDR ' + P_BASELINE_BOTTOM_HDR + '\n' - f.write(wstr) - - wstr = 'LOOK_REF1 ' + str(LA[0]) + '\n' - f.write(wstr) - - wstr = 'LOOK_REF2 ' + str(LA[len(LA)-1]) + '\n' - f.write(wstr) - - call_str ='SLC_corners ' + MrslcPar + ' > ' + MCORNER - os.system(call_str) - call_str = "awk 'NR==3,NR==6 {print $3,$6} ' " + MCORNER + '> ' + MLATLON - os.system(call_str) - LL = np.loadtxt(MLATLON) - - wstr = 'LAT_REF1 ' + str(LL[0][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF1 ' + str(LL[0][1]) + '\n' - f.write(wstr) - - wstr = 'LAT_REF2 ' + str(LL[1][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF2 ' + str(LL[1][1]) + '\n' - f.write(wstr) - - - wstr = 'LAT_REF3 ' + str(LL[2][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF3 ' + str(LL[2][1]) + '\n' - f.write(wstr) - - wstr = 'LAT_REF4 ' + str(LL[3][0]) + '\n' - f.write(wstr) - wstr = 'LON_REF4 ' + str(LL[3][1]) + '\n' - f.write(wstr) - - - call_str = "awk 'NR==1,NR==2 {print $3,$4}' " + BASE + " > " + BVH_TXT - os.system(call_str) - BVH=np.loadtxt(BVH_TXT) - - H_BASELINE_TOP_HDR = str(BVH[0][0]) -# print 'H_BASELINE_TOP_HDR ' + H_BASELINE_TOP_HDR - wstr = 'H_BASELINE_TOP_HDR ' + H_BASELINE_TOP_HDR + '\n' - f.write(wstr) - - H_BASELINE_RATE_HDR = str(BVH[1][0]) -# print 'H_BASELINE_RATE_HDR ' + H_BASELINE_RATE_HDR - wstr = 'H_BASELINE_RATE_HDR ' + H_BASELINE_RATE_HDR + '\n' - f.write(wstr) - - V_BASELINE_TOP_HDR = str(BVH[0][1]) -# print 'V_BASELINE_TOP_HDR ' + V_BASELINE_TOP_HDR - wstr = 'V_BASELINE_TOP_HDR ' + V_BASELINE_TOP_HDR + '\n' - f.write(wstr) - - V_BASELINE_RATE_HDR = str(BVH[1][1]) -# print 'V_BASELINE_RATE_HDR ' + V_BASELINE_RATE_HDR - wstr = 'V_BASELINE_RATE_HDR ' + V_BASELINE_RATE_HDR + '\n' - f.write(wstr) - - #RR = UseGamma(OFF_STD,'read','final range offset poly. coeff.:') - #cor_rg = RR.split(' ')[0] - - #AA = UseGamma(OFF_STD,'read','final azimuth offset poly. coeff.:') - #cor_az = AA.split(' ')[0] - - #STDRR = UseGamma(OFF_STD,'read','final model fit std. dev. (samples) range:') - #std_rg=STDRR.split(' ')[0] - - #std_az = UseGamma2(OFF_STD,'read','final model fit std. dev. (samples) range:') - - #wstr = 'RANGE_OFFSET ' + cor_az + '\n' - #f.write(wstr) - #wstr = 'RANGE_OFFSET_STD ' + std_rg + '\n' - #f.write(wstr) - #wstr = 'AZIMUTH_OFFSET ' + cor_az + '\n' - #f.write(wstr) - #wstr = 'AZIMUTH_OFFSET_STD ' + std_az + '\n' - #f.write(wstr) - - f.close() - - sys.exit(1) - - -if __name__ == '__main__': - main(sys.argv[1:]) - - - - - - diff --git a/pyint/GenerateRSC_Sen_Gamma_All.py.bak b/pyint/GenerateRSC_Sen_Gamma_All.py.bak deleted file mode 100755 index d1c91cf..0000000 --- a/pyint/GenerateRSC_Sen_Gamma_All.py.bak +++ /dev/null @@ -1,200 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst_Ref(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - M1 = min(Mindex) - M2 = max(Mindex) - - S1 = min(Sindex) - S2 = max(Sindex) - - if M1==1: S1 = S1 - else: - S1=1-M1+1 - M1=1 - - - if M2 ==len(La_M): S2 = S2 - else: - S2 = S2 + len(La_M) - M2 - M2 = len(La_M) - - - return M1 , M2, S1, S2 - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Generate parameter file for the whole project. -''' - -EXAMPLE = ''' - Usage: - GenerateRSC_Sen_Gamma_All.py projectName - - Examples: - GenerateRSC_Sen_Gamma_All.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - IFGLIST = glob.glob(processDir+'/IFG*'+ projectName + '*') - - TT = 'out.txt' - if os.path.isfile(TT): - os.remove(TT) - for kk in IFGLIST: - print '>>> Process ' + os.path.basename(kk) - call_str = 'GenerateRSC_Sen_Gamma.py ' + os.path.basename(kk) + ' >> ' + TT - os.system(call_str) - - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Generate_IfgDir.py.bak b/pyint/Generate_IfgDir.py.bak deleted file mode 100755 index 874e5a9..0000000 --- a/pyint/Generate_IfgDir.py.bak +++ /dev/null @@ -1,137 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def usage(): - print ''' -****************************************************************************************************** - - Select interferometry pairs from time series SAR images - - usage: - - Generate_IfgDir.py ProjectName IFG_List - - e.g. Generate_IfgDir.py PacayaT163TsxHhA ifg_list - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==3: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - IFG_List=sys.argv[2] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - processDir = scratchDir + '/' + projectName + "/PROCESS" - - IFGLIST = glob.glob(processDir+'/*_' +projectName + '_*') - LIST0=[] - for kk in IFGLIST: - SS = os.path.basename(kk) - L0 = SS.split('_')[2] - kk0 = SS.split(L0)[0]+ L0 - LIST0.append(kk0) - - if not os.path.isdir(processDir): - call_str='mkdir ' + processDir - os.system(call_str) - - Dirlist = [] - fd=file(IFG_List,'r') - - for line in fd.readlines(): - if len(line)>0: - Dirlist.append(line) - - for ff in Dirlist: - master = ff.split('-')[0] - slave = ff.split('-')[1] - slave = str(int(slave)) - if len(slave)==5: - slave = '0'+slave - - STR = 'IFG' + '_' + projectName + '_' + master + '-' + slave + '_1000_1000' - STR0 = 'IFG' + '_' + projectName + '_' + master + '-' + slave - - if not STR0 in LIST0: - call_str ='mkdir ' + processDir+'/' + STR - os.system(call_str) - print 'Generate directory ' + STR + ' \n' - - - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - diff --git a/pyint/Generate_RdcDEM_Gamma.py.bak b/pyint/Generate_RdcDEM_Gamma.py.bak deleted file mode 100755 index eb7e331..0000000 --- a/pyint/Generate_RdcDEM_Gamma.py.bak +++ /dev/null @@ -1,285 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generating Radar coordinates-based DEM based on GEO-DEM files. - If no dem file found, makedem.py will be called. - - usage: - - Generate_RdcDEM_Gamma.py projectName Date - - e.g. Generate_RdcDEM_Gamma.py PacayaT163TsxHhA 100201 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==3: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - Date=sys.argv[2] - else: - usage();sys.exit(1) - - Mdate = Date - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDir = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - simDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - - workDir = simDir - - if 'DEM' in templateContents: - dem = templateContents['DEM'] - if not os.path.isfile(dem): - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo DEM= ' + dem + ' >> ' + templateFile - os.system(call_str) - else: - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo DEM = ' + dem + ' >> ' + templateFile - os.system(call_str) - demPar = dem + ".par" - - if not os.path.isfile(dem): - call_str = 'Makedem_PyINT.py ' + projectName + ' gamma' - os.system(call_str) - - - - -# Parameter setting for simPhase - - - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '256' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '256' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - -# Definition of file - MslcDir = slcDir + '/' + Mdate - - - MslcImg = MslcDir + '/' + Mdate + '.slc' - MslcPar = MslcDir + '/' + Mdate + '.slc.par' - OFFSTD = workDir + '/' + Mdate + '_dem.off_std' - - - BLANK = workDir + '/' + Mdate + '.blk' - - MamprlksImg = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - - - UTMDEMpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.pix' - LSMAP = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offs' - SIMSNR = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.rdc.dem' - - - - - if not (os.path.isdir(simDir)): - os.makedirs(simDir) - - createBlankFile(BLANK) - - -### remove DEM look up table if it existed for considering gamma overlapping - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - #call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - os.system(call_str) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' 2 2 ' + rposSimphase + ' ' + azposSimphase #+ ' - - - 512' - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + rwinSimphase + ' ' + azwinSimphase + ' ' + SIMOFFSET #+ ' - 128 128 ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5 > ' + OFFSTD - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Generate_RdcDEM_Rslc_ALL.py.bak b/pyint/Generate_RdcDEM_Rslc_ALL.py.bak deleted file mode 100755 index ad28233..0000000 --- a/pyint/Generate_RdcDEM_Rslc_ALL.py.bak +++ /dev/null @@ -1,168 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - -def usage(): - print ''' -****************************************************************************************************** - - Generating Radar coordinates-based DEM based on GEO-DEM files. - If no dem file found, makedem.py will be called. - - usage: - - Generate_RdcDEM_Rslc_ALL.py projectName - - e.g. Generate_RdcDEM_Rslc_ALL.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDir = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - - ListSLC = os.listdir(slcDir) - Datelist = [] - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - - run_GenDEM_rslc_all = processDir + '/run_GenDEM_rslc_all' - if os.path.isfile(run_GenDEM_rslc_all): - os.remove(run_GenDEM_rslc_all) - - - for kk in Datelist: - STR = 'echo Generate_RdcDEM_Rslc_Gamma.py ' + projectName + ' ' + kk + ' >>' + run_GenDEM_rslc_all - os.system(STR) - - call_str='$INT_SCR/createBatch.pl ' + run_GenDEM_rslc_all + ' memory=3700 ' + ' walltime= 1:00' - os.system(call_str) - - - print "Create RdcDEM based on rslcs in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Generate_RdcDEM_Rslc_Gamma.py.bak b/pyint/Generate_RdcDEM_Rslc_Gamma.py.bak deleted file mode 100755 index 507f9d7..0000000 --- a/pyint/Generate_RdcDEM_Rslc_Gamma.py.bak +++ /dev/null @@ -1,285 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generating Radar coordinates-based DEM based on GEO-DEM files. - If no dem file found, makedem.py will be called. - - usage: - - Generate_RdcDEM_Gamma.py projectName Date - - e.g. Generate_RdcDEM_Gamma.py PacayaT163TsxHhA 100201 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==3: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - Date=sys.argv[2] - else: - usage();sys.exit(1) - - Mdate = Date - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDir = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - simDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - - workDir = simDir - - if 'DEM' in templateContents: - dem = templateContents['DEM'] - if not os.path.isfile(dem): - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo ' + dem + ' >> ' + templateFile - os.system(call_str) - else: - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo ' + dem + ' >> ' + templateFile - os.system(call_str) - demPar = dem + ".par" - - if not os.path.isfile(dem): - call_str = 'Makedem_PyINT.py ' + projectName + ' gamma' - os.system(call_str) - - - - -# Parameter setting for simPhase - - - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '256' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '256' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - -# Definition of file - MslcDir = slcDir + '/' + Mdate - - - MslcImg = rslcDir + '/' + Mdate + '.rslc' - MslcPar = rslcDir + '/' + Mdate + '.rslc.par' - OFFSTD = workDir + '/' + Mdate + '_dem.off_std' - - - BLANK = workDir + '/' + Mdate + '.blk' - - MamprlksImg = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - - - UTMDEMpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.pix' - LSMAP = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offs' - SIMSNR = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.rdc.dem' - - - - - if not (os.path.isdir(simDir)): - os.makedirs(simDir) - - createBlankFile(BLANK) - - -### remove DEM look up table if it existed for considering gamma overlapping - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - os.system(call_str) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' 2 2 ' + rposSimphase + ' ' + azposSimphase + ' - - - 512' - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + rwinSimphase + ' ' + azwinSimphase + ' ' + SIMOFFSET + ' - 128 128 ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5 > ' + OFFSTD - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Generate_RdcDEM_Sen_ALL.py.bak b/pyint/Generate_RdcDEM_Sen_ALL.py.bak deleted file mode 100755 index 1336f38..0000000 --- a/pyint/Generate_RdcDEM_Sen_ALL.py.bak +++ /dev/null @@ -1,171 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - -def usage(): - print ''' -****************************************************************************************************** - - Generating Radar coordinates-based DEM based on GEO-DEM files. - If no dem file found, makedem.py will be called. - - usage: - - Generate_RdcDEM_Sen_ALL.py projectName - - e.g. Generate_RdcDEM_Sen_ALL.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDir = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - - ListSLC = os.listdir(slcDir) - Datelist = [] - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - - run_GenDEM_rslc_all = processDir + '/DEM/run_GenDEM_rslc_all' - if os.path.isfile(run_GenDEM_rslc_all): - os.remove(run_GenDEM_rslc_all) - - - for kk in Datelist: - STR = 'echo Generate_RdcDEM_Sen_Gamma.py ' + projectName + ' ' + kk + ' >>' + run_GenDEM_rslc_all - os.system(STR) - - call_str='rm job*' - os.system(call_str) - - call_str='$INT_SCR/createBatch.pl ' + run_GenDEM_rslc_all + ' memory=5000 ' + ' walltime= 1:00' - os.system(call_str) - - - print "Create RdcDEM based on rslcs in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Generate_RdcDEM_Sen_Gamma.py.bak b/pyint/Generate_RdcDEM_Sen_Gamma.py.bak deleted file mode 100755 index e65184c..0000000 --- a/pyint/Generate_RdcDEM_Sen_Gamma.py.bak +++ /dev/null @@ -1,287 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generating Radar coordinates-based DEM based on GEO-DEM files. - If no dem file found, makedem.py will be called. - - usage: - - Generate_RdcDEM_Gamma.py projectName Date - - e.g. Generate_RdcDEM_Gamma.py PacayaT163TsxHhA 100201 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==3: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName=sys.argv[1] - Date=sys.argv[2] - else: - usage();sys.exit(1) - - Mdate = Date - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDir = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - simDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - - - workDir = simDir - - if 'DEM' in templateContents: - dem = templateContents['DEM'] - if not os.path.isfile(dem): - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo DEM= ' + dem + ' >> ' + templateFile - os.system(call_str) - else: - dem = DEMDir + '/' + projectName + '/' + projectName + '.dem' - call_str = 'echo DEM = ' + dem + ' >> ' + templateFile - os.system(call_str) - demPar = dem + ".par" - - if not os.path.isfile(dem): - call_str = 'Makedem_PyINT.py ' + projectName + ' gamma' - os.system(call_str) - - - - -# Parameter setting for simPhase - - - - if 'Simphase_Lat_Ovr' in templateContents: latovrSimphase = templateContents['Simphase_Lat_Ovr'] - else: latovrSimphase = '2' - if 'Simphase_Lon_Ovr' in templateContents: lonovrSimphase = templateContents['Simphase_Lon_Ovr'] - else: lonovrSimphase = '2' - - - if 'Simphase_rpos' in templateContents: rposSimphase = templateContents['Simphase_rpos'] - else: rposSimphase = '-' - if 'Simphase_azpos' in templateContents: azposSimphase = templateContents['Simphase_azpos'] - else: azposSimphase = '-' - - if 'Simphase_rwin' in templateContents: rwinSimphase = templateContents['Simphase_rwin'] - else: rwinSimphase = '256' - if 'Simphase_azwin' in templateContents: azwinSimphase = templateContents['Simphase_azwin'] - else: azwinSimphase = '256' - if 'Simphase_thresh' in templateContents: threshSimphase = templateContents['Simphase_thresh'] - else: threshSimphase = '-' - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - -# Definition of file - MslcDir = rslcDir + '/' + Mdate - - - MslcImg = MslcDir + '/' + Mdate + '.slc' - MslcPar = MslcDir + '/' + Mdate + '.slc.par' - OFFSTD = workDir + '/' + Mdate + '_dem.off_std' - - - BLANK = workDir + '/' + Mdate + '.blk' - - MamprlksImg = MslcDir+ '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar = MslcDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - - - UTMDEMpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.pix' - LSMAP = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offs' - SIMSNR = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.snr' - SIMOFFSET = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.offset' - SIMCOFF = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + Mdate + '_'+ rlks + 'rlks.rdc.dem' - - - - - if not (os.path.isdir(simDir)): - os.makedirs(simDir) - - createBlankFile(BLANK) - - -### remove DEM look up table if it existed for considering gamma overlapping - - if os.path.isfile(UTMDEM): - os.remove(UTMDEM) - if os.path.isfile(UTMDEMpar): - os.remove(UTMDEMpar) - if os.path.isfile(UTM2RDC): - os.remove(UTM2RDC) - - nWidthUTMDEM0 = UseGamma(demPar, 'read', 'width') - DateFormat = UseGamma(demPar, 'read', 'data_format:') - - if DateFormat == 'INTEGER*2': - DF_type = '4' - else: - DF_type = '2' - - - tmp_dem = dem + '_tmp' - - if not os.path.isfile(tmp_dem): - call_str = '$GAMMA_BIN/replace_values ' + dem + ' -10000 0 ' + tmp_dem + ' ' + nWidthUTMDEM0 + ' 2 ' + DF_type - os.system(call_str) - call_str = 'cp ' + tmp_dem + ' ' + dem - os.system(call_str) - - #if not os.path.isfile(MslcImg): - call_str = "$GAMMA_BIN/multi_look " + MslcImg + " " + MslcPar + " " + MamprlksImg + " " + MamprlksPar + " " + rlks + " " + azlks - os.system(call_str) - - - #call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - call_str = '$GAMMA_BIN/gc_map ' + MamprlksPar + ' ' + '-' + ' ' + demPar + ' ' + dem + ' ' + UTMDEMpar + ' ' + UTMDEM + ' ' + UTM2RDC + ' ' + latovrSimphase + ' ' + lonovrSimphase + ' ' + SIMSARUTM + ' - - - - ' + PIX + ' ' + LSMAP + ' - 3 128' - os.system(call_str) - - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLinePWR1 = UseGamma(MamprlksPar, 'read', 'azimuth_lines') - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples') - - call_str = '$GAMMA_BIN/geocode ' + UTM2RDC + ' ' + SIMSARUTM + ' ' + nWidthUTMDEM + ' ' + SIMSARRDC + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + SIMDIFFpar + ' 1 < ' + BLANK - os.system(call_str) - - call_str = '$GAMMA_BIN/init_offsetm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' 2 2 ' + rposSimphase + ' ' + azposSimphase #+ ' - - - 512' - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_pwrm ' + SIMSARRDC + ' ' + MamprlksImg + ' ' + SIMDIFFpar + ' ' + SIMOFFS + ' ' + SIMSNR + ' ' + rwinSimphase + ' ' + azwinSimphase + ' ' + SIMOFFSET #+ ' - 128 128 ' + threshSimphase - os.system(call_str) - - call_str = '$GAMMA_BIN/offset_fitm ' + SIMOFFS + ' ' + SIMSNR + ' ' + SIMDIFFpar + ' ' + SIMCOFF + ' ' + SIMCOFFSETS + ' 0.5 > ' + OFFSTD - os.system(call_str) - - call_str = '$GAMMA_BIN/gc_map_fine ' + UTM2RDC + ' ' + nWidthUTMDEM + ' ' + SIMDIFFpar + ' ' + UTMTORDC + ' 1' - os.system(call_str) - - call_str = '$GAMMA_BIN/geocode ' + UTMTORDC + ' ' + UTMDEM + ' ' + nWidthUTMDEM + ' ' + HGTSIM + ' ' + nWidth + ' ' + nLinePWR1 + ' 0 0 - - 1 1 1' - os.system(call_str) - - - - print "Create DEM in Radar Coordinates is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Geocode_Gamma.py.bak b/pyint/Geocode_Gamma.py.bak deleted file mode 100755 index bede48c..0000000 --- a/pyint/Geocode_Gamma.py.bak +++ /dev/null @@ -1,319 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if ( inFile.rsplit('.')[1] == 'int' or inFile.rsplit('.')[1] == 'diff' ): - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Geocoding GAMMA files: slc, mli, int, unw, flt, cor... - - - usage: - - Geocode_Gamma.py igramDir - - e.g. Geocode_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Geocode_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Geocode_Gamma.py SPI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - demDir = processDir + '/DEM' - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - masterDate = templateContents['masterDate'] - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - geoDir= scratchDir + '/' + projectName + "/PROCESS" + "/GEO" - if not os.path.isdir(geoDir): - str_call="mkdir " + geoDir - os.system(str_call) - - geoDir = geoDir + "/geo_" + IFGPair - if not os.path.isdir(geoDir): - str_call="mkdir " + geoDir - os.system(str_call) - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - ### geocode process - - if 'Topo_Flag' in templateContents: flagTopo = templateContents['Topo_Flag'] - else: flagTopo = 'N' - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - - if 'unwrapMethod' in templateContents: unwrapMethod = templateContents['unwrapMethod'] - else: unwrapMethod = 'mcf' - -# Definition of file - simDir = demDir - - masterDate = Mdate - UTMDEMpar = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.pix' - LSMAP = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.offs' - SIMSNR = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.snr' - SIMOFFSET = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.offset' - SIMCOFF = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.rdc.dem' - SIMUNW = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_unw' - - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' - - DIFFpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.diff.par' - - DIFFINTlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - DIFFINTFFTlks = DIFFINTlks.replace('diff_', 'diff_sim_') - - CORDIFFlks = workDir+'/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORDIFFFILTlks = workDir+'/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - MASKTHINlks = CORFILTlks + 'maskt.bmp' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - GEOINT = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.int' - GEOFILTINT = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.filt.int' - GEOPWR = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.amp' - GEOCOR = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.diff.cor' - - GEODIFFRAWINT = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.diff.int' - GEODIFFINT = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.diff_filt.int' - GEOUNW = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.unw' - GEOQUADUNW = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks' + Suffix[i] +'.quad_fit.unw' - - if flatteningIgram == 'orbit': - FLTFILTlks = FLTlks.replace('flat_', 'filt_') - else : - FLTFILTlks = FLTFFTlks.replace('flat_', 'filt_') - - if flatteningDiff == 'orbit': - DIFFINTFILTlks = DIFFINTlks.replace('diff_', 'diff_filt_') - else: - DIFFINTFILTlks = DIFFINTFFTlks.replace('diff_', 'diff_filt_') - - if flagTopo == 'Y': - WRAPlks = FLTFILTlks - else: - WRAPlks = DIFFINTFILTlks - - if unwrapMethod == "mcf": - UNWlks = WRAPlks.replace('.int', '.unw') - else: - UNWlks = WRAPlks.replace('.int', '.branch.unw') - - QUADUNWlks = UNWlks.replace('.unw','.quad_fit.unw') - - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLineUTMDEM = UseGamma(UTMDEMpar, 'read', 'nlines') - - -# if flatteningIgram == 'fft': -# FLTlks = FLTFFTlks - -# FLTFILTlks = FLTlks.replace('flat_', 'filt_') - - geocode(MamprlksImg, GEOPWR, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(CORDIFFFILTlks, GEOCOR, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(FLTlks, GEOINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(FLTFILTlks, GEOFILTINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - - call_str = '$GAMMA_BIN/raspwr ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - ' - os.system(call_str) - - ras2jpg(GEOPWR, GEOPWR) - - call_str = '$GAMMA_BIN/rascc ' + GEOCOR + ' ' + nWidthUTMDEM + ' - - - - - - - - - -' - os.system(call_str) - ras2jpg(GEOCOR, GEOCOR) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + GEOINT + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(GEOINT, GEOINT) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + GEOFILTINT + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(GEOFILTINT, GEOFILTINT) - - geocode(DIFFINTlks, GEODIFFRAWINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(DIFFINTFILTlks, GEODIFFINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(UNWlks, GEOUNW, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + GEODIFFRAWINT + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(GEODIFFRAWINT, GEODIFFRAWINT) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + GEODIFFINT + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(GEODIFFINT, GEODIFFINT) - - call_str = '$GAMMA_BIN/rasrmg ' + GEOUNW + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(GEOUNW, GEOUNW) - - if flatteningUnwrap == 'Y': - geocode(QUADUNWlks, GEOQUADUNW, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - call_str = '$GAMMA_BIN/rasrmg ' + GEOQUADUNW + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(GEOQUADUNW, GEOQUADUNW) - - - print "Geocoding is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Geocode_Sen_Gamma.py.bak b/pyint/Geocode_Sen_Gamma.py.bak deleted file mode 100755 index 9c0bd9d..0000000 --- a/pyint/Geocode_Sen_Gamma.py.bak +++ /dev/null @@ -1,271 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if ( inFile.rsplit('.')[1] == 'int' or inFile.rsplit('.')[1] == 'diff' ): - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Geocoding GAMMA files: slc, mli, int, unw, flt, cor... - - - usage: - - Geocode_Gamma.py igramDir - - e.g. Geocode_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Geocode_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Geocode_Gamma.py SPI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - demDir = processDir + '/DEM' - simDir = demDir - MslcDir = rslcDir + '/' + Mdate - SslcDir = rslcDir + '/' + Sdate - - templateContents=read_template(templateFile) - if 'Resamp_All' in templateContents: Resamp_All = templateContents['Resamp_All'] - else: Resamp_All = '1' - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - masterDate = templateContents['masterDate'] - masterDir = rslcDir + '/' + masterDate - - - if not Resamp_All=='1': - masterDate = Mdate - - UTMDEMpar = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm.dem.par' - UTMDEM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm.dem' - UTM2RDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.utm_to_rdc' - SIMSARUTM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_sar_utm' - PIX = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.pix' - LSMAP = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.ls_map' - SIMSARRDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_sar_rdc' - SIMDIFFpar = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.diff_par' - SIMOFFS = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.offs' - SIMSNR = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.snr' - SIMOFFSET = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.offset' - SIMCOFF = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.coff' - SIMCOFFSETS = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.coffsets' - UTMTORDC = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.UTM_TO_RDC' - HGTSIM = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.rdc.dem' - SIMUNW = simDir + '/sim_' + masterDate + '_'+rlks +'rlks.sim_unw' - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - geoDir= scratchDir + '/' + projectName + "/PROCESS" + "/GEO" - if not os.path.isdir(geoDir): - str_call="mkdir " + geoDir - os.system(str_call) - - geoDir = geoDir + "/geo_" + IFGPair - if not os.path.isdir(geoDir): - str_call="mkdir " + geoDir - os.system(str_call) - - - ### geocode process - - if 'Topo_Flag' in templateContents: flagTopo = templateContents['Topo_Flag'] - else: flagTopo = 'N' - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - - - MamprlksImg = MslcDir + '/' + Mdate + '_' + rlks + 'rlks.amp' - MamprlksPar = MslcDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - - MrslcPar = workDir + '/' + Mdate + '.rslc.par' - MrslcImg = workDir + '/' + Mdate + '.rslc' - SrslcPar = workDir + '/' + Sdate + '.rslc.par' - SrslcImg = workDir + '/' + Sdate + '.rslc' - - - if Resamp_All=='1': - MamprlksImg = masterDir + '/' + masterDate + '_' + rlks + 'rlks.amp' - MamprlksPar = masterDir + '/' + masterDate + '_' + rlks + 'rlks.amp.par' - MrslcPar = MslcDir + '/' + Mdate + '.rslc.par' - MrslcImg = MslcDir + '/' + Mdate + '.rslc' - SrslcPar = SslcDir + '/' + Sdate + '.rslc.par' - SrslcImg = SslcDir + '/' + Sdate + '.rslc' - - -# Definition of file - UNWlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.unw' - CORDIFFFILTlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.cor' - DIFFINTFILTlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - QUADUNWlks = UNWlks.replace('.unw','.quad_fit.unw') - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.off' - - GEOPWR = geoDir + '/geo_' + os.path.basename(MamprlksImg) - GEOCOR = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks.diff_filt.cor' - GEODIFFINT = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks.diff_filt.int' - GEOUNW = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks.unw' - GEOQUADUNW = geoDir + '/geo_' + Mdate + '-' + Sdate + '_'+rlks + 'rlks.quad_fit.unw' - - if os.path.isfile(OFFlks): - os.remove(OFFlks) - - call_str = 'create_offset ' + MrslcPar + ' ' + SrslcPar + ' ' + OFFlks + ' 1 ' + rlks + ' ' + azlks + ' 0' - os.system(call_str) - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - nWidthUTMDEM = UseGamma(UTMDEMpar, 'read', 'width') - nLineUTMDEM = UseGamma(UTMDEMpar, 'read', 'nlines') - - -# if flatteningIgram == 'fft': -# FLTlks = FLTFFTlks - -# FLTFILTlks = FLTlks.replace('flat_', 'filt_') - - geocode(MamprlksImg, GEOPWR, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(CORDIFFFILTlks, GEOCOR, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - #geocode(FLTlks, GEOINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - #geocode(FLTFILTlks, GEOFILTINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - - call_str = '$GAMMA_BIN/raspwr ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - ' - os.system(call_str) - - ras2jpg(GEOPWR, GEOPWR) - - call_str = '$GAMMA_BIN/rascc ' + GEOCOR + ' ' + nWidthUTMDEM + ' - - - - - - - - - -' - os.system(call_str) - ras2jpg(GEOCOR, GEOCOR) - - geocode(DIFFINTFILTlks, GEODIFFINT, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - geocode(UNWlks, GEOUNW, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - - call_str = '$GAMMA_BIN/rasmph_pwr ' + GEODIFFINT + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - 2.0 0.3 - ' - os.system(call_str) - ras2jpg(GEODIFFINT, GEODIFFINT) - - call_str = '$GAMMA_BIN/rasrmg ' + GEOUNW + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(GEOUNW, GEOUNW) - - if flatteningUnwrap == 'Y': - geocode(QUADUNWlks, GEOQUADUNW, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM) - call_str = '$GAMMA_BIN/rasrmg ' + GEOQUADUNW + ' ' + GEOPWR + ' ' + nWidthUTMDEM + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(GEOQUADUNW, GEOQUADUNW) - - - print "Geocoding is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Get_off_std.py.bak b/pyint/Get_off_std.py.bak deleted file mode 100755 index 50ddbdf..0000000 --- a/pyint/Get_off_std.py.bak +++ /dev/null @@ -1,145 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def UseGamma2(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[2].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Get co-registration standard deviation of SLCs for one project - - usage: - - GenerateRSC_Gamma.py projectName - - e.g. Get_off_std.py GalapagosT061EnvA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - OFFDir = scratchDir + '/' + projectName + '/RSLC' - OFFSTR = OFFDir + '/*.off_std' - OFFFile = glob.glob(OFFSTR) - STD_TXT ='COREG_STD_ALL' - os.chdir(OFFDir) - if os.path.isfile(STD_TXT): - os.remove(STD_TXT) - - for ff in OFFFile: - OFF_STD = ff - NM = os.path.basename(ff).split('.')[0] - RR = UseGamma(OFF_STD,'read','final range offset poly. coeff.:') - cor_rg = RR.split(' ')[0] - - AA = UseGamma(OFF_STD,'read','final azimuth offset poly. coeff.:') - cor_az = AA.split(' ')[0] - - STDRR = UseGamma(OFF_STD,'read','final model fit std. dev. (samples) range:') - std_rg=STDRR.split(' ')[0] - - std_az = UseGamma2(OFF_STD,'read','final model fit std. dev. (samples) range:') - - STR = NM + ' ' + cor_rg + ' ' + cor_az + ' ' + std_rg + ' ' + std_az - call_str ='echo ' + STR + ' >> ' + STD_TXT - os.system(call_str) - - - sys.exit(1) - - -if __name__ == '__main__': - main(sys.argv[1:]) - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pyint/LATLON2SAR.py.bak b/pyint/LATLON2SAR.py.bak deleted file mode 100755 index 052aa09..0000000 --- a/pyint/LATLON2SAR.py.bak +++ /dev/null @@ -1,139 +0,0 @@ -#! /usr/bin/env python - -#''' -################################################################################## -### Author: Yun-Meng Cao ### -### Date : March, 2017 ### -### Email : ymcmrs@gmail.com ### -### Transform LAT/LON coordinates into SAR coordinates based on lookup table ### -################################################################################## -#''' - - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def read_data(inFile, dtype, nWidth, nLength): - data = np.fromfile(inFile, dtype, int(nLength)*int(nWidth)).reshape(int(nLength),int(nWidth)) - - return data - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Transform LAT/LON coordinates into SAR coordinates based on lookup table - - usage: - - LATLON2SAR.py Latitude Longitude LookupTableFile UTMDEMpar - - e.g. LATLON2SAR.py 0.324 -78.213 /Yunmeng/20201230.utm_to_rdc /Yunmeng/20201230.dem.utm.par - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==5: - LAT = sys.argv[1] - LON = sys.argv[2] - LtFile = sys.argv[3] - UTMPAR = sys.argv[4] - else: - usage();sys.exit(1) - - nWidthUTM = UseGamma(UTMPAR, 'read', 'width:') - nLineUTM = UseGamma(UTMPAR, 'read', 'nlines:') - - Corner_LAT = UseGamma(UTMPAR, 'read', 'corner_lat:') - Corner_LON = UseGamma(UTMPAR, 'read', 'corner_lon:') - - Corner_LAT =Corner_LAT.split(' ')[0] - Corner_LON =Corner_LON.split(' ')[0] - - post_Lat = UseGamma(UTMPAR, 'read', 'post_lat:') - post_Lon = UseGamma(UTMPAR, 'read', 'post_lon:') - - post_Lat =post_Lat.split(' ')[0] - post_Lon =post_Lon.split(' ')[0] - data = read_data(LtFile,'>c8',nWidthUTM,nLineUTM) # real: range imaginary: azimuth - - XX = int (( float(LAT) - float(Corner_LAT) ) / float(post_Lat)) # latitude width range - YY = int (( float(LON) - float(Corner_LON) ) / float(post_Lon)) # longitude nline azimuth - - CPX_OUT = data[XX][YY] - Range = int(CPX_OUT.real) - Azimuth = int(CPX_OUT.imag) - - print ' Latitude: ' + LAT + ' ' + 'Longitude: ' + LON - print ' Range: ' + str(Range) + ' ' + 'Azimuth: ' + str(Azimuth) -############################################################################## -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/pyint/MAI_SLC_Gamma.py.bak b/pyint/MAI_SLC_Gamma.py.bak deleted file mode 100755 index 0c39f54..0000000 --- a/pyint/MAI_SLC_Gamma.py.bak +++ /dev/null @@ -1,182 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################## -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Split beam of SLC: backward and forward SLC image generation # -# # -################################################################################## -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Split beam of original SLC to generate sub-aperture SLC: backward- and forward-SLCs - - usage: - - MAI_SLC_Gamma.py igramDir - - e.g. MAI_SLC_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - if INF!='MAI': - usage();sys.exit(1) - - if not os.path.isdir(workDir): - call_str="mkdir " + workDir - os.system(call_str) - - templateContents=read_template(templateFile) - coregCoarse = templateContents['Coreg_Coarse'] - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if 'Squint_MAI' in templateContents: Squint = templateContents['Squint_MAI'] - else: Squint = '0.5' -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - -# split slcs - - MFslcImg = workDir + "/" + Mdate + ".F.slc" - MFslcPar = workDir + "/" + Mdate + ".F.slc.par" - SFslcImg = workDir + "/" + Sdate + ".F.slc" - SFslcPar = workDir + "/" + Sdate + ".F.slc.par" - - MBslcImg = workDir + "/" + Mdate + ".B.slc" - MBslcPar = workDir + "/" + Mdate + ".B.slc.par" - SBslcImg = workDir + "/" + Sdate + ".B.slc" - SBslcPar = workDir + "/" + Sdate + ".B.slc.par" - - print MFslcImg + " "+ MslcImg - -# Multi-aperture processing - - call_str = '$GAMMA_BIN/sbi_filt '+ MslcImg + ' ' + MslcPar + ' '+SslcPar + ' ' + MFslcImg + ' '+ MFslcPar + ' ' + MBslcImg + ' ' + MBslcPar + ' ' + Squint - os.system(call_str) - print call_str - - call_str = '$GAMMA_BIN/sbi_filt '+ SslcImg + ' ' + SslcPar + ' '+MslcPar + ' ' + SFslcImg + ' '+ SFslcPar + ' ' + SBslcImg + ' ' + SBslcPar + ' ' + Squint - os.system(call_str) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - diff --git a/pyint/Makedem_PyINT.py.bak b/pyint/Makedem_PyINT.py.bak deleted file mode 100755 index 8a27494..0000000 --- a/pyint/Makedem_PyINT.py.bak +++ /dev/null @@ -1,174 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -######################################################################### - -INTRODUCTION = ''' -############################################################################################## - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Generate dem automatically for GAMMA processing. - -''' - -EXAMPLE = ''' - Usage: - Makedem_PyINT.py projectName processor - - Examples: - Makedem_PyINT.py ShanghaiT171F96S1A gamma - -################################################################################################### -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Generate dem automatically.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of the projection.') - parser.add_argument('processor',help='Name of the processor. [gamma or roi_pac]') - - inps = parser.parse_args() - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - processor = inps.processor - scratchDir = os.getenv('SCRATCHDIR') - slcDir = scratchDir + '/' + projectName + "/SLC" - KK=os.listdir(slcDir) - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - ListSLC = os.listdir(slcDir) - Datelist = [] - - - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - if 'masterDate' in templateContents: - masterDate0 = templateContents['masterDate'] - if masterDate0 in Datelist: - masterDate = masterDate0 - print "masterDate : " + masterDate0 - else: - masterDate=Datelist[0] - print "The selected masterDate is not included in above datelist !!" - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - else: - masterDate=Datelist[0] - print "masterDate is not found in template!!! " - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - SLC_PAR = slcDir + '/' + masterDate + '/'+ masterDate + '.slc.par' - - demDir = os.getenv('DEMDIR') - os.chdir(demDir) - call_str = 'mkdir ' + projectName - os.system(call_str) - - demDir2 = demDir + '/' + projectName - os.chdir(demDir2) - - call_str= 'makedem.py ' + '-s ' + SLC_PAR + ' -p ' + processor + ' -o ' + projectName - os.system(call_str) - - print 'Generate DEM for project %s is done.' % projectName - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pyint/NameChange.py.bak b/pyint/NameChange.py.bak deleted file mode 100755 index 1731719..0000000 --- a/pyint/NameChange.py.bak +++ /dev/null @@ -1,180 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : Mar, 2017 # -# # -# Select Interferometry-Pairs from time series SAR images # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def usage(): - print ''' -****************************************************************************************************** - - Select interferometry pairs from time series SAR images - - usage: - - SelectPairs_Gamma.py ProjectName - - e.g. SelectPairs_Gamma.py PacayaT163TsxHhA - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - - if 'JOB' in templateContents: JOB = templateContents['JOB'] - else: JOB = 'IFG' - - INF=JOB - if INF=='IFG': - Suffix=[''] - print "Time series interferograms will be processed!" - elif INF=='MAI': - Suffix=['.F','.B'] - print "Time series multi-aperture interferograms will be processed!" - elif INF=='RSI': - Suffix=['.HF','.LF'] - print "Time series range split-spectrum interferograms will be processed!" - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -# define files - - SLC_Tab = processDir + "/SLC_Tab" - TS_Berp = processDir + "/TS_Berp" - TS_Itab = processDir + "/TS_Itab" - itab_type = '1' - pltflg = '0' - - if 'Max_Spacial_Baseline' in templateContents: MaxSB=templateContents['Max_Spacial_Baseline'] - else: - print "Max_Spacial_Baseline is not found in template!! " - print "500m is chosen as the threshold for spatial baseline!" - MaxSB = '500' - - if 'Max_Temporal_Baseline' in templateContents: MaxTB=templateContents['Max_Temporal_Baseline'] - else: - print "Max_Temporal_Baseline is not found in template!! " - print "500 days is chosen as the threshold for temporal baseline!" - MaxTB = '500' - - -# extract available SAR images slc and slc_par - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - print "All of the available SAR acquisition datelist is :" - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - print ListSLC[kk] - DateDir = slcDir+'/'+ListSLC[kk] - SLC0 = glob.glob(DateDir+'/*slc')[0] - SLCPar0 = glob.glob(DateDir+'/*slc.par')[0] - - str_slc = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc" - str_slc_par = slcDir + "/" + ListSLC[kk] +"/" + ListSLC[kk] + ".slc.par" - - call_str = 'mv ' + SLC0 + ' ' + str_slc - os.system(call_str) - - call_str = 'mv ' + SLCPar0 + ' ' + str_slc_par - os.system(call_str) - - SLCfile.append(str_slc) - SLCParfile.append(str_slc_par) - - - print "Change name of SLC file is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - diff --git a/pyint/RSI_SLC_Gamma.py.bak b/pyint/RSI_SLC_Gamma.py.bak deleted file mode 100755 index f2dd96e..0000000 --- a/pyint/RSI_SLC_Gamma.py.bak +++ /dev/null @@ -1,216 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March , 2017 # -# # -# Range Split Spectrum for SAR complex data based on GAMMA # -# # -################################################################################### -#''' -import numpy as np -import os -import pysar._readfile as readfile -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Split Spectrum on range direction to generate high-frequency- and low-frequency- SLCs - - usage: - - RSI_SLC_Gamma.py igramDir - - e.g. RSI_SLC_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workdir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if INF!='RSI': - usage();sys.exit(1) - - if not os.path.isdir(workdir): - call_str = 'mkdir ' + workdir - os.system(call_str) - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - -# input slcs - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - - MHslcImg = workdir + '/'+Mdate + '.HF.slc' - MHslcPar = workdir + '/'+Mdate + '.HF.slc.par' - call_str = 'cp ' + MslcPar + ' '+ MHslcPar - os.system(call_str) - - SHslcImg = workdir + '/'+Sdate + '.HF.slc' - SHslcPar = workdir + '/'+Sdate + '.HF.slc.par' - call_str = 'cp ' + SslcPar + ' '+ SHslcPar - os.system(call_str) - - MLslcImg = workdir + '/'+Mdate + '.LF.slc' - MLslcPar = workdir + '/'+Mdate + '.LF.slc.par' - call_str = 'cp ' + MslcPar + ' '+ MLslcPar - os.system(call_str) - - SLslcImg = workdir + '/'+Sdate + '.LF.slc' - SLslcPar = workdir + '/'+Sdate + '.LF.slc.par' - call_str = 'cp ' + SslcPar + ' '+ SLslcPar - os.system(call_str) - - nWidth = UseGamma(MslcPar, 'read','range_samples:') - - call_str= 'bpf ' + MslcImg + ' ' + MHslcImg + ' ' + nWidth + ' 0.25 0.5 0 1 0 0 - - 1' - os.system(call_str) - - call_str= 'bpf ' + MslcImg + ' ' + MLslcImg + ' ' + nWidth + ' -0.25 0.5 0 1 0 0 - - 1' - os.system(call_str) - - nWidth = UseGamma(SslcPar, 'read','range_samples:') - - call_str= 'bpf ' + SslcImg + ' ' + SHslcImg + ' ' + nWidth + ' 0.25 0.5 0 1 0 0 - - 1' - os.system(call_str) - - call_str= 'bpf ' + SslcImg + ' ' + SLslcImg + ' ' + nWidth + ' -0.25 0.5 0 1 0 0 - - 1' - os.system(call_str) - - - print "Split spectrum for both slave and master date is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - - diff --git a/pyint/Resamp_all_Gamma.py.bak b/pyint/Resamp_all_Gamma.py.bak deleted file mode 100755 index 31e3543..0000000 --- a/pyint/Resamp_all_Gamma.py.bak +++ /dev/null @@ -1,270 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import re - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Coregistrate all SAR or interferograms to one master data - - usage: - - Resamp_all_Gamma.py igramDir - - e.g. Resamp_all_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Resamp_all_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Resamp_all_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - Moff = rslcDir +"/"+ masterDate + '-' + Mdate + '.off' - Soff = rslcDir +"/"+ masterDate + '-' + Sdate + '.off' - - if INF=='IFG' or INF =='IFGRAM': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) -# definition of intermediate and output file variables for slc images and parameters - - BaseslcDir = slcDir + "/" + masterDate - BaseslcImg = BaseslcDir + '/' + masterDate + '.slc' - BaseslcPar = BaseslcDir + '/' + masterDate + '.slc.par' - Baseslc4Par = workDir + '/' + masterDate + '.slc4.par' - - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - offs = workDir + "/offs" - snr = workDir + "/snr" - offsets = workDir + "/offsets" - coffs = workDir + "/coffs" - coffsets = workDir + "/coffsets" - - MrslcImg = rslcDir + "/" + Mdate + ".rslc" - MrslcPar = rslcDir + "/" + Mdate + ".rslc.par" - SrslcImg = rslcDir + "/" + Sdate + ".rslc" - SrslcPar = rslcDir + "/" + Sdate + ".rslc.par" - - MamprlksImg = rslcDir + "/" + Mdate + '_'+rlks+'rlks' + ".ramp" - MamprlksPar = rslcDir + "/" + Mdate + '_'+rlks+'rlks' + ".ramp.par" - - SamprlksImg = rslcDir + "/" + Sdate + '_'+rlks+'rlks' + ".ramp" - SamprlksPar = rslcDir + "/" + Sdate + '_'+rlks+'rlks' + ".ramp.par" - -############################################## Resampling ##################################################### - - for i in range(len(Suffix)): - if not INF=='IFG': - MslcImg = workDir + "/" + Mdate + Suffix[i]+".slc" - MslcPar = workDir + "/" + Mdate + Suffix[i]+".slc.par" - SslcImg = workDir + "/" + Sdate + Suffix[i]+".slc" - SslcPar = workDir + "/" + Sdate + Suffix[i]+".slc.par" - - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int.par' - - rINT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.rint' - rINTpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.rint.par' - - MrslcImg0 = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar0 = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - MrslcPar00 = workDir + "/" + Mdate + Suffix[i]+".rslc0.par" - - call_str = 'cp ' + MrslcPar0 + ' ' + MrslcPar00 - os.system(call_str) - - MrslcImg = rslcDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = rslcDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = rslcDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = rslcDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = rslcDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = rslcDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - SamprlksImg = rslcDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = rslcDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - -#### detect the choice for resampling ####### - - -### post coregistration for interferogram - - fin = open(BaseslcPar,"r") - fout = open(Baseslc4Par,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() - - fin = open(MrslcPar0,"r") - fout = open(INTpar,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() -################################################## - - call_str = 'cp ' + MamprlksImg + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + MamprlksPar + ' ' + workDir - os.system(call_str) - - call_str = 'cp ' + SamprlksImg + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + SamprlksPar + ' ' + workDir - os.system(call_str) - - call_str = 'cp ' + MrslcPar + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + SrslcPar + ' ' + workDir - os.system(call_str) - - call_str = 'cp ' + MrslcImg + ' ' + workDir - os.system(call_str) - call_str = 'cp ' + SrslcImg + ' ' + workDir - os.system(call_str) - - -####################################################### - - if ( masterDate != Mdate): - call_str = "$GAMMA_BIN/SLC_interp " + INT + " " + Baseslc4Par + " " + INTpar + " " + Moff + " " + rINT + " " + rINTpar - os.system(call_str) - os.rename(rINT, INT) - - - print "Coregistrate "+ igramDir +" to " + masterDate +" is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Resamp_all_Sen_Gamma.py.bak b/pyint/Resamp_all_Sen_Gamma.py.bak deleted file mode 100755 index 7e582fe..0000000 --- a/pyint/Resamp_all_Sen_Gamma.py.bak +++ /dev/null @@ -1,259 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import re - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Resampling all Sentinel-1 based intferograms into one master date coordinates. - - usage: - - Resamp_all_Sen_Gamma.py igramDir - - e.g. Resamp_all_Sen_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Resamp_all_Sen_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. Resamp_all_Sen_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - demDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - simDir = scratchDir + '/' + projectName + "/PROCESS/SIM" - - if not os.path.isdir(simDir): - call_str= 'mkdir ' + simDir - os.system(call_str) - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - M_off = rslcDir +'/' + Mdate + '/' + masterDate + '-' + Mdate + '.off' - M_lt = rslcDir +'/' + Mdate + '/' + masterDate + '-' + Mdate + '.lt ' - - -# definition of intermediate and output file variables for slc images and parameters - - BaseslcDir = rslcDir + "/" + masterDate - BaseslcImg = BaseslcDir + '/' + masterDate + '.slc' - BaseslcPar = BaseslcDir + '/' + masterDate + '.slc.par' - Baseslc4Par = workDir + '/' + masterDate + '.slc4.par' - - SslcDir = rslcDir + "/" + Sdate - MslcDir = rslcDir + "/" + Mdate - - MLI1PAR = rslcDir +'/' + masterDate + '/' + masterDate + '_' + rlks + 'rlks.amp.par' - MLI2PAR = rslcDir +'/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par' - - HGTSIM = demDir + '/sim_' + masterDate + '_' + rlks +'rlks' + '.rdc.dem' - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_' + rlks +'rlks' + '.sim_unw' - - - MrslcPar = MslcDir + "/" + Mdate + ".rslc.par" - SrslcPar = SslcDir + "/" + Sdate + ".rslc.par" - - MrslcPar0 = workDir + "/" + Mdate + ".rslc.par" - SrslcPar0 = workDir + "/" + Sdate + ".rslc.par" - MrslcImg0 = workDir + "/" + Mdate + ".rslc" - SrslcImg0 = workDir + "/" + Sdate + ".rslc" - - OFF = workDir + '/' + Mdate+ '-' + Sdate + '.roff' - OFFlks = workDir + '/' + Mdate+ '-' + Sdate + '_' + rlks + 'rlks.roff' - DIFFpar = workDir + '/' + Mdate+ '-' + Sdate + '.diff_par' - - int_off = workDir + '/off0' - INT = workDir + '/' + Mdate + '-' + Sdate + '.int' - INTpar = workDir + '/' + Mdate + '-' + Sdate + '.int.par' - rINT = workDir + '/' + Mdate + '-' + Sdate + '.rint' - rINTpar = workDir + '/' + Mdate + '-' + Sdate + '.rint.par' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - DIFFINTlks = workDir + '/' + Mdate + '_' + Sdate + '.diff' - DIFFFILTlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - - if os.path.isfile(OFFlks): - os.remove(OFFlks) - - if os.path.isfile(int_off): - os.remove(int_off) - - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - -############################################## Resampling ##################################################### - -#### detect the choice for resampling ####### - - -### post coregistration for interferogram - - fin = open(BaseslcPar,"r") - fout = open(Baseslc4Par,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() - - fin = open(MrslcPar0,"r") - fout = open(INTpar,"w") - txt = fin.read() - txtout = re.subn("SCOMPLEX","FCOMPLEX",txt)[0] - fout.write(txtout) - fin.close() - fout.close() - - if not Mdate==masterDate: - call_str = 'create_offset ' + MrslcPar0 + ' ' + MrslcPar0 + ' ' + int_off + ' 1 - - 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/SLC_intf ' + MrslcImg0 + ' ' + SrslcImg0 + ' ' + MrslcPar0 + ' ' + SrslcPar0 + ' ' + int_off + ' ' + INT + ' 1 1 - - - - - -' - os.system(call_str) - - call_str = "$GAMMA_BIN/SLC_interp_lt " + INT + " " + Baseslc4Par + " " + INTpar + " " + M_lt + " " + MLI1PAR + " " + MLI2PAR + " " + M_off + " " + rINT + " " + rINTpar - os.system(call_str) - os.rename(rINT, INT) - - if os.path.isfile(OFF): - os.remove(OFF) - call_str = 'create_offset ' + MrslcPar + ' ' + MrslcPar + ' ' + OFF + ' 1 - - 0' - os.system(call_str) - call_str = '$GAMMA_BIN/multi_cpx '+ INT + ' ' + OFF + ' ' + INTlks + ' ' + OFFlks + ' ' + rlks + ' ' + azlks - os.system(call_str) - - #call_str = 'create_offset ' + MrslcPar + ' ' + SrslcPar + ' ' + OFFlks + ' 1 ' + rlks + ' ' + azlks + ' 0' - #os.system(call_str) - - call_str = '$GAMMA_BIN/phase_sim_orb ' + MrslcPar + ' ' + SrslcPar + ' ' + OFFlks + ' ' + HGTSIM + ' ' + SIMUNW - os.system(call_str) - - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - call_str = '$GAMMA_BIN/create_diff_par ' + MLI1PAR + ' ' + MLI1PAR + ' ' + DIFFpar + ' 1 0 ' - os.system(call_str) - - call_str = '$GAMMA_BIN/sub_phase ' + INTlks + ' ' + SIMUNW + ' ' + DIFFpar + ' ' + DIFFINTlks + ' 1 0' - os.system(call_str) - - #os.remove(INT) - - #call_str = '$GAMMA_BIN/adapt_filt ' + DIFFINTlks + ' ' + DIFFINTFILTlks + ' ' + nWidth + ' ' + fFiltLengthDiff + ' ' + nFiltWindowDiff - #os.system(call_str) - - print "Coregistrate "+ igramDir +" to " + masterDate +" is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/SAR2LATLON.py.bak b/pyint/SAR2LATLON.py.bak deleted file mode 100755 index c470fee..0000000 --- a/pyint/SAR2LATLON.py.bak +++ /dev/null @@ -1,144 +0,0 @@ -#! /usr/bin/env python - -#''' -################################################################################## -### Author: Yun-Meng Cao ### -### Date : March, 2017 ### -### Email : ymcmrs@gmail.com ### -### Transform SAR coordinates into LAT/LON coordinates based on lookup table ### -################################################################################## -#''' - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def read_data(inFile, dtype, nWidth, nLength): - data = np.fromfile(inFile, dtype, int(nLength)*int(nWidth)).reshape(int(nLength),int(nWidth)) - - return data - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Transform SAR coordinates into LAT/LON coordinates based on lookup table - - usage: - - SAR2LATLON.py Range Azimuth LookupTableFile UTMDEMpar - - e.g. SAR2LATLON.py 1500 1000 /Yunmeng/20201230.utm_to_rdc /Yunmeng/20201230.dem.utm.par - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==5: - Range = sys.argv[1] - Azimuth = sys.argv[2] - LtFile = sys.argv[3] - UTMPAR = sys.argv[4] - else: - usage();sys.exit(1) - - nWidthUTM = UseGamma(UTMPAR, 'read', 'width:') - nLineUTM = UseGamma(UTMPAR, 'read', 'nlines:') - - Corner_LAT = UseGamma(UTMPAR, 'read', 'corner_lat:') - Corner_LON = UseGamma(UTMPAR, 'read', 'corner_lon:') - - Corner_LAT =Corner_LAT.split(' ')[0] - Corner_LON =Corner_LON.split(' ')[0] - - post_Lat = UseGamma(UTMPAR, 'read', 'post_lat:') - post_Lon = UseGamma(UTMPAR, 'read', 'post_lon:') - - post_Lat =post_Lat.split(' ')[0] - post_Lon =post_Lon.split(' ')[0] - data = read_data(LtFile,'>c8',nWidthUTM,nLineUTM) # real: range imaginary: azimuth - - Range_LT = data.real - Azimuth_LT = data.imag - - CPX_input =complex(Range + '+' + Azimuth+'j') - - DD = abs(CPX_input - data) - - LL= abs(DD) - IDX= np.where(LL == LL.min()) - Lat_out = float(Corner_LAT) + IDX[0]*float(post_Lat) - Lon_out = float(Corner_LON) + IDX[1]*float(post_Lon) - - print ' Range: ' + Range + ' ' + 'Azimuth: ' + Azimuth - print ' Latitude: ' + str(Lat_out[0]) + ' ' + 'Longitude: ' + str(Lon_out[0]) - -############################################################################## -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/pyint/SLC2Ifg.py.bak b/pyint/SLC2Ifg.py.bak deleted file mode 100755 index 467d395..0000000 --- a/pyint/SLC2Ifg.py.bak +++ /dev/null @@ -1,55 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2018, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - - - -def usage(): - print ''' -****************************************************************************************************** - - Coregistration of SAR images based on cross-correlation by using GAMMA. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. - - usage: - - SLC2Ifg.py IfgramDir - - e.g. SLC2Ifg.py IFG_MexicoCityT143F529S1D_20180506-20180518_034_048 - -******************************************************************************************************* - ''' - - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - projectName = igramDir.split('_')[1] - - if 'S1' in projectName: - call_str='SLC2Ifg_Sen_Gamma.py ' + ifgramDir - else: - call_str='SLC2Ifg_Gamma.py ' + ifgramDir - - os.system(call_str) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/SLC2Ifg_Gamma.py.bak b/pyint/SLC2Ifg_Gamma.py.bak deleted file mode 100755 index 1523a41..0000000 --- a/pyint/SLC2Ifg_Gamma.py.bak +++ /dev/null @@ -1,165 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def usage(): - print ''' -****************************************************************************************************** - - Generating interferograms from SLC : InSAR, MAI, Split-specrum Interferometry - - usage: - - SLC2Ifg_Gamma.py igramDir - - e.g. SLC2Ifg_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. SLC2Ifg_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. SLC2Ifg_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - projectName = igramDir.split('_')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - workDir = processDir + '/' + igramDir - - if not os.path.isdir(workDir): - call_str="mkdir "+ workDir - os.system(call_str) - - - if 'Coreg_int' in templateContents: Coreg_int = templateContents['Coreg_int'] - else: Coreg_int = '1' - - if 'INT_Flag' in templateContents: INT_Flag = templateContents['INT_Flag'] - else: INT_Flag = '1' - - if 'DIFF_Flag' in templateContents: DIFF_Flag = templateContents['DIFF_Flag'] - else: DIFF_Flag = '1' - - if 'UNW_Flag' in templateContents: UNW_Flag = templateContents['UNW_Flag'] - else: UNW_Flag = '1' - - if 'UNW_SUB_Flag' in templateContents: UNW_SUB_Flag = templateContents['UNW_SUB_Flag'] - else: UNW_SUB_Flag = '1' - - if 'GEO_Flag' in templateContents: GEO_Flag = templateContents['GEO_Flag'] - else: GEO_Flag = '1' - -############################################################## - - if 'coregMethod' in templateContents: coregMethod = templateContents['coregMethod'] - else: coregMethod = 'Init' - if 'unwrapMethod' in templateContents: unwrapMethod = templateContents['unwrapMethod'] - else: unwrapMethod = 'mcf' - - - if Coreg_int == '1' : - if coregMethod == "DEM": - call_str = "CoregistSLC_DEM_Gamma.py " + igramDir - os.system(call_str) - else: - call_str = "CoregistSLC_init_Gamma.py " + igramDir - os.system(call_str) - - if INT_Flag == '1' : - call_str = "GenIgram_Gamma.py " + igramDir - os.system(call_str) - - if DIFF_Flag == '1': - call_str = "SimPhase_Gamma.py " + igramDir - os.system(call_str) - call_str = "DiffPhase_Gamma.py " + igramDir - os.system(call_str) - - call_str = "GenerateRSC_Gamma.py " + igramDir - os.system(call_str) - - if UNW_Flag == '1': - if unwrapMethod =="mcf": - call_str = "UnwrapPhase_Gamma.py " + igramDir - os.system(call_str) - else: - call_str = "UnwrapPhase_BranchCut_Gamma.py " + igramDir - os.system(call_str) - - if GEO_Flag == '1': - call_str = "Geocode_Gamma.py " + igramDir - os.system(call_str) - - print "SLC to interferogram done!" - sys.exit(1) - - - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - diff --git a/pyint/SLC2Ifg_Sen_Gamma.py.bak b/pyint/SLC2Ifg_Sen_Gamma.py.bak deleted file mode 100755 index 231e619..0000000 --- a/pyint/SLC2Ifg_Sen_Gamma.py.bak +++ /dev/null @@ -1,165 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def usage(): - print ''' -****************************************************************************************************** - - Coregistration of SAR images based on cross-correlation by using GAMMA. - Be suitable for conventional InSAR, MAI, Range Split-Spectrum InSAR. - - usage: - - SLC2Ifg_Sen_Gamma.py igramDir - - e.g. SLC2Ifg_Sen_Gamma.py IFG_PacayaT163S1A_131021-131101_0011_0007 - e.g. SLC2Ifg_Sen_Gamma.py MAI_PacayaT163S1A_131021-131101_0011_0007 - e.g. SLC2Ifg_Sen_Gamma.py RSI_PacayaT163S1A_131021-131101_0011_0007 - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents =read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - masterDate = templateContents['masterDate'] - - if not os.path.isdir(workDir): - call_str = 'mkdir ' + workDir - os.system(call_str) -######################################################################## - - #call_str = 'Check_Common_Burst.py ' + igramDir - #os.system(call_str) - - #call_str = 'Extract_Common_Burst.py ' + igramDir - #os.system(call_str) - - #call_str = 'CreateRdcDem_Sen_Gamma.py ' + igramDir - #os.system(call_str) - - if 'DiffPhase' in templateContents: DiffPhase = templateContents['DiffPhase'] - else: DiffPhase = '1' - - if 'UnwrapPhase' in templateContents : UnwrapPhase = templateContents['UnwrapPhase'] - else: UnwrapPhase = '1' - - if 'GeoPhase' in templateContents : GeoPhase = templateContents['GeoPhase'] - else: GeoPhase = '1' - - if 'Resamp_All' in templateContents: Resamp_All = templateContents['Resamp_All'] - else: Resamp_All = '1' - - if DiffPhase == '1': - call_str = 'DiffPhase_Sen_Gamma.py ' + igramDir - os.system(call_str) - - call_str ='GenerateRSC_Sen_Gamma.py ' + igramDir - os.system(call_str) - - if Resamp_All =='1': - call_str = 'Resamp_all_Sen_Gamma.py ' + igramDir - os.system(call_str) - - if UnwrapPhase =='1': - call_str = 'UnwrapPhase_Sen_Gamma.py ' + igramDir - os.system(call_str) - - if GeoPhase =='1': - call_str = 'Geocode_Sen_Gamma.py ' + igramDir - os.system(call_str) - - print "Interferometry process for Sentinel-1 is done !" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/SelectPairs_Coherence.py.bak b/pyint/SelectPairs_Coherence.py.bak deleted file mode 100755 index 73b4a0a..0000000 --- a/pyint/SelectPairs_Coherence.py.bak +++ /dev/null @@ -1,149 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def usage(): - print ''' -****************************************************************************************************** - - Select interferometry pairs from time series SAR images - - usage: - - SelectPairs_Coherence.py projectName ifg_coherence.txt min_cor - - e.g. SelectPairs_Coherence.py projectName coherence_spatialAverage.txt 0.6 - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==4: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: - projectName = sys.argv[1] - TXT=sys.argv[2] - MC=sys.argv[3] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - processDir = scratchDir + '/' + projectName + "/PROCESS" - IFG_PAIRS = scratchDir + '/' + projectName + "/PROCESS/ifg_coherence_" + MC - RUN_IFG = scratchDir + '/' + projectName + "/PROCESS/run_slc2ifg_coherence_" + MC - - if os.path.isfile(IFG_PAIRS): - os.remove(IFG_PAIRS) - if os.path.isfile(RUN_IFG): - os.remove(RUN_IFG) - - IFGLIST = glob.glob(processDir+'/*_' +projectName + '_*') - LIST0=[] - for kk in IFGLIST: - SS = os.path.basename(kk) - L0 = SS.split('_')[2] - kk0 = SS.split(L0)[0]+ L0 - LIST0.append(kk0) - - if not os.path.isdir(processDir): - call_str='mkdir ' + processDir - os.system(call_str) - - B =[] - A = np.loadtxt(TXT,dtype=str) - for kk in range(len(A[:,0])): - CC = float(A[kk,1]) - if CC > float(MC): - ff = A[kk,0] - master = ff.split('-')[0] - slave = ff.split('-')[1] - slave = str(int(slave)) - if len(slave)==5: - slave = '0'+slave - SS = master + '-' + slave - call_str = 'echo ' + SS + ' >>' + IFG_PAIRS - os.system(call_str) - - STR = 'IFG' + '_' + projectName + '_' + master + '-' + slave + '_1000_1000' - STR0 = 'IFG' + '_' + projectName + '_' + master + '-' + slave - - if not STR0 in LIST0: - B.append(STR0) - call_str = 'echo SLC2Ifg_Gamma.py ' + STR + ' >>' + RUN_IFG - os.system(call_str) - - #call_str ='mkdir ' + processDir+'/' + STR - #os.system(call_str) - print 'Add interferogram directory ' + STR + ' \n' - print '%s interferograms are generated. ' % str(len(B)) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - diff --git a/pyint/SelectPairs_Gamma.py.bak b/pyint/SelectPairs_Gamma.py.bak deleted file mode 100755 index 5404e36..0000000 --- a/pyint/SelectPairs_Gamma.py.bak +++ /dev/null @@ -1,322 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -def usage(): - print ''' -****************************************************************************************************** - - Select interferometry pairs from time series SAR images - - usage: - - SelectPairs_Gamma.py ProjectName - - e.g. SelectPairs_Gamma.py PacayaT163TsxHhA - - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - - if 'JOB' in templateContents: JOB = templateContents['JOB'] - else: JOB = 'IFG' - - INF=JOB - if INF=='IFG': - Suffix=[''] - print "Time series interferograms will be processed!" - elif INF=='MAI': - Suffix=['.F','.B'] - print "Time series multi-aperture interferograms will be processed!" - elif INF=='RSI': - Suffix=['.HF','.LF'] - print "Time series range split-spectrum interferograms will be processed!" - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -# define files - - SLC_Tab = processDir + "/SLC_Tab" - TS_Berp = processDir + "/TS_Berp" - TS_Itab = processDir + "/TS_Itab" - itab_type = '1' - pltflg = '0' - - if 'Max_Spacial_Baseline' in templateContents: MaxSB=templateContents['Max_Spacial_Baseline'] - else: - print "Max_Spacial_Baseline is not found in template!! " - print "500m is chosen as the threshold for spatial baseline!" - MaxSB = '100' - - if 'Max_Temporal_Baseline' in templateContents: MaxTB=templateContents['Max_Temporal_Baseline'] - else: - print "Max_Temporal_Baseline is not found in template!! " - print "500 days is chosen as the threshold for temporal baseline!" - MaxTB = '100' - - -# extract available SAR images slc and slc_par - ListSLC = os.listdir(slcDir) - Datelist = [] - SLCfile = [] - SLCParfile = [] - - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - map(int,Datelist) - Datelist.sort() - map(str,Datelist) - - print "All of the available SAR acquisition datelist is :" - for kk in range(len(Datelist)): - print Datelist[kk] - str_slc = slcDir + "/" + Datelist[kk] +"/" + Datelist[kk] + ".slc" - str_slc_par = slcDir + "/" + Datelist[kk] +"/" + Datelist[kk] + ".slc.par" - SLCfile.append(str_slc) - SLCParfile.append(str_slc_par) - - if 'masterDate' in templateContents: - masterDate0 = templateContents['masterDate'] - if masterDate0 in Datelist: - masterDate = masterDate0 - print "masterDate : " + masterDate0 - else: - masterDate=Datelist[0] - print "The selected masterDate is not included in above datelist !!" - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - else: - masterDate=Datelist[0] - print "masterDate is not found in template!!! " - print "The first date [ %s ] is chosen as the master date! " % Datelist[0] - - RefPar=slcDir + "/" + masterDate +"/" + masterDate + ".slc.par" - - File= open(SLC_Tab,'w') - - for kk in range(len(SLCfile)): - File.write(str(SLCfile[kk])+ ' '+str(SLCParfile[kk])+'\n') - - File.close() - - call_str = "base_calc " + SLC_Tab + " " + RefPar + " " + TS_Berp + " " + TS_Itab + " " + '1 0 ' + '- ' + MaxSB + ' - ' + MaxTB - os.system(call_str) - - TS_Net=np.loadtxt(TS_Berp) - -# print TS_Net[:,0] -# print TS_Net[:,1] - IFG_Flag=TS_Net[:,0] - MDatelist=TS_Net[:,1] - SDatelist=TS_Net[:,2] - Berplist=TS_Net[:,3] - TBaselist=TS_Net[:,4] - -############################### Add or Remove Date ############################# - - if 'Add_Date' in templateContents: AD=templateContents['Add_Date'] - else: - AD ='' - - Addlist = [] - if len(AD)>0: - AD= AD.split('[')[1].split(']')[0] - if ',' in AD: - LL=AD.split(',') - for kk in range(len(LL)): - XX=LL[kk] - if is_number(XX): - if XX in Datelist: - Addlist.append(XX) - else: - print XX + ' is not in the SLC datelist! ' - else: - D1=XX.split(':')[0] - D2=XX.split(':')[1] - map(int,Datelist) - for dd in Datelist: - if (int(dd) > int(D1)) and (int(dd) < int(D2)) : - Addlist.append(dd) - else: - LL = AD - if is_number(LL): - if LL in Datelist: - Addlist.append(LL) - else: - print LL + ' is not in the SLC date list!' - - else: - D1=XX.split(':')[0] - D2=XX.split(':')[1] - map(int,Datelist) - for dd in Datelist: - if (int(dd) > int(D1)) and (int(dd) < int(D2)) : - Addlist.append(dd) - - Addlist=list(set(Addlist)) # remove possible repeat date - print Addlist -################################################################################### - - - if len(Addlist)>0: - igramDir=[] - run_slc2ifg_gamma = processDir + '/run_slc2ifg_gamma_add' - - if os.path.isfile(run_slc2ifg_gamma): - os.remove(run_slc2ifg_gamma) - - print "Start to create interferograms directory:" - - f_slc2ifg =open(run_slc2ifg_gamma,'w') - for kk in range(len(IFG_Flag)): - str_sb=str(int(abs(Berplist[kk]))) - str_sb=add_zero(str_sb) - str_tb=str(int(abs(TBaselist[kk]))) - str_tb=add_zero(str_tb) - - str_dir=processDir + "/"+ INF + '_' + projectName+"_"+str(int(MDatelist[kk]))[2:]+"-"+str(int(SDatelist[kk]))[2:]+"_"+str_sb+"_"+str_tb - - str_igram = INF + '_' + projectName+"_"+str(int(MDatelist[kk]))[2:]+"-"+str(int(SDatelist[kk]))[2:]+"_"+str_sb+"_"+str_tb - MD=str(int(MDatelist[kk])) - SD=str(int(SDatelist[kk])) - if ((str(MD[2:]) in Addlist) or (str(SD[2:]) in Addlist)): - igramDir.append(str_dir) - print 'Add igramDir: ' + str_igram - str_scrip = 'SLC2Ifg_Gamma.py ' + str_igram + '\n' - f_slc2ifg.write(str_scrip) - #if not os.path.isdir(str_dir): - # call_str="mkdir " + str_dir - # os.system(call_str) - f_slc2ifg.close() - - -########################### Prepare Process directory ############################# - else: - igramDir=[] - run_slc2ifg_gamma = processDir + '/run_slc2ifg_gamma' - - if os.path.isfile(run_slc2ifg_gamma): - os.remove(run_slc2ifg_gamma) - - - f_slc2ifg =open(run_slc2ifg_gamma,'w') - for kk in range(len(IFG_Flag)): - str_sb=str(int(abs(Berplist[kk]))) - str_sb=add_zero(str_sb) - str_tb=str(int(abs(TBaselist[kk]))) - str_tb=add_zero(str_tb) - - str_dir=processDir + "/"+ INF + '_' + projectName+"_"+str(int(MDatelist[kk]))[2:]+"-"+str(int(SDatelist[kk]))[2:]+"_"+str_sb+"_"+str_tb - igramDir.append(str_dir) - - str_igram = INF + '_' + projectName+"_"+str(int(MDatelist[kk]))[2:]+"-"+str(int(SDatelist[kk]))[2:]+"_"+str_sb+"_"+str_tb - str_scrip = 'SLC2Ifg_Gamma.py ' + str_igram + '\n' - if 'S1' in projectName: - str_scrip = 'SLC2Ifg_Sen_Gamma.py ' + str_igram + '\n' - - - f_slc2ifg.write(str_scrip) - STR_FLAG = INF + '_' + projectName+"_"+str(int(MDatelist[kk]))[2:]+"-"+str(int(SDatelist[kk]))[2:] - KK= glob.glob(processDir + '/' + STR_FLAG + '*') - print len(KK) - if len(KK)< 1: - call_str="mkdir " + str_dir - os.system(call_str) - print 'Add IFG >>> ' + str_dir - f_slc2ifg.close() - - print "Selection of interferometric pairs is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - diff --git a/pyint/Sen_Orbit_Cor.py.bak b/pyint/Sen_Orbit_Cor.py.bak deleted file mode 100755 index 5776d8b..0000000 --- a/pyint/Sen_Orbit_Cor.py.bak +++ /dev/null @@ -1,146 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def StrNum(S): - S = str(S) - if len(S)==1: - S='0' +S - return S - - -######################################################################### - -INTRODUCTION = ''' -############################################################################################## - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Download and update the orbit data of Sentinel-1A/B slc par files based on the AUX_POEORB data. - See also: Sen_PreOrbit.py, Update_Orbit_Sen.py - -''' - -EXAMPLE = ''' - Usage: - Sen_Orbit_Cor.py projectName Date - - Examples: - Sen_Orbit_Cor.py projectName Date - -################################################################################################### -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Download and update orbit date for Sentinel-1 data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of the projection.') - parser.add_argument('date',help='SAR acquisition date.') - - inps = parser.parse_args() - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - DATE = inps.date - scratchDir = os.getenv('SCRATCHDIR') - slcDir = scratchDir + '/' + projectName + "/SLC" - - if len(DATE)==8: - DATE = DATE[2:9] - - SLCPATH = slcDir + '/' + DATE - - KK=os.listdir(SLCPATH) - SLC_PAR = [] - for ll in KK: - if 'slc.par' in ll: - SLC_PAR.append(ll) - os.chdir(SLCPATH) - FF = SLC_PAR[0] - - SENSOR = UseGamma(FF, 'read', 'sensor:') - - if 'S1A' in SENSOR: - SAT = 'A' - else: - SAT = 'B' - - print 'SAR image is acquired by Sentinel-1%s.' % SAT - - call_str = 'Sen_PreOrbit.py ' + DATE + ' ' + SAT - os.system(call_str) - - call_str = 'Update_Orbit_Sen.py ' + SLCPATH - os.system(call_str) - - - print 'Download and update the precise orbit date for Sentinel-1%s data %s is finished.' % (SAT,DATE) - - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pyint/Sen_Orbit_Cor_all.py.bak b/pyint/Sen_Orbit_Cor_all.py.bak deleted file mode 100755 index ffad140..0000000 --- a/pyint/Sen_Orbit_Cor_all.py.bak +++ /dev/null @@ -1,135 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def StrNum(S): - S = str(S) - if len(S)==1: - S='0' +S - return S - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -######################################################################### - -INTRODUCTION = ''' -############################################################################################## - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Download and update the orbit data of Sentinel-1A/B slc par files for the whole project based on the AUX_POEORB data. - See also: Sen_PreOrbit.py, Update_Orbit_Sen.py and Sen_Orbit_Cor.py. - -''' - -EXAMPLE = ''' - Usage: - Sen_Orbit_Cor_all.py projectName - - Examples: - Sen_Orbit_Cor_all.py projectName - -################################################################################################### -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Correct orbit data for all of the Sentinel-1 data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of the projection.') - - inps = parser.parse_args() - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - slcDir = scratchDir + '/' + projectName + "/SLC" - SAR = os.listdir(slcDir) - if os.path.isfile('run_Sen_OrbCor'): - call_str = 'rm run_Sen_OrbCor' - os.system(call_str) - - for kk in SAR: - if is_number(kk): - call_str ='echo Sen_Orbit_Cor.py ' + projectName + ' ' + kk + ' >> run_Sen_OrbCor' - os.system(call_str) - - call_str = 'rm job*' - os.system(call_str) - - call_str = 'rm z_out*' - os.system(call_str) - - - call_str = '$INT_SCR/createBatch.pl run_Sen_OrbCor memory=3700 walltime=0:10' - os.system(call_str) - - - print 'Correct the orbit for project %s is done.' % projectName - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pyint/Sen_PreOrbit.py.bak b/pyint/Sen_PreOrbit.py.bak deleted file mode 100755 index c62f1be..0000000 --- a/pyint/Sen_PreOrbit.py.bak +++ /dev/null @@ -1,162 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse -import linecache - -def StrNum(S): - S = str(S) - if len(S)==1: - S='0' +S - return S - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Download precise sentinel orbit data (AUX_POEORB)automatically. - refered website: https://qc.sentinel1.eo.esa.int/aux_poeorb/ - -''' - -EXAMPLE = ''' - Usage: - Sen_PreOrbit.py Date Satellite (A or B) - - Examples: - Sen_PreOrbit.py 20160101 A - -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Download precise S1 orbit data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('date',help='SAR date that need precise orbital data.') - parser.add_argument('satellite',help='satellite type: A (Sentinel-1A) or B(Sentinel-1B).') - - inps = parser.parse_args() - return inps - -################################################################################ - - -def main(argv): - - total = time.time() - inps = cmdLineParse() - - DATE = inps.date - - if len(DATE)==6: - DATE = '20' + DATE - ST = inps.satellite - YEAR = int(DATE[0:4]) - MON = int(DATE[4:6]) - DAY = int(DATE[6:8]) - - MON_DAY = [31,28,31,30,31,30,31,31,30,31,30,31] - - if YEAR%4==0: - MON_DAY[1]=29 - - if MON ==1 and DAY ==1: - DAY0 = 31 - MON0 = 12 - YEAR0 =YEAR -1 - elif MON!=1 and DAY ==1: - DAY0 = MON_DAY[MON-2] - MON0 = MON-1 - YEAR0 = YEAR - else: - DAY0 = DAY -1 - MON0 = MON - YEAR0 = YEAR - - MONDAY0 = MON_DAY[MON0-1] - - TT = [1,4,7,10,13,16,19,22,25,28,MONDAY0] - - T0 = [] - for k in range(len(TT)): - T0.append(TT[k]) - TT[k] = TT[k]-DAY0 - - for k in range(len(TT)): - if k == len(TT)-1: - if TT[k]==0: - ff = k-1 - else: - if TT[k]<=0 and TT[k+1]>0: - ff = k - - - DAY1 = T0[ff] - DAY2 = T0[ff+1] - - S1 = StrNum(YEAR0) + '-' + StrNum(MON0) - S2 = StrNum(YEAR0) + '-' + StrNum(MON0) + '-' + StrNum(DAY1) - S3 = StrNum(YEAR0) + '-' + StrNum(MON0) + '-' + StrNum(DAY2) - S4 = StrNum(YEAR0) + '-' + StrNum(MON0) + '-' + StrNum(DAY0) - - #SS = 'https://qc.sentinel1.eo.esa.int/aux_poeorb/?mission=S1' + ST + '&validity_start_time=' + StrNum(YEAR0) + '&validity_start_time=' + S1 + '&validity_start_time=' + S2 + '..' + S3 + '&validity_start_time=' + S4 - SS = 'https://qc.sentinel1.eo.esa.int/aux_poeorb/?validity_start=' + StrNum(YEAR0) + '&validity_start=' + S1 + '&validity_start=' + S2 + '..' + S3 + '&validity_start=' +S4 + '&sentinel1__mission=S1'+ST+ '&sentinel1_mission=S1'+ST+ '&sentinel1_mission=S1'+ST+ '&sentinel1_mission=S1'+ST - - - SS = "'" + SS + "'" - print SS - call_str = 'curl ' + SS + ' >tt' - os.system(call_str) - - call_str = "grep 'EOF' -C 0 tt >t0" - os.system(call_str) - - - call_str="awk -F'href=' '{print $2}' t0 >t00" - os.system(call_str) - - call_str= "awk -F'>' '{print $1}' t00 > t0" - os.system(call_str) - - SS=linecache.getline('t0', 1) - print SS - - call_str = 'wget -q --no-check-certificate ' + SS - os.system(call_str) - - - print "Download precise orbital data for %s is done." % DATE - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - diff --git a/pyint/SimPhase_Gamma.py.bak b/pyint/SimPhase_Gamma.py.bak deleted file mode 100755 index 2f5b8b0..0000000 --- a/pyint/SimPhase_Gamma.py.bak +++ /dev/null @@ -1,211 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Simulating Topography phase and flattening phase based on radar-coordinates' DEM - - usage: - - SimPhase_Gamma.py igramDir - - e.g. SimPhase_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. SimPhase_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_-0007 - e.g. SimPhase_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_-0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - os.system(call_str) - - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - if not os.path.isdir(simDir): - call_str='mkdir ' + simDir - os.system(call_str) - - demDir = scratchDir + '/' + projectName + "/PROCESS" + "/DEM" - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - -# Definition of file - SslcDir = slcDir + "/" + Sdate - MslcDir = slcDir + "/" + Mdate - - MslcImg = MslcDir + "/" + Mdate + ".slc" - MslcPar = MslcDir + "/" + Mdate + ".slc.par" - SslcImg = SslcDir + "/" + Sdate + ".slc" - SslcPar = SslcDir + "/" + Sdate + ".slc.par" - - MrslcImg = workDir + "/" + Mdate + ".rslc" - MrslcPar = workDir + "/" + Mdate + ".rslc.par" - SrslcImg = workDir + "/" + Sdate + ".rslc" - SrslcPar = workDir + "/" + Sdate + ".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks' + ".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks' + ".ramp.par" - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.off' - - #if 'masterDate' in templateContents: - # masterDate = templateContents['masterDate'] - # HGTSIM = demDir + '/sim_' + masterDate + '_' + rlks +'rlks' + '.rdc.dem' - # if not os.path.isfile(HGTSIM): - # HGTSIM = demDir + '/sim_' + Mdate + '_' + rlks +'rlks' + '.rdc.dem' - #else: - # HGTSIM = demDir + '/sim_' + Mdate + '_' + rlks +'rlks' + '.rdc.dem' - - #if not os.path.isfile(HGTSIM): - # call_str = 'Generate_RdcDEM_Gamma.py ' + projectName + ' ' + Mdate - # os.system(call_str) - - HGTSIM = demDir + '/sim_' + Mdate + '_' + rlks +'rlks' + '.rdc.dem' - if not os.path.isfile(HGTSIM): - call_str = 'Generate_RdcDEM_Rslc_Gamma.py ' + projectName + ' ' + Mdate - os.system(call_str) - - SIMUNW = simDir + '/sim_' + Mdate + '-' + Sdate + '_' + rlks +'rlks' + '.sim_unw' - - -################################### Phase Simulation ########################################### - - if os.path.isfile(OFFlks): - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - else: - nWidth = UseGamma(MamprlksPar, 'read', 'range_samples:') - - if 'Igram_Flag_TDM' in templateContents: flagTDM = templateContents['Igram_Flag_TDM'] - else: flagTDM = 'N' - - if flagTDM == 'N': - call_str = '$GAMMA_BIN/phase_sim_orb ' + MrslcPar + ' ' + SrslcPar + ' ' + OFFlks + ' ' + HGTSIM + ' ' + SIMUNW - else: - call_str = '$GAMMA_BIN/phase_sim_orb ' + MrslcPar + ' ' + SrslcPar + ' ' + OFFlks + ' ' + HGTSIM + ' ' + SIMUNW + ' - - - 0' - os.system(call_str) - - - print "Simulation interferometric phas with DEM is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UTM2SARPIX.py.bak b/pyint/UTM2SARPIX.py.bak deleted file mode 100755 index 3e2d27b..0000000 --- a/pyint/UTM2SARPIX.py.bak +++ /dev/null @@ -1,128 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Transform lat and lon to SAR coordinates based on SLCPar and DEM # -# # -################################################################################### -#''' - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Transform lat and lon to SAR coordinates based on SLCPar and DEM - - usage: - - UTM2SARPIX.py latitude longitude SLCPar DEM - - e.g. UTM2SARPIX.py 31.1 -108.2 /Yunmeng/2010.slc.par /Yunmeng/2010.dem - -******************************************************************************************************* - ''' - - -def main(argv): - - if len(sys.argv)==5: - LAT = sys.argv[1] - LON = sys.argv[2] - PAR = sys.argv[3] - DEM = sys.argv[4] - else: - usage();sys.exit(1) - - DEMpar = DEM + '.par' - - DateFormat = UseGamma(DEMpar, 'read', 'data_format:') - - nWidth = UseGamma(DEMpar, 'read', 'width:') - nLength = UseGamma(DEMpar, 'read', 'nlines:') - - Corner_LAT = UseGamma(DEMpar, 'read', 'corner_lat:') - Corner_LON = UseGamma(DEMpar, 'read', 'corner_lon:') - - Corner_LAT =Corner_LAT.split(' ')[0] - Corner_LON =Corner_LON.split(' ')[0] - - post_Lat = UseGamma(DEMpar, 'read', 'post_lat:') - post_Lon = UseGamma(DEMpar, 'read', 'post_lon:') - - post_Lat =post_Lat.split(' ')[0] - post_Lon =post_Lon.split(' ')[0] - - if DateFormat =='INTEGER*2': - STR = '>i2' - else: - STR = '>f4' - - TXT = 'SARCOORD' - - DEMdate = np.fromfile(DEM,STR,int(nLength)*int(nWidth)).reshape(int(nLength),int(nWidth)) - - LAT = float(LAT); LON =float(LON) - nWidth=int(nWidth);nLength=int(nLength) - Corner_LAT = float(Corner_LAT); Corner_LON=float(Corner_LON) - post_Lat = float(post_Lat); post_Lon=float(post_Lon) - - XX = int (( LAT - Corner_LAT ) / post_Lat) # latitude width range - YY = int (( LON - Corner_LON ) / post_Lon) # longitude nline azimuth - - - ELEV = DEMdate[XX][YY] - - call_str = 'coord_to_sarpix ' + PAR + ' - - ' + str(LAT) + ' ' + str(LON) + ' ' + str(ELEV) + ' >' +TXT - os.system(call_str) - - call_str = 'cat ' + TXT - os.system(call_str) - - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - diff --git a/pyint/Untitled.ipynb b/pyint/Untitled.ipynb deleted file mode 100755 index c726431..0000000 --- a/pyint/Untitled.ipynb +++ /dev/null @@ -1,59 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 Down2SLC_Sen_Gamma.py JeddahT14F65S1A 190507\n", - "Down2SLC_Sen_Gamma.py JeddahT14F65S1A 190507 >/dev/null\n", - "1 Down2SLC_Sen_Gamma.py JeddahT14F65S1A 190519\n", - "Down2SLC_Sen_Gamma.py JeddahT14F65S1A 190519 >/dev/null\n" - ] - } - ], - "source": [ - "#with open('run_down2slc_sen') as f:\n", - "# for line in f:\n", - "# print(line)\n", - " \n", - "f=open('/home/caoy0a/Documents/SCRATCH/JeddahT14F65S1A/DOWNLOAD/run_down2slc_sen','r')\n", - "ll = f.read().splitlines() \n", - "f.close()\n", - "\n", - "N = len(ll)\n", - "\n", - "for i in range(0,N):\n", - " ss = str(i)+ ' ' + ll[i]\n", - " print(ss)\n", - " str_call = ll[i] + ' >/dev/null'\n", - " print(str_call)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pyint/UnwrapGEO_Sen_Gamma.py.bak b/pyint/UnwrapGEO_Sen_Gamma.py.bak deleted file mode 100755 index 217f46c..0000000 --- a/pyint/UnwrapGEO_Sen_Gamma.py.bak +++ /dev/null @@ -1,271 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Unwrap and Geocoding for Sentinel-1 # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Generating the differential interferograms for Sentinel-1A/B - - usage: - - DiffPhase_Sen_Gamma.py igramDir - - e.g. DiffPhase_Sen_Gamma.py IFG_PacayaT163S1A_131021-131101_0011_-0007 - e.g. DiffPhase_Sen_Gamma.py MAI_PacayaT163S1A_131021-131101_0011_-0007 - e.g. DiffPhase_Sen_Gamma.py RSI_PacayaT163S1A_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if 'Igram_Cor_Rwin' in templateContents: rWinCor = templateContents['Igram_Cor_Rwin'] - else: rWinCor = '5' - if 'Igram_Cor_Awin' in templateContents: aWinCor = templateContents['Igram_Cor_Awin'] - else: aWinCor = '5' - - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - - if 'UnwrappedThreshold' in templateContents: unwrappedThreshold = templateContents['UnwrappedThreshold'] - else: unwrappedThreshold = '0.3' - if 'Unwrap_patr' in templateContents: unwrappatrDiff = templateContents['Unwrap_patr'] - else: unwrappatrDiff = '1' - if 'Unwrap_pataz' in templateContents: unwrappatazDiff = templateContents['Unwrap_pataz'] - else: unwrappatazDiff = '1' - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: SW = '1' - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: EW = '3' - if 'Start_Burst' in templateContents: SB = templateContents['Start_Burst'] - else: SB = '1' - -# Definition of file - MslcDir = slcDir + '/' + Mdate - SslcDir = slcDir + '/' + Sdate - - MslcTOP1 = MslcDir + '/' + Mdate + '.IW1.slc.TOPS_par' # bursts number in all of TOPS are same ? If not, should modify - SslcTOP1 = SslcDir + '/' + Sdate + '.IW1.slc.TOPS_par' - - NB_master = UseGamma(MslcTOP1 , 'read', 'number_of_bursts:') - NB_slave = UseGamma(SslcTOP1 , 'read', 'number_of_bursts:') - - if 'End_Burst' in templateContents: EB = templateContents['End_Burst'] - else: EB = str(min(int(NB_master),int(NB_slave))) # using the minmun number as the end of the burst number - - MSLC_tab = MslcDir + '/SLC_Tab2_' + SW + EW + '_' + SB + EB - SSLC_tab = SslcDir + '/SLC_Tab2_' + SW + EW + '_' + SB + EB - - MamprlksImg = MslcDir + '/' + Mdate + '.' + SW + EW + '_' + SB + EB +'_'+rlks +'rlks.amp' - MamprlksPar = MslcDir + '/' + Mdate + '.' + SW + EW + '_' + SB + EB +'_'+rlks +'rlks.amp.par' - - SamprlksImg = SslcDir + '/' + Sdate + '.' + SW + EW + '_' + SB + EB +'_'+rlks +'rlks.amp' - SamprlksPar = SslcDir + '/' + Sdate + '.' + SW + EW + '_' + SB + EB +'_'+rlks +'rlks.amp.par' - - - RSLC_tab = workDir + '/RSLC_tab' + SW + EW + '_' + SB + EB - DIFF0 = workDir + '/' + Mdate + '_' + Sdate +'.diff' - DIFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.diff' - DIFFFILTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.filt.diff' - UNWlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.unw' - UNWINTERPlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.unw_interp' - DIFFpar = workDir + '/' + Mdate + '-' + Sdate +'.diff_par' - QUADFIT = workDir + '/' + Mdate + '-' + Sdate +'.quad_fit' - - CORDIFFFILTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.filt_diff.cor' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - call_str = 'cp ' + DIFF0 + ' ' + DIFFlks - os.system(call_str) - - ###################### Filtering #################### - - if 'Diff_FilterStrength' in templateContents: - strFilterStrengeh = templateContents['Diff_FilterStrength'] - fFiltLengthDiff = strFilterStrengeh.split('/')[0] - nFiltWindowDiff = strFilterStrengeh.split('/')[1] - else: - fFiltLengthDiff = '-' - nFiltWindowDiff='-' - - nWidth = UseGamma( MamprlksPar, 'read', 'range_samples:') - nLine = UseGamma(MamprlksPar, 'read', 'azimuth_lines:') - - nCenterWidth = str(int(nWidth) / 2) - nCenterLine = str(int(nLine) / 2) - - if 'Ref_Range' in templateContents: Ref_Range = templateContents['Ref_Range'] - else: Ref_Range = nCenterWidth - if 'Ref_Azimuth' in templateContents: Ref_Azimuth = templateContents['Ref_Azimuth'] - else: Ref_Azimuth = nCenterLine - - - call_str = '$GAMMA_BIN/adapt_filt ' + DIFFlks + ' ' + DIFFFILTlks + ' ' + nWidth + ' ' + fFiltLengthDiff + ' ' + nFiltWindowDiff - os.system(call_str) - -#################### Unwrap ########################## - - call_str= '$GAMMA_BIN/cc_wave ' + DIFFFILTlks + ' ' + MamprlksImg + ' ' + SamprlksImg + ' ' + CORDIFFFILTlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc ' + CORDIFFFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(CORDIFFFILTlks, CORDIFFFILTlks) - - - CORDIFFFILTlksbmp = CORDIFFFILTlks + '_mask.bmp' - call_str = '$GAMMA_BIN/rascc_mask ' + CORDIFFFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' 1 1 0 1 1 ' + unwrappedThreshold + ' 0.0 0.1 0.9 1. .35 1 ' + CORDIFFFILTlksbmp # based on diff coherence - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc_mask_thinning ' + CORDIFFFILTlksbmp + ' ' + CORDIFFFILTlks + ' ' + nWidth + ' ' + MASKTHINDIFFlks + ' 5 0.3 0.4 0.5 0.6 0.7' - os.system(call_str) - - call_str = '$GAMMA_BIN/mcf ' + DIFFFILTlks + ' ' + CORDIFFFILTlks + ' ' + MASKTHINDIFFlks + ' ' + UNWlks + ' ' + nWidth + ' 1 0 0 - - ' + unwrappatrDiff + ' ' + unwrappatazDiff + ' - ' + Ref_Range + ' ' + Ref_Azimuth #choose the reference point center - os.system(call_str) - - call_str = '$GAMMA_BIN/interp_ad ' + UNWlks + ' ' + UNWINTERPlks + ' ' + nWidth - os.system(call_str) - - call_str = '$GAMMA_BIN/unw_model ' + DIFFFILTlks + ' ' + UNWINTERPlks + ' ' + UNWlks + ' ' + nWidth - os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + UNWlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(UNWlks, UNWlks) - - if flatteningUnwrap == 'Y': - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - OUTUNWQUAD = UNWlks.replace('.unw','.quad_fit.unw') - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + DIFFpar + ' 1 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_fit ' + UNWlks + ' ' + DIFFpar + ' 32 32 ' + CORDIFFFILTlks + '_mask.bmp ' + QUADFIT + ' 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_sub ' + UNWlks + ' ' + DIFFpar + ' ' + OUTUNWQUAD + ' 1 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + OUTUNWQUAD + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(OUTUNWQUAD, OUTUNWQUAD) - - - print "Unwrapping for S1 interferogram is done !" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UnwrapPhase_BranchCut_Gamma.py.bak b/pyint/UnwrapPhase_BranchCut_Gamma.py.bak deleted file mode 100755 index 47daed1..0000000 --- a/pyint/UnwrapPhase_BranchCut_Gamma.py.bak +++ /dev/null @@ -1,341 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Unwrap interferograms based on Branch-Cut Method # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if ( inFile.rsplit('.')[1] == 'int' or inFile.rsplit('.')[1] == 'diff'): - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - -def GetSubset(Subset): - KK = Subset.split('[')[1].split(']')[0] - if ':' in KK: - Dx = Subset.split('[')[1].split(']')[0].split(',')[0] - Dy = Subset.split('[')[1].split(']')[0].split(',')[1] - - x1 = Dx.split(':')[0] - x2 = Dx.split(':')[1] - - y1 = Dy.split(':')[0] - y2 = Dy.split(':')[1] - else: - x1 = '-' - x2 = '-' - y1 = '-' - y2 = '-' - - return x1,x2,y1,y2 - -def usage(): - print ''' -****************************************************************************************************** - - Unwrap interferograms based on Branch-cut method. - - - usage: - - UnwrapPhase_BranchCut_Gamma.py igramDir - - e.g. UnwrapPhase_BranchCut_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_BranchCut_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_BranchCut_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Topo_Flag' in templateContents: flagTopo = templateContents['Topo_Flag'] - else: flagTopo = 'N' - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - if 'UnwrappedThreshold' in templateContents: unwrappedThreshold = templateContents['UnwrappedThreshold'] - else: unwrappedThreshold = '0.3' - if 'Unwrap_patr' in templateContents: unwrappatrDiff = templateContents['Unwrap_patr'] - else: unwrappatrDiff = '1' - if 'Unwrap_pataz' in templateContents: unwrappatazDiff = templateContents['Unwrap_pataz'] - else: unwrappatazDiff = '1' - - if 'branch_length' in templateContents: mbl = templateContents['branch_length'] - else: mbl = '32' - - - -# Definition of file - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' - - DIFFpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.diff.par' - UNWFLAGlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.unw_flag' - - DIFFINTlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - DIFFINTFFTlks = DIFFINTlks.replace('diff_', 'diff_sim_') - - CORDIFFlks = workDir+'/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORDIFFFILTlks = workDir+'/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - MASKTHINlks = CORFILTlks + 'maskt.bmp' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - nLine = UseGamma(OFFlks, 'read', 'interferogram_azimuth_lines') - - nCenterWidth = str(int(nWidth) / 2) - nCenterLine = str(int(nLine) / 2) - - if 'Ref_Range' in templateContents: Ref_Range = templateContents['Ref_Range'] - else: Ref_Range = nCenterWidth - if 'Ref_Azimuth' in templateContents: Ref_Azimuth = templateContents['Ref_Azimuth'] - else: Ref_Azimuth = nCenterLine #### unwrapping differential interferogram #### -### if topo case, it calls FLTFILTlks -### else if diff case, it calls DIFFINTFILTlks - - if flagTopo == 'Y': - if flatteningIgram == 'orbit': - FLTFILTlks = FLTlks.replace('flat_', 'filt_') - else : - FLTFILTlks = FLTFFTlks.replace('flat_', 'filt_') - WRAPlks = FLTFILTlks - MASKTHIN = MASKTHINlks - CORMASK = CORFILTlks - else: - if flatteningDiff == 'orbit': - DIFFINTFILTlks = DIFFINTlks.replace('diff_', 'diff_filt_') - else: - DIFFINTFILTlks = DIFFINTFFTlks.replace('diff_', 'diff_filt_') - WRAPlks = DIFFINTFILTlks - MASKTHIN = MASKTHINDIFFlks - CORMASK = CORDIFFFILTlks - - UWNTHINlks = WRAPlks.replace('.int', '.unw_thinned.bmp') - UNWINTERPlks = WRAPlks.replace('.int', '.unw_interp') - UNWlks = WRAPlks.replace('.int', '.branch.unw') - - -######################################################### - if 'Subset_Rdc' in templateContents: - Subset = templateContents['Subset_Rdc'] - XX = GetSubset(Subset) - if not XX[3] == '-': - SRU = XX[0] - NR = str(int(XX[1])-int(XX[0])) - ERL = str(int(NR) + int(SRU)) - SAU= XX[2] - NA = str(int(XX[3])-int(XX[2])) - EAL = str(int(NA) + int(SAU)) - else: - SRU = '-' - NR = '-' - SAU = '-' - NA = '-' - ERL = '-' - EAL = '-' - else: - SRU = '-' - NR = '-' - SAU = '-' - NA = '-' - ERL = '-' - EAL = '-' - - if os.path.isfile(UNWlks): - os.remove(UNWlks) - - if os.path.isfile(UNWFLAGlks): - os.remove(UNWFLAGlks) - - if NR == '-': - ERL = '-' - else: - ERL = str(int(NR) + int(SRU)) - - if NA == '-': - EAL = '-' - else: - EAL = str(int(NA) + int(SAU)) - - - CORFILTlksbmp = CORFILTlks + '_mask.bmp' - - call_str = '$GAMMA_BIN/corr_flag ' + CORDIFFlks + ' ' + UNWFLAGlks + ' ' + nWidth + ' ' + unwrappedThreshold + ' ' + SRU + ' ' + ERL + ' ' + SAU + ' ' + EAL - os.system(call_str) - - call_str = '$GAMMA_BIN/residue_cc ' + DIFFINTFILTlks + ' ' + UNWFLAGlks + ' ' + nWidth + ' ' + SRU + ' ' + ERL + ' ' + SAU + ' ' + EAL - os.system(call_str) - - call_str = '$GAMMA_BIN/tree_cc ' + UNWFLAGlks + ' ' + nWidth + ' ' + mbl + ' ' + SRU + ' ' + ERL + ' ' + SAU + ' ' + EAL - os.system(call_str) - - - call_str = '$GAMMA_BIN/grasses ' + DIFFINTFILTlks + ' ' + UNWFLAGlks + ' ' + UNWlks + ' ' + nWidth + ' ' + SRU + ' ' + ERL + ' ' + SAU + ' ' + EAL + ' ' + Ref_Range + ' ' + Ref_Azimuth - os.system(call_str) - - - call_str = '$GAMMA_BIN/rasrmg ' + UNWlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(UNWlks, UNWlks) - - if flatteningUnwrap == 'Y': - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - QUADFIT = WRAPlks.replace('.int', '.quad_fit') - OUTUNWQUAD = UNWlks.replace('.unw','.quad_fit.unw') - call_str = '$GAMMA_BIN/create_diff_par ' + OFFlks + ' ' + OFFlks + ' ' + DIFFpar + ' - 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_fit ' + UNWlks + ' ' + DIFFpar + ' 32 32 ' + CORMASK + '_mask.bmp ' + QUADFIT + ' 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_sub ' + UNWlks + ' ' + DIFFpar + ' ' + OUTUNWQUAD + ' 0 0' - os.system(call_str) - - - print "Uwrapping interferometric phase based on Branch-cut is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UnwrapPhase_Gamma.py.bak b/pyint/UnwrapPhase_Gamma.py.bak deleted file mode 100755 index 2a5c226..0000000 --- a/pyint/UnwrapPhase_Gamma.py.bak +++ /dev/null @@ -1,280 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if ( inFile.rsplit('.')[1] == 'int' or inFile.rsplit('.')[1] == 'diff'): - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Unwrap interferograms based on GAMMA. - - - usage: - - UnwrapPhase_Gamma.py igramDir - - e.g. UnwrapPhase_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Topo_Flag' in templateContents: flagTopo = templateContents['Topo_Flag'] - else: flagTopo = 'N' - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - if 'UnwrappedThreshold' in templateContents: unwrappedThreshold = templateContents['UnwrappedThreshold'] - else: unwrappedThreshold = '0.3' - if 'Unwrap_patr' in templateContents: unwrappatrDiff = templateContents['Unwrap_patr'] - else: unwrappatrDiff = '1' - if 'Unwrap_pataz' in templateContents: unwrappatazDiff = templateContents['Unwrap_pataz'] - else: unwrappatazDiff = '1' - -# Definition of file - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' - - DIFFpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.diff.par' - - DIFFINTlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - DIFFINTFFTlks = DIFFINTlks.replace('diff_', 'diff_sim_') - - CORDIFFlks = workDir+'/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORDIFFFILTlks = workDir+'/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - MASKTHINlks = CORFILTlks + 'maskt.bmp' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - nLine = UseGamma(OFFlks, 'read', 'interferogram_azimuth_lines') - - nCenterWidth = str(int(nWidth) / 2) - nCenterLine = str(int(nLine) / 2) - - if 'Ref_Range' in templateContents: Ref_Range = templateContents['Ref_Range'] - else: Ref_Range = nCenterWidth - if 'Ref_Azimuth' in templateContents: Ref_Azimuth = templateContents['Ref_Azimuth'] - else: Ref_Azimuth = nCenterLine #### unwrapping differential interferogram #### -### if topo case, it calls FLTFILTlks -### else if diff case, it calls DIFFINTFILTlks - - if flagTopo == 'Y': - if flatteningIgram == 'orbit': - FLTFILTlks = FLTlks.replace('flat_', 'filt_') - else : - FLTFILTlks = FLTFFTlks.replace('flat_', 'filt_') - WRAPlks = FLTFILTlks - MASKTHIN = MASKTHINlks - CORMASK = CORFILTlks # using the un-filtered image as mask file - else: - if flatteningDiff == 'orbit': - DIFFINTFILTlks = DIFFINTlks.replace('diff_', 'diff_filt_') - else: - DIFFINTFILTlks = DIFFINTFFTlks.replace('diff_', 'diff_filt_') - WRAPlks = DIFFINTFILTlks - MASKTHIN = MASKTHINDIFFlks - CORMASK = CORDIFFFILTlks # using the un-filtered image as mask file - - UWNTHINlks = WRAPlks.replace('.int', '.unw_thinned.bmp') - UNWINTERPlks = WRAPlks.replace('.int', '.unw_interp') - UNWlks = WRAPlks.replace('.int', '.unw') - - # using the un-filtered image as mask file -########################### Start to Mask ########################## - - CORMASKbmp = CORMASK + '_mask.bmp' - - if os.path.isfile(CORMASKbmp): - os.remove(CORMASKbmp) - - call_str = '$GAMMA_BIN/rascc_mask ' + CORMASK + ' ' + MamprlksImg + ' ' + nWidth + ' 1 1 0 1 1 ' + unwrappedThreshold + ' 0.0 0.1 0.9 1. .35 1 ' + CORMASKbmp # based on int coherence - os.system(call_str) - - #call_str = '$GAMMA_BIN/rascc_mask_thinning ' + CORMASKbmp + ' ' + CORMASK + ' ' + nWidth + ' ' + MASKTHIN + ' 5 0.3 0.4 0.5 0.6 0.7' - #os.system(call_str) -########################## Start to Unwrap ########################### - - call_str = '$GAMMA_BIN/mcf ' + WRAPlks + ' ' + CORMASK + ' ' + CORMASKbmp + ' ' + UNWlks + ' ' + nWidth + ' - - - - - ' + unwrappatrDiff + ' ' + unwrappatazDiff + ' - ' + Ref_Range + ' ' + Ref_Azimuth #choose the reference point center - os.system(call_str) - -# call_str = '$GAMMA_BIN/interp_ad ' + UNWlks + ' ' + UNWINTERPlks + ' ' + nWidth -# os.system(call_str) - -# call_str = '$GAMMA_BIN/unw_model ' + WRAPlks + ' ' + UNWINTERPlks + ' ' + UNWlks + ' ' + nWidth -# os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + UNWlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(UNWlks, UNWlks) - - if flatteningUnwrap == 'Y': - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - QUADFIT = WRAPlks.replace('.int', '.quad_fit') - OUTUNWQUAD = UNWlks.replace('.unw','.quad_fit.unw') - call_str = '$GAMMA_BIN/create_diff_par ' + OFFlks + ' ' + OFFlks + ' ' + DIFFpar + ' - 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_fit ' + UNWlks + ' ' + DIFFpar + ' 32 32 ' + CORMASKbmp + ' ' + QUADFIT + ' 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_sub ' + UNWlks + ' ' + DIFFpar + ' ' + OUTUNWQUAD + ' 0 0' - os.system(call_str) - - - print "Uwrapping interferometric phase is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UnwrapPhase_Gamma_All.py.bak b/pyint/UnwrapPhase_Gamma_All.py.bak deleted file mode 100755 index 5ad38a0..0000000 --- a/pyint/UnwrapPhase_Gamma_All.py.bak +++ /dev/null @@ -1,204 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def common_burst_Ref(La_M,La_S): - Min = max(min(La_M),min(La_S)) - Max = min(max(La_M),max(La_S)) - - M_min = [] - M_max = [] - for xm in La_M: - k0_min = float(xm) - float(Min) - k0_max = float(xm) - float(Max) - M_min.append(abs(k0_min)) - M_max.append(abs(k0_max)) - - M_Index_min = M_min.index(min(M_min)) + 1 - M_Index_max = M_max.index(min(M_max)) + 1 - Mindex =[M_Index_min,M_Index_max] - - S_min = [] - S_max = [] - for xs in La_S: - k0_min = float(xs) - float(Min) - k0_max = float(xs) - float(Max) - S_min.append(abs(k0_min)) - S_max.append(abs(k0_max)) - - S_Index_min = S_min.index(min(S_min)) + 1 - S_Index_max = S_max.index(min(S_max)) + 1 - Sindex =[S_Index_min,S_Index_max] - #print La_M - #print La_S - #print min(M_min),min(M_max),min(S_min),min(S_max) - M1 = min(Mindex) - M2 = max(Mindex) - - S1 = min(Sindex) - S2 = max(Sindex) - - if M1==1: S1 = S1 - else: - S1=1-M1+1 - M1=1 - - - if M2 ==len(La_M): S2 = S2 - else: - S2 = S2 + len(La_M) - M2 - M2 = len(La_M) - - - return M1 , M2, S1, S2 - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Unwarp interferograms for the whole project. -''' - -EXAMPLE = ''' - Usage: - UnwrapPhase_Gamma_All.py projectName - - Examples: - UnwrapPhase_Gamma_All.py PacayaT163TsxHhA -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Check common busrts for TOPS data.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='Name of project.') - - inps = parser.parse_args() - - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - IFGLIST = glob.glob(processDir+'/IFG*'+ projectName + '*') - - TT = processDir+ '/run_unwrap_all' - if os.path.isfile(TT): - os.remove(TT) - for kk in IFGLIST: - print '>>> Process ' + os.path.basename(kk) - if 'S1' in projectName: - call_str = 'echo UnwrapPhase_Sen_Gamma.py ' + os.path.basename(kk) + ' >> ' + TT - else: - call_str = 'echo UnwrapPhase_Gamma.py ' + os.path.basename(kk) + ' >> ' + TT - os.system(call_str) - - call_str ='BatchProcess.py ' + '-p ' + TT + ' -m 8000 ' + ' -t 2:00' - os.system(call_str) - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UnwrapPhase_Sen_Gamma.py.bak b/pyint/UnwrapPhase_Sen_Gamma.py.bak deleted file mode 100755 index d554df4..0000000 --- a/pyint/UnwrapPhase_Sen_Gamma.py.bak +++ /dev/null @@ -1,291 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : March, 2017 # -# # -# Unwrap and Geocoding for Sentinel-1 # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if inFile.rsplit('.')[1] == 'int': - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - - - -def usage(): - print ''' -****************************************************************************************************** - - Unwrapping the differential interferograms for Sentinel-1A/B - - usage: - - UnwrapPhase_Sen_Gamma.py igramDir - - e.g. UnwrapPhase_Sen_Gamma.py IFG_PacayaT163S1A_131021-131101_0011_-0007 - e.g. UnwrapPhase_Sen_Gamma.py MAI_PacayaT163S1A_131021-131101_0011_-0007 - e.g. UnwrapPhase_Sen_Gamma.py RSI_PacayaT163S1A_131021-131101_0011_-0007 -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - workDir = processDir + '/' + igramDir - - templateContents=read_template(templateFile) - masterDate = templateContents['masterDate'] - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if 'Igram_Cor_Rwin' in templateContents: rWinCor = templateContents['Igram_Cor_Rwin'] - else: rWinCor = '5' - if 'Igram_Cor_Awin' in templateContents: aWinCor = templateContents['Igram_Cor_Awin'] - else: aWinCor = '5' - - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - - if 'UnwrappedThreshold' in templateContents: unwrappedThreshold = templateContents['UnwrappedThreshold'] - else: unwrappedThreshold = '0.3' - if 'Unwrap_patr' in templateContents: unwrappatrDiff = templateContents['Unwrap_patr'] - else: unwrappatrDiff = '1' - if 'Unwrap_pataz' in templateContents: unwrappatazDiff = templateContents['Unwrap_pataz'] - else: unwrappatazDiff = '1' - - if 'Start_Swath' in templateContents: SW = templateContents['Start_Swath'] - else: SW = '1' - if 'End_Swath' in templateContents: EW = templateContents['End_Swath'] - else: EW = '3' - if 'Start_Burst' in templateContents: SB = templateContents['Start_Burst'] - else: SB = '1' - - if 'Resamp_All' in templateContents: Resamp_All = templateContents['Resamp_All'] - else: Resamp_All = '1' - - if 'Clear_IntFile' in templateContents: Clear_IntFile = templateContents['Clear_IntFile'] - else: Clear_IntFile = '0' - - if 'Clear_RslcFile' in templateContents: Clear_RslcFile = templateContents['Clear_RslcFile'] - else: Clear_RslcFile = '0' - -# Definition of file - MslcDir = rslcDir + '/' + Mdate - SslcDir = rslcDir + '/' + Sdate - masterDir = rslcDir + '/' + masterDate - - - MamprlksImg = MslcDir + '/' + Mdate + '_' + rlks +'rlks.amp' - MamprlksPar = MslcDir + '/' + Mdate + '_' + rlks +'rlks.amp.par' - - if Resamp_All =='1': - MamprlksImg = masterDir + '/' + masterDate + '_' + rlks +'rlks.amp' - MamprlksPar = masterDir + '/' + masterDate + '_' + rlks +'rlks.amp.par' - - INT = workDir + '/' + Mdate + '-' + Sdate + '.int' - INTrlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - SamprlksImg = workDir + '/' + Sdate + '_' + rlks +'rlks.amp' - SamprlksPar = workDir + '/' + Sdate + '_' + rlks +'rlks.amp.par' - - DIFF0 = workDir + '/' + Mdate + '_' + Sdate +'.diff' - DIFFlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - DIFFFILTlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.int' - - UNWlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.unw' - UNWINTERPlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.unw_interp' - DIFFpar = workDir + '/' + Mdate + '-' + Sdate +'.diff_par' - QUADFIT = workDir + '/' + Mdate + '-' + Sdate +'.quad_fit' - - CORDIFFFILTlks = workDir + '/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks.cor' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - call_str = 'cp ' + DIFF0 + ' ' + DIFFlks - os.system(call_str) - - - ###################### Filtering #################### - - if 'Diff_FilterStrength' in templateContents: - strFilterStrengeh = templateContents['Diff_FilterStrength'] - fFiltLengthDiff = strFilterStrengeh.split('/')[0] - nFiltWindowDiff = strFilterStrengeh.split('/')[1] - else: - fFiltLengthDiff = '-' - nFiltWindowDiff='-' - - nWidth = UseGamma( MamprlksPar, 'read', 'range_samples:') - nLine = UseGamma(MamprlksPar, 'read', 'azimuth_lines:') - - nCenterWidth = str(int(nWidth) / 2) - nCenterLine = str(int(nLine) / 2) - - if 'Ref_Range' in templateContents: Ref_Range = templateContents['Ref_Range'] - else: Ref_Range = nCenterWidth - if 'Ref_Azimuth' in templateContents: Ref_Azimuth = templateContents['Ref_Azimuth'] - else: Ref_Azimuth = nCenterLine - - - call_str = '$GAMMA_BIN/adapt_filt ' + DIFFlks + ' ' + DIFFFILTlks + ' ' + nWidth + ' ' + fFiltLengthDiff + ' ' + nFiltWindowDiff - os.system(call_str) - -#################### Unwrap ########################## - - call_str= '$GAMMA_BIN/cc_wave ' + DIFFFILTlks + ' ' + MamprlksImg + ' - ' + CORDIFFFILTlks + ' ' + nWidth + ' ' + rWinCor + ' ' + aWinCor - os.system(call_str) - - call_str = '$GAMMA_BIN/rascc ' + CORDIFFFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - ras2jpg(CORDIFFFILTlks, CORDIFFFILTlks) - - - CORDIFFFILTlksbmp = CORDIFFFILTlks + '_mask.bmp' - call_str = '$GAMMA_BIN/rascc_mask ' + CORDIFFFILTlks + ' ' + MamprlksImg + ' ' + nWidth + ' 1 1 0 1 1 ' + unwrappedThreshold + ' 0.0 0.1 0.9 1. .35 1 ' + CORDIFFFILTlksbmp # based on diff coherence - os.system(call_str) - - #call_str = '$GAMMA_BIN/rascc_mask_thinning ' + CORDIFFFILTlksbmp + ' ' + CORDIFFFILTlks + ' ' + nWidth + ' ' + MASKTHINDIFFlks + ' 5 0.3 0.4 0.5 0.6 0.7' - #os.system(call_str) - - call_str = '$GAMMA_BIN/mcf ' + DIFFFILTlks + ' ' + CORDIFFFILTlks + ' ' + CORDIFFFILTlksbmp + ' ' + UNWlks + ' ' + nWidth + ' 0 0 0 - - ' + unwrappatrDiff + ' ' + unwrappatazDiff + ' - ' + Ref_Range + ' ' + Ref_Azimuth #choose the reference point center - os.system(call_str) - - #call_str = '$GAMMA_BIN/interp_ad ' + UNWlks + ' ' + UNWINTERPlks + ' ' + nWidth - #os.system(call_str) - - #call_str = '$GAMMA_BIN/unw_model ' + DIFFFILTlks + ' ' + UNWINTERPlks + ' ' + UNWlks + ' ' + nWidth - #os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + UNWlks + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(UNWlks, UNWlks) - - if flatteningUnwrap == 'Y': - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - OUTUNWQUAD = UNWlks.replace('.unw','.quad_fit.unw') - call_str = '$GAMMA_BIN/create_diff_par ' + MamprlksPar + ' ' + MamprlksPar + ' ' + DIFFpar + ' 1 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_fit ' + UNWlks + ' ' + DIFFpar + ' 32 32 ' + CORDIFFFILTlks + '_mask.bmp ' + QUADFIT + ' 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_sub ' + UNWlks + ' ' + DIFFpar + ' ' + OUTUNWQUAD + ' 0 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + OUTUNWQUAD + ' ' + MamprlksImg + ' ' + nWidth + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(OUTUNWQUAD, OUTUNWQUAD) - - if Clear_IntFile =='1': - os.remove(INT) - os.remove(INTrlks) - os.remove(DIFF0) - os.remove(DIFFlks) - os.remove(DIFFFILTlks) - - RSLCFILE= glob.glob(workDir+'/'+'*.rslc') - if Clear_RslcFile =='1': - for kk in RSLCFILE: - os.remove(kk) - - - print "Unwrapping for S1 interferogram is done !" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/UnwrapPhase_Sub_Gamma.py.bak b/pyint/UnwrapPhase_Sub_Gamma.py.bak deleted file mode 100755 index daddf9e..0000000 --- a/pyint/UnwrapPhase_Sub_Gamma.py.bak +++ /dev/null @@ -1,347 +0,0 @@ -#! /usr/bin/env python -#''' -################################################################################### -# # -# Author: Yun-Meng Cao # -# Email : ymcmrs@gmail.com # -# Date : February, 2017 # -# # -# Unwrap interferograms based on Rounding box # -# # -################################################################################### -#''' -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def geocode(inFile, outFile, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM): - if ( inFile.rsplit('.')[1] == 'int' or inFile.rsplit('.')[1] == 'diff'): - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 1' - else: - call_str = '$GAMMA_BIN/geocode_back ' + inFile + ' ' + nWidth + ' ' + UTMTORDC + ' ' + outFile + ' ' + nWidthUTMDEM + ' ' + nLineUTMDEM + ' 0 0' - os.system(call_str) - -def createBlankFile(strFile): - f = open(strFile,'w') - for i in range (10): - f.write('\n') - f.close() - -def GetSubset(Subset): - KK = Subset.split('[')[1].split(']')[0] - if ':' in KK: - Dx = Subset.split('[')[1].split(']')[0].split(',')[0] - Dy = Subset.split('[')[1].split(']')[0].split(',')[1] - - x1 = Dx.split(':')[0] - x2 = Dx.split(':')[1] - - y1 = Dy.split(':')[0] - y2 = Dy.split(':')[1] - else: - x1 = '-' - x2 = '-' - y1 = '-' - y2 = '-' - - return x1,x2,y1,y2 - -def usage(): - print ''' -****************************************************************************************************** - - Unwrap interferograms based on GAMMA. - - - usage: - - UnwrapPhase_Gamma.py igramDir - - e.g. UnwrapPhase_Sub_Gamma.py IFG_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_Sub_Gamma.py MAI_PacayaT163TsxHhA_131021-131101_0011_0007 - e.g. UnwrapPhase_Sub_Gamma.py RSI_PacayaT163TsxHhA_131021-131101_0011_0007 - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: igramDir=sys.argv[1] - else: - usage();sys.exit(1) - - INF = igramDir.split('_')[0] - projectName = igramDir.split('_')[1] - IFGPair = igramDir.split(projectName+'_')[1].split('_')[0] - Mdate = IFGPair.split('-')[0] - Sdate = IFGPair.split('-')[1] - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - workDir = processDir + '/' + igramDir - simDir = scratchDir + '/' + projectName + "/PROCESS" + "/SIM" - simDir = simDir + '/sim_' + Mdate + '-' + Sdate - - templateContents=read_template(templateFile) - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - if INF=='IFG': - Suffix=[''] - elif INF=='MAI': - Suffix=['.F','.B'] - elif INF=='RSI': - Suffix=['.HF','.LF'] - else: - print "The folder name %s cannot be identified !" % igramDir - usage();sys.exit(1) - - - if 'Igram_Flattening' in templateContents: flatteningIgram = templateContents['Igram_Flattening'] - else: flatteningIgram = 'orbit' - if 'Topo_Flag' in templateContents: flagTopo = templateContents['Topo_Flag'] - else: flagTopo = 'N' - if 'Diff_Flattening' in templateContents: flatteningDiff = templateContents['Diff_Flattening'] - else: flatteningDiff = 'orbit' - if 'Unwrap_Flattening' in templateContents: flatteningUnwrap = templateContents['Unwrap_Flattening'] - else: flatteningUnwrap = 'N' - if 'UnwrappedThreshold' in templateContents: unwrappedThreshold = templateContents['UnwrappedThreshold'] - else: unwrappedThreshold = '0.3' - if 'Unwrap_patr' in templateContents: unwrappatrDiff = templateContents['Unwrap_patr'] - else: unwrappatrDiff = '1' - if 'Unwrap_pataz' in templateContents: unwrappatazDiff = templateContents['Unwrap_pataz'] - else: unwrappatazDiff = '1' - - if 'Subset_Rdc' in templateContents: - Subset = templateContents['Subset_Rdc'] - XX = GetSubset(Subset) - if not XX[3] == '-': - SRU = XX[0] - NR = str(int(XX[1])-int(XX[0])) - SAU= XX[2] - NA = str(int(XX[3])-int(XX[2])) - else: - SRU = '-' - NR = '-' - SAU = '-' - NA = '-' - else: - SRU = '-' - NR = '-' - SAU = '-' - NA = '-' - -# Definition of file - - for i in range(len(Suffix)): - MrslcImg = workDir + "/" + Mdate + Suffix[i]+".rslc" - MrslcPar = workDir + "/" + Mdate + Suffix[i]+".rslc.par" - SrslcImg = workDir + "/" + Sdate + Suffix[i]+".rslc" - SrslcPar = workDir + "/" + Sdate + Suffix[i]+".rslc.par" - - MamprlksImg = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - MamprlksImg_Sub = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".sub.ramp" - MamprlksPar = workDir + "/" + Mdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - SamprlksImg = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp" - SamprlksPar = workDir + "/" + Sdate + '_'+rlks+'rlks'+Suffix[i]+".ramp.par" - - OFF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.off' - INT = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.int' - INTlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - OFFlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.off' - FLTlks = workDir + '/flat_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - FLTFFTlks = FLTlks.replace('flat_', 'flat_sim_') - - CORlks = workDir + '/' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORFILTlks = workDir + '/filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - BASE = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base' - BASE_REF = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.base_ref' - - DIFFpar = workDir + '/' + Mdate + '-' + Sdate + Suffix[i] + '.diff.par' - - DIFFINTlks = workDir + '/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.int' - DIFFINTFFTlks = DIFFINTlks.replace('diff_', 'diff_sim_') - - CORDIFFlks = workDir+'/diff_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - CORDIFFFILTlks = workDir+'/diff_filt_' + Mdate + '-' + Sdate + '_' + rlks + 'rlks' + Suffix[i] + '.cor' - - MASKTHINlks = CORFILTlks + 'maskt.bmp' - MASKTHINDIFFlks = CORDIFFFILTlks + 'maskt.bmp' - - - nWidth = UseGamma(OFFlks, 'read', 'interferogram_width') - nLine = UseGamma(OFFlks, 'read', 'interferogram_azimuth_lines') - - nCenterWidth = str(int(nWidth) / 2) - nCenterLine = str(int(nLine) / 2) - - if 'Ref_Range' in templateContents: Ref_Range = templateContents['Ref_Range'] - else: Ref_Range = nCenterWidth - if 'Ref_Azimuth' in templateContents: Ref_Azimuth = templateContents['Ref_Azimuth'] - else: Ref_Azimuth = nCenterLine #### unwrapping differential interferogram #### -### if topo case, it calls FLTFILTlks -### else if diff case, it calls DIFFINTFILTlks - - if flagTopo == 'Y': - if flatteningIgram == 'orbit': - FLTFILTlks = FLTlks.replace('flat_', 'filt_') - else : - FLTFILTlks = FLTFFTlks.replace('flat_', 'filt_') - WRAPlks = FLTFILTlks - MASKTHIN = MASKTHINlks - CORMASK = CORFILTlks # using the un-filtered image as mask file - else: - if flatteningDiff == 'orbit': - DIFFINTFILTlks = DIFFINTlks.replace('diff_', 'diff_filt_') - else: - DIFFINTFILTlks = DIFFINTFFTlks.replace('diff_', 'diff_filt_') - WRAPlks = DIFFINTFILTlks - MASKTHIN = MASKTHINDIFFlks - CORMASK = CORDIFFFILTlks # using the un-filtered image as mask file - - UWNTHINlks = WRAPlks.replace('.int', '.sub.unw_thinned.bmp') - UNWINTERPlks = WRAPlks.replace('.int', '.sub.unw_interp') - UNWlks = WRAPlks.replace('.int', '.sub.unw') - - if os.path.isfile(UNWlks): - os.remove(UNWlks) - - - # using the un-filtered image as mask file -########################### Start to Mask ########################## - - CORMASKbmp = CORMASK + '.sub_mask.bmp' - if os.path.isfile(CORMASKbmp): - os.remove(CORMASKbmp) - - if os.path.isfile(CORMASKbmp): - os.remove(CORMASKbmp) - - call_str = '$GAMMA_BIN/rascc_mask ' + CORMASK + ' ' + MamprlksImg + ' ' + nWidth + ' 1 1 0 1 1 ' + unwrappedThreshold + ' 0.0 0.1 0.9 1. .35 1 ' + CORMASKbmp # based on int coherence - os.system(call_str) - - - call_str = '$GAMMA_BIN/mcf ' + WRAPlks + ' ' + CORMASK + ' ' + CORMASKbmp + ' ' + UNWlks + ' ' + nWidth + ' 1 ' + SRU + ' ' + SAU + ' ' + NR + ' ' + NA + ' ' + unwrappatrDiff + ' ' + unwrappatazDiff + ' - ' + Ref_Range + ' ' + Ref_Azimuth #choose the reference point center - os.system(call_str) - - - data = np.fromfile(UNWlks, '>f4', int(nLine)*int(nWidth)).reshape(int(nLine),int(nWidth)) - data_sub = data[int(SAU):(int(SAU)+int(NA)),int(SRU):(int(SRU)+int(NR))] - -# if not sys.byteorder == 'big': -# data_sub.byteswap(True) - data_sub.tofile(UNWlks) - - - data = np.fromfile(MamprlksImg, '>f4', int(nLine)*int(nWidth)).reshape(int(nLine),int(nWidth)) - data_sub = data[int(SAU):(int(SAU)+int(NA)),int(SRU):(int(SRU)+int(NR))] - - data_sub.tofile(MamprlksImg_Sub) - - data = np.fromfile(CORMASKbmp, '>u1', int(nLine)*int(nWidth)).reshape(int(nLine),int(nWidth)) - data_sub = data[int(SAU):(int(SAU)+int(NA)),int(SRU):(int(SRU)+int(NR))] - data_sub.tofile(CORMASKbmp) - - - WIDTH = NR -# call_str = '$GAMMA_BIN/interp_ad ' + UNWlks + ' ' + UNWINTERPlks + ' ' + nWidth -# os.system(call_str) - -# call_str = '$GAMMA_BIN/unw_model ' + WRAPlks + ' ' + UNWINTERPlks + ' ' + UNWlks + ' ' + nWidth -# os.system(call_str) - - call_str = '$GAMMA_BIN/rasrmg ' + UNWlks + ' ' + MamprlksImg_Sub + ' ' + WIDTH + ' - - - - - - - - - - ' - os.system(call_str) - - ras2jpg(UNWlks, UNWlks) - - - - - if flatteningUnwrap == 'Y': - if os.path.isfile(DIFFpar): - os.remove(DIFFpar) - - QUADFIT = WRAPlks.replace('.int', '.quad_fit') - OUTUNWQUAD = UNWlks.replace('.unw','.quad_fit.unw') - call_str = '$GAMMA_BIN/create_diff_par ' + OFFlks + ' ' + OFFlks + ' ' + DIFFpar + ' - 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_fit ' + UNWlks + ' ' + DIFFpar + ' 32 32 - ' + QUADFIT + ' 0' - os.system(call_str) - - call_str = '$GAMMA_BIN/quad_sub ' + UNWlks + ' ' + DIFFpar + ' ' + OUTUNWQUAD + ' 0 0' - os.system(call_str) - - - - - print "Uwrapping interferometric phase is done!" - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) diff --git a/pyint/Update_Orbit_Sen.py.bak b/pyint/Update_Orbit_Sen.py.bak deleted file mode 100755 index 645079e..0000000 --- a/pyint/Update_Orbit_Sen.py.bak +++ /dev/null @@ -1,123 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob -import argparse - -def StrNum(S): - S = str(S) - if len(S)==1: - S='0' +S - return S - - -######################################################################### - -INTRODUCTION = ''' -############################################################################################## - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Update the orbit data of Sentinel-1A/B slc par files based on the AUX_POEORB data. - See also: Sen_PreOrbit.py - -''' - -EXAMPLE = ''' - Usage: - Update_Orbit_Sen.py SLCPATH/Date - - Examples: - Update_Orbit_Sen.py /scratch/projects/insarlab/yxc773/ShanghaiT171F96S1A/SLC/170122 - -################################################################################################### -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Update the orbit data for the slc par files.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('slc_path',help='Path of SLC directory.') - - inps = parser.parse_args() - return inps - -################################################################################ - - -def main(argv): - - inps = cmdLineParse() - PATH = inps.slc_path - os.chdir(PATH) - - path = os.getcwd() - KK=os.listdir(path) - - Date = os.path.basename(path) - if len(Date)==6: - Date = '20'+Date - Date0 = int(Date)-1 - FF0 = 'V'+str(Date0) - - - - SLC_PAR = [] - ORBIT = 'test' - for ll in KK: - if 'slc.par' in ll: - SLC_PAR.append(ll) - if 'S1A_OPER_AUX_POEORB_OPOD_' and FF0 in ll: - print ll - ORBIT = ll - - if not os.path.isfile(ORBIT): - - print 'Precise orbit file is not found! Please use Sen_PreOrb.py to download the orbit data.' - sys.exit(1) - - print SLC_PAR - N = len(SLC_PAR) - - for ff in SLC_PAR: - call_str = 'S1_OPOD_vec ' + ff + ' ' + ORBIT - os.system(call_str) - - print 'Update the orbit parameters of the slc par files for date %s is finished.' % Date - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pyint/load_data_gamma.py.bak b/pyint/load_data_gamma.py.bak deleted file mode 100755 index 38c9daf..0000000 --- a/pyint/load_data_gamma.py.bak +++ /dev/null @@ -1,636 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import os -import sys -import glob -import time -import argparse - -import h5py -import numpy as np - -def print_progress(iteration, total, prefix='calculating:', suffix='complete', decimals=1, barLength=50, elapsed_time=None): - """Print iterations progress - Greenstick from Stack Overflow - Call in a loop to create terminal progress bar - @params: - iteration - Required : current iteration (Int) - total - Required : total iterations (Int) - prefix - Optional : prefix string (Str) - suffix - Optional : suffix string (Str) - decimals - Optional : number of decimals in percent complete (Int) - barLength - Optional : character length of bar (Int) - elapsed_time- Optional : elapsed time in seconds (Int/Float) - - Reference: http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console - """ - filledLength = int(round(barLength * iteration / float(total))) - percents = round(100.00 * (iteration / float(total)), decimals) - bar = '#' * filledLength + '-' * (barLength - filledLength) - if elapsed_time: - sys.stdout.write('%s [%s] %s%s %s %s secs\r' % (prefix, bar, percents, '%', suffix, int(elapsed_time))) - else: - sys.stdout.write('%s [%s] %s%s %s\r' % (prefix, bar, percents, '%', suffix)) - sys.stdout.flush() - if iteration == total: - print("\n") - - ''' - Sample Useage: - for i in range(len(dateList)): - print_progress(i+1,len(dateList)) - ''' - return - - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def read_data(inFile, dtype, nWidth, nLength): - data = np.fromfile(inFile, dtype, int(nLength)*int(nWidth)).reshape(int(nLength),int(nWidth)) - return data - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - -def add_zero(s): - if len(s)==1: - s="000"+s - elif len(s)==2: - s="00"+s - elif len(s)==3: - s="0"+s - return s - -def read_list(ListName): - List=glob.glob(ListName) - return List - -def read_list_except(ListName,ExString): - List=glob.glob(ListName) - List_New = [] - for S in List: - if ExString not in os.path.basename(S): - List_New.append(S) - return List_New - - -def load_gamma2multi_group_h5(fileType, fileName, fileList, RSCList, datatype): - - RSC =RSCList[0] - rsc_dic = read_roipac_rsc(RSC) - nWidth = rsc_dic['WIDTH'] - nLine = rsc_dic['FILE_LENGTH'] - - H5FILE = fileName + '.h5' - fileNum = len(fileList) - print 'Start to load ' + fileName + ' >>> %s %s files will be loaded for further process' % ( str(fileNum), fileType) - f = h5py.File(H5FILE,'w') - gg=f.create_group(fileType) - - for i in range(len(fileList)): - S=fileList[i] - RSC =RSCList[i] - rsc_dic = read_roipac_rsc(RSC) - print_progress(i+1, fileNum, prefix='loading', suffix=os.path.basename(S)) - data = read_data(S,datatype,nWidth,nLine) - File = os.path.basename(S) - group = gg.create_group(File) - dset = group.create_dataset(File, data = data, compression='gzip') - for key,value in rsc_dic.iteritems(): - group.attrs[key] = value - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidth)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLine)-1) - group.attrs['DATE12']=File.split('_')[2] - group.attrs['DATATYPE'] = datatype - group.attrs['PROCCESSOR'] = 'gamma' - - f.close() - - -def Get_Datelist(projectName): - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - rslcDir = scratchDir + '/' + projectName + "/RSLC" - slcDir = scratchDir + '/' + projectName + "/SLC" - - ListSLC = os.listdir(slcDir) - Datelist = [] - - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): # if SAR date number is 8, 6 should change to 8. - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - Datelist = map(int,Datelist) - Datelist.sort() - Datelist = map(str,Datelist) - return Datelist - -def Get_Inflist(projectName): - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - IFGRAM = scratchDir + '/' + projectName + "/PROCESS/IFG*" - IFGList = glob.glob(IFGRAM) - - ListSLC = os.listdir(slcDir) - Datelist = [] - - -def Get_PairName(projectName): - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - IFGRAM = scratchDir + '/' + projectName + "/PROCESS/IFG*" - IFGList = glob.glob(IFGRAM) - - PAIR_Name = [] - for kk in range(len(IFGList)): - SS = IFGList[kk] - IFGName = os.path.basename(SS) - PAIR=IFGName.split('_')[2] - PAIR_Name.append(PAIR) - - return PAIR_Name - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def UseGamma2(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[2].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def Remove_Inf_List(RemoveNumberStr): - AD=RemoveNumberStr - Addlist = [] - if len(AD)>0: - AD= AD.split('[')[1].split(']')[0] - if ',' in AD: - LL=AD.split(',') - for kk in range(len(LL)): - XX=LL[kk] - if is_number(XX): - Addlist.append(XX) - - else: - D1=XX.split(':')[0] - D2=XX.split(':')[1] - for jj in range(int(D1),int(D2)+1): - Addlist.append(str(jj)) - else: - LL = AD - if is_number(LL): - Addlist.append(LL) - else: - D1=LL.split(':')[0] - D2=LL.split(':')[1] - for jj in range(int(D1),int(D2)+1): - Addlist.append(str(jj)) - for ii in range(len(Addlist)): - Addlist[ii]=int(Addlist[ii])-1 - Addlist = map(str,Addlist) - return Addlist - - -def read_roipac_rsc(File): - '''Read ROI_PAC .rsc file into a python dictionary structure.''' - rsc_dict = dict(np.loadtxt(File, dtype=str, usecols=(0,1))) - return rsc_dict - - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao @PyINT v1.0 - - Loading data for PyMIS processing. - -''' - -EXAMPLE = ''' - Usage: - load_data_pymis.py projectName - load_data_pymis.py projectName --demRdc - load_data_pymis.py projectName --wrapIfgram - - Examples: - load_data_pymis.py PacayaT163TsxHhA - load_data_pymis.py PacayaT163TsxHhA --demRdc - load_data_pymis.py PacayaT163TsxHhA --coherence - -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Loading data for PyMIS processing.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - parser.add_argument('projectName',help='project name of PyMIS.') - parser.add_argument('--coherence',action="store_true", default=False, help='Loading coherence file.') - parser.add_argument('--wrapIfgram',action="store_true", default=False, help='Loading wrapped interferograms.') - parser.add_argument('--unwrapIfgram',action="store_true", default=False, help='Loading unwrapped interferograms.') - parser.add_argument('--demRdc',action="store_true", default=False, help='Loading radar coordinates DEM.') - parser.add_argument('--demGeo',action="store_true", default=False, help='Loading GEO coordinates DEM.') - parser.add_argument('--geo2rdc',action="store_true", default=False, help='Loading geocoding lookup table.') - - inps = parser.parse_args() - - - - return inps - -################################################################################ - -def main(argv): - - - total = time.time() - inps = cmdLineParse() - projectName = inps.projectName - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - templateContents=read_template(templateFile) - - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - simDir = scratchDir + '/' + projectName + "/PROCESS/DEM" - - - masterDate = templateContents['masterDate'] - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - workDir = scratchDir + '/' + projectName + '/TSSAR' - if not os.path.isdir(workDir): - call_str='mkdir ' + workDir - os.system(call_str) - - if not os.path.isdir(workDir): - call_str='mkdir ' + workDir - os.system(call_str) - - print 'Project : ' + projectName - print 'Loading data for timeseries processing >>>' - print 'Change process Dir to :' + workDir - os.chdir(workDir) - - -################# DEM Define ############ - - - - - UTM2RDC = simDir+'/sim_' + masterDate + '_' + rlks + 'rlks.UTM_TO_RDC' - RDCDEM = simDir+'/sim_' + masterDate + '_' + rlks + 'rlks.rdc.dem' - UTMDEM = simDir+'/sim_' + masterDate + '_' + rlks + 'rlks.utm.dem' - UTMPAR = simDir+'/sim_' + masterDate + '_' + rlks + 'rlks.utm.dem.par' - - - -# if not os.path.isfile(UTM2RDC): -# print 'Start to generate subset look-up table and subset-DEM >>>' -# call_str = 'CreateRdcDem_Sub_Gammapy.py ' + igramDir -# print call_str -# os.system(call_str) -# else: -# print 'Subet lookup table %s is existed!' % UTM2RDC - - Dem_Format = UseGamma(UTMPAR, 'read', 'data_format:') - - if Dem_Format=='REAL*4': - dtype_utmdem='f4' - else: - dtype_utmdem='i2' - - nWidthUTM = UseGamma(UTMPAR, 'read', 'width:') - nLineUTM = UseGamma(UTMPAR, 'read', 'nlines:') - - Corner_LAT = UseGamma(UTMPAR, 'read', 'corner_lat:') - Corner_LON = UseGamma(UTMPAR, 'read', 'corner_lon:') - - Corner_LAT =Corner_LAT.split(' ')[0] - Corner_LON =Corner_LON.split(' ')[0] - - post_Lat = UseGamma(UTMPAR, 'read', 'post_lat:') - post_Lon = UseGamma(UTMPAR, 'read', 'post_lon:') - - post_Lat =post_Lat.split(' ')[0] - post_Lon =post_Lon.split(' ')[0] - -############### timeseries file define ################## - - if 'IFG_list' in templateContents: IFG_list = templateContents['IFG_list'] - else: IFG_list = processDir + '/IFG*/diff_filt*rlks.int' - if 'UNW_list' in templateContents: UNW_list = templateContents['UNW_list'] - else: UNW_list = processDir + '/IFG*/diff_filt*rlks.unw' - if 'COR_list' in templateContents: COR_list = templateContents['COR_list'] - else: COR_list = processDir + '/IFG*/diff_filt*rlks.cor' - if 'MASK_list' in templateContents: MASK_list = templateContents['MASK_list'] - else: MASK_list = processDir + '/IFG*/diff_filt*rlks.unw' - if 'RSC_list' in templateContents: RSC_list = templateContents['RSC_list'] - else: RSC_list = processDir + '/IFG*/*rlks.rsc' - - MM=MASK_list[0] - if MM.split('.')[len(MM.split('.'))-1]=='bmp': - dtype_mask ='u1' - else: - dtype_mask ='f4' - - if 'Byte_order' in templateContents: byteoder = templateContents['Byte_order'] - else: byteorder = 'big' - - if byteorder =='big': - sign = '>' - else: - sign ='<' - - dtype_inf = sign + 'c8' - dtype_unw = sign + 'f4' - dtype_utmdem = sign + dtype_utmdem - dtype_rdcdem = sign + 'f4' - dtype_lt = sign + 'c8' - dtype_mask = sign + dtype_mask - dtype_cor = sign + 'f4' - -#################### start to load data ######################## - InfList = read_list(IFG_list) - NInf = len(InfList) - - print 'RSC_Name is : ' + RSC_list - RSCList = read_list(RSC_list) - RSC =RSCList[0] - rsc_dic = read_roipac_rsc(RSC) - nWidth = rsc_dic['WIDTH'] - nLine = rsc_dic['FILE_LENGTH'] - UNWList = read_list(UNW_list) - CORList = read_list(COR_list) - Flag_K = 0 - if inps.coherence: - Flag_K = 1 - print '' - print 'COR_Name is : ' + COR_list - load_gamma2multi_group_h5('coherence','coherence', CORList, RSCList, dtype_cor) - elif inps.wrapIfgram: - Flag_K = 1 - print '' - print 'IFG_Name is : ' + IFG_list - load_gamma2multi_group_h5('wrapped','wrapIfgram', InfList, RSCList, dtype_inf) - elif inps.unwrapIfgram: - Flag_K = 1 - print '' - print 'UNW_Name is : ' + UNW_list - load_gamma2multi_group_h5('interferograms','unwrapIfgram', UNWList, RSCList, dtype_unw) - elif inps.demGeo: - Flag_K = 1 - print '' - print 'Start to write GEO-DEM into h5 file >>> ' + UTMDEM - data = read_data(UTMDEM, dtype_utmdem, nWidthUTM, nLineUTM) - H5FILE = 'demGeo.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('dem') - dset = group.create_dataset('dem', data=data, compression='gzip') - group.attrs['WIDTH'] = nWidthUTM - group.attrs['FILE_LENGTH'] = nLineUTM - group.attrs['X_FIRST'] = Corner_LON # X: latitude Y: longitude - group.attrs['Y_FIRST'] = Corner_LAT - group.attrs['X_STEP'] = post_Lon - group.attrs['Y_STEP'] = post_Lat - group.attrs['X_UNIT'] = 'degrees' - group.attrs['Y_UNIT'] = 'degrees' - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidthUTM)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLineUTM)-1) - group.attrs['DATATYPE'] = dtype_utmdem - group.attrs['COORD'] = 'geo' - group.attrs['PROCCESSOR'] = 'gamma' - f.close() - elif inps.demRdc: - Flag_K = 1 - print '' - print 'Start to write RDC-DEM into h5 file >>> ' + RDCDEM - data = read_data(RDCDEM, dtype_rdcdem, nWidth, nLine) - H5FILE = 'demRdc.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('dem') - dset = group.create_dataset('dem', data=data, compression='gzip') - group.attrs['PROCCESSOR'] = 'gamma' - group.attrs['WIDTH'] = nWidth - group.attrs['FILE_LENGTH'] = nLine - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidth)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLine)-1) - group.attrs['DATATYPE'] = dtype_rdcdem - group.attrs['COORD'] ='radar' - f.close() - elif inps.geo2rdc: - Flag_K = 1 - print '' - print 'Start to write GEO2RDC into h5 file >>> ' + UTM2RDC - data = read_data(UTM2RDC,dtype_lt,nWidthUTM,nLineUTM) # real: range imaginary: azimuth - H5FILE = 'geo2rdc.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('lt') - dset = group.create_dataset('lt', data=data, compression='gzip') - group.attrs['WIDTH'] = nWidthUTM - group.attrs['FILE_LENGTH'] = nLineUTM - group.attrs['X_FIRST'] = Corner_LON # X: latitude Y: longitude - group.attrs['Y_FIRST'] = Corner_LAT - group.attrs['X_STEP'] = post_Lon - group.attrs['Y_STEP'] = post_Lat - group.attrs['X_UNIT'] = 'degrees' - group.attrs['Y_UNIT'] = 'degrees' - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidthUTM)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLineUTM)-1) - group.attrs['DATATYPE'] = dtype_utmdem - group.attrs['COORD'] = 'geo' - group.attrs['PROCCESSOR'] = 'gamma' - f.close() - - - - if not os.path.isfile('wrapIfgram.h5') and Flag_K==0: - print '' - print 'IFG_Name is : ' + IFG_list - load_gamma2multi_group_h5('wrapped','wrapIfgram', InfList, RSCList, dtype_inf) - else: - print '' - print 'wrapIfgram.h5 has existed, loading wrapped interferograms is skipped.' - - - - if not os.path.isfile('unwrapIfgram.h5') and Flag_K==0: - print '' - print 'UNW_Name is : ' + UNW_list - load_gamma2multi_group_h5('interferograms','unwrapIfgram', UNWList, RSCList, dtype_unw) - else: - print '' - print 'unwrapIfgram.h5 has existed, loading unwrapped interferograms is skipped.' - - - if not os.path.isfile('coherence.h5') and Flag_K==0: - print '' - print 'COR_Name is : ' + COR_list - load_gamma2multi_group_h5('coherence','coherence', CORList, RSCList, dtype_cor) - else: - print '' - print 'coherence.h5 has existed, loading coherence is skipped.' - - -######### load DEM and lookup table ########## - - if not os.path.isfile('demGeo.h5') and Flag_K==0: - print '' - print 'Start to write GEO-DEM into h5 file >>> ' + UTMDEM - data = read_data(UTMDEM, dtype_utmdem, nWidthUTM, nLineUTM) - H5FILE = 'demGeo.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('dem') - dset = group.create_dataset('dem', data=data, compression='gzip') - group.attrs['WIDTH'] = nWidthUTM - group.attrs['FILE_LENGTH'] = nLineUTM - group.attrs['X_FIRST'] = Corner_LON # X: latitude Y: longitude - group.attrs['Y_FIRST'] = Corner_LAT - group.attrs['X_STEP'] = post_Lon - group.attrs['Y_STEP'] = post_Lat - group.attrs['X_UNIT'] = 'degrees' - group.attrs['Y_UNIT'] = 'degrees' - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidthUTM)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLineUTM)-1) - group.attrs['DATATYPE'] = dtype_utmdem - group.attrs['COORD'] = 'geo' - group.attrs['PROCCESSOR'] = 'gamma' - f.close() - else: - print '' - print 'demGeo.h5 has existed, loading GEO-DEM is skipped.' - - - if not os.path.isfile('demRdc.h5') and Flag_K==0: - print '' - print 'Start to write RDC-DEM into h5 file >>> ' + RDCDEM - data = read_data(RDCDEM, dtype_rdcdem, nWidth, nLine) - H5FILE = 'demRdc.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('dem') - dset = group.create_dataset('dem', data=data, compression='gzip') - group.attrs['PROCCESSOR'] = 'gamma' - group.attrs['WIDTH'] = nWidth - group.attrs['FILE_LENGTH'] = nLine - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidth)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLine)-1) - group.attrs['DATATYPE'] = dtype_rdcdem - group.attrs['COORD'] ='radar' - f.close() - else: - print '' - print 'demRdc.h5 has existed, loading RDC-DEM is skipped.' - - - if not os.path.isfile('geo2rdc.h5') and Flag_K==0: - print '' - print 'Start to write GEO2RDC into h5 file >>> ' + UTM2RDC - data = read_data(UTM2RDC,dtype_lt,nWidthUTM,nLineUTM) # real: range imaginary: azimuth - H5FILE = 'geo2rdc.h5' - f =h5py.File(H5FILE,'w') - group=f.create_group('lt') - dset = group.create_dataset('lt', data=data, compression='gzip') - group.attrs['WIDTH'] = nWidthUTM - group.attrs['FILE_LENGTH'] = nLineUTM - group.attrs['X_FIRST'] = Corner_LON # X: latitude Y: longitude - group.attrs['Y_FIRST'] = Corner_LAT - group.attrs['X_STEP'] = post_Lon - group.attrs['Y_STEP'] = post_Lat - group.attrs['X_UNIT'] = 'degrees' - group.attrs['Y_UNIT'] = 'degrees' - group.attrs['X_MIN'] = '0' - group.attrs['X_MAX'] = str(int(nWidthUTM)-1) - group.attrs['Y_MIN'] = '0' - group.attrs['Y_MAX'] = str(int(nLineUTM)-1) - group.attrs['DATATYPE'] = dtype_utmdem - group.attrs['COORD'] = 'geo' - group.attrs['PROCCESSOR'] = 'gamma' - f.close() - else: - print '' - print 'geo2rdc.h5 has existed, loading lookup table is skipped.' - - print '' - print 'Done.\nLoading data spend ' + str(time.time()-total) +' secs' - sys.exit(1) - - -############################################################################## -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/pyint/makedem.py.bak b/pyint/makedem.py.bak deleted file mode 100755 index e28a616..0000000 --- a/pyint/makedem.py.bak +++ /dev/null @@ -1,296 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - - -import numpy as np -import os -import sys -import getopt -import array -import argparse -from skimage import io - -def get_sufix(STR): - n = len(STR.split('.')) - SUFIX = STR.split('.')[n-1] - - return SUFIX - -def read_region(STR): - WEST = STR.split('/')[0] - EAST = STR.split('/')[1].split('/')[0] - - SOUTH = STR.split(EAST+'/')[1].split('/')[0] - NORTH = STR.split(EAST+'/')[1].split('/')[1] - - WEST =float(WEST) - SOUTH=float(SOUTH) - EAST=float(EAST) - NORTH=float(NORTH) - return WEST,SOUTH,EAST,NORTH - - -def write_demrsc_file(FILE,Corner_LON,Corner_LAT,X_STEP,Y_STEP,WIDTH,LENGTH): - f = open(FILE,'w') - f.write('DATE12 111111-222222\n') - f.write('FILE_LENGTH ' + str(int(LENGTH)) + '\n') - f.write('FILE_TYPE .dem\n') - f.write('PROCESSOR roipac\n') - f.write('PROJECTION LATLON\n') - f.write('RLOOKS 1\n') - f.write('WIDTH ' + str(int(WIDTH)) + '\n') - f.write('XMAX ' + str(int(int(WIDTH)-1)) + '\n') - f.write('XMIN 0\n') - f.write('X_FIRST ' + str(float(Corner_LON)) + '\n') - f.write('X_STEP ' + str(float(X_STEP)) + '\n') - f.write('X_UNIT degrees\n') - f.write('YMAX ' + str(int(int(LENGTH)-1)) + '\n') - f.write('YMIN 0\n') - f.write('Y_FIRST ' + str(float(Corner_LAT)) + '\n') - f.write('Y_STEP ' + str(float(Y_STEP)) + '\n') - f.write('Y_UNIT degrees\n') - f.write('Z_OFFSET 0\n') - f.write('Z_SCALE 1\n') - f.close - - -def write_dempar_file(FILE,Corner_LON,Corner_LAT,X_STEP,Y_STEP,WIDTH,LENGTH,DATA_FORMAT): - DEM_TYPE = 'SRTM1' - Proj = 'EQA' - f=open(FILE,'w') - f.write("Gamma DIFF&GEO DEM/MAP parameter file\n") - f.write("title:\tIMPORTED DEM FROM %s\n" % DEM_TYPE) # SRTM1 (30m) or SRTM3 (90m) - f.write("DEM_projection: %s\n" % Proj) # Projection should be checked. - f.write("data_format: %s\n" % DATA_FORMAT) # INTEGER*2 OR REAL*4 should be modified - f.write("DEM_hgt_offset: 0.00000\n") - f.write("DEM_scale: 1.00000\n") - f.write("width: %s\n" % WIDTH) - f.write("nlines: %s\n" % LENGTH) - f.write("corner_lat: %s decimal degrees\n" % Corner_LAT) - f.write("corner_lon: %s decimal degrees\n" % Corner_LON) - f.write("post_lat: %s decimal degrees\n" % Y_STEP) - f.write("post_lon: %s decimal degrees\n" % X_STEP) - f.write("\n") - f.write("ellipsoid_name: WGS 84\n") - f.write("ellipsoid_ra: 6378137.000 m\n") - f.write("ellipsoid_reciprocal_flattening: 298.2572236\n") - f.write("\n") - f.write("datum_name: WGS 1984\n") - f.write("datum_shift_dx: 0.000 m\n") - f.write("datum_shift_dy: 0.000 m\n") - f.write("datum_shift_dz: 0.000 m\n") - f.write("datum_scale_m: 0.00000e+00\n") - f.write("datum_rotation_alpha: 0.00000e+00 arc-sec\n") - f.write("datum_rotation_beta: 0.00000e+00 arc-sec\n") - f.write("datum_rotation_gamma: 0.00000e+00 arc-sec\n") - f.write("datum_country_list Global Definition, WGS84, World\n") - f.write("\n") - - f.close() - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -######################################################################### - -INTRODUCTION = ''' -############################################################################# - Copy Right(c): 2017, Yunmeng Cao [ymcmrs@gmail.com] - - Generating DEM used in interferometry both for GAMMA and ROI_PAC processor. - - 1) Available raw DEM files can be used, e.g., dem.tif, dem.grd; - 2) If no raw DEM is provided, SRTM-1 (30m) can be downloaded automatically. - - Requirement: - Python 2.7 or higher version. GDAL should be installed in your PC. -''' - -EXAMPLE = ''' - Usage: - makedem.py -r west/east/south/north -d raw_demfile -p processor -o output - makedem.py -r west/east/south/north -p processor - makedem.py -d raw_demfile --byteorder - - Examples: - makedem.py -r " -118/-116/33/34 " -p gamma -o SouthCalifornia - makedem.py -r " -118/-116/33/34 " --byteorder little - makedem.py -d dem.tif -p roi_pac --byteorder big - makedem.py -s 20101108.slc.par -p roi_pac -############################################################################## -''' - - -def cmdLineParse(): - parser = argparse.ArgumentParser(description='Generate DEM for interferometry processing.',\ - formatter_class=argparse.RawTextHelpFormatter,\ - epilog=INTRODUCTION+'\n'+EXAMPLE) - - #parser.add_argument('-r','--lalo', dest='region', nargs=4, type=float, help='lalo limit') - parser.add_argument('-r',dest = 'region',help='Research region, west/east/south/north.') - parser.add_argument('-d', dest='dem', help='Raw dem file that used for further processing.') - parser.add_argument('-s', dest='par', help='SLC parameter file of SAR image used for determining research region.') - parser.add_argument('-p', dest='processor', help='Interferometry processor. [ gamma or roi_pac ] [default: gamma]') - parser.add_argument('-o', dest='out', help='Output name of the generated DEM.') - parser.add_argument('--byteorder', dest='byteorder', help='Byteorder of the generated DEM: big or little. [default: big for gamma and little for roi_pac]') - parser.add_argument('--dir', dest='PATH', help='Processing directory for generating DEM. [default: Current directory]') - - inps = parser.parse_args() - - if not inps.region and not inps.dem and not inps.par: - parser.print_usage() - sys.exit(os.path.basename(sys.argv[0])+': error: research region, raw_demfile and SLC parameter file, at least one is needed.') - - return inps - -################################################################################ - -def main(argv): - - inps = cmdLineParse() - - if inps.par: - Par = inps.par - print "SLC_par file is provided: %s" % Par - print "SRTM1 over research region will be downloaded automatically based on %s" % Par - call_str = "SLC_corners "+ Par + " > corners.txt" - os.system(call_str) - - File = open("corners.txt","r") - InfoLine = File.readlines()[8:10] - File.close() - - MinLat = float(InfoLine[0].split(':')[1].split(' max. ')[0]) - MaxLat = float(InfoLine[0].split(':')[2]) - MinLon = float(InfoLine[1].split(':')[1].split(' max. ')[0]) - MaxLon = float(InfoLine[1].split(':')[2]) - - north = MaxLat + 1 - south = MinLat - 1 - east = MaxLon + 1 - west = MinLon - 1 - - - if inps.region: - region = inps.region - west,south,east,north = read_region(region) - - #print 'Research region: %s/%s/%s/%s' % west,south,east,north - - if inps.dem: - dem = inps.dem - print 'Raw dem file is provided: %s .' % dem - - if inps.out: Name = inps.out - else: Name = "out" - - if inps.processor: processor = inps.processor - else: processor ='gamma' - - if inps.byteorder: Byteorder = inps.byteorder - else: - if processor == 'gamma': Byteorder = 'big' - else: Byteorder ='little' - - if inps.PATH: workdir = inps.PATH - else: workdir = os.getcwd() - os.chdir(workdir) - - if not inps.dem: - - print 'Research region: %s(west) %s(south) %s(east) %s(north)' % (west,south,east,north) - print '>>> Ready to download SRTM1 dem over research region.' - call_str='wget -q -O dem.tif "http://ot-data1.sdsc.edu:9090/otr/getdem?north=%f&south=%f&east=%f&west=%f&demtype=SRTMGL1"' % (north,south,east,west) - os.system(call_str) - print '>>> DEM download finished.' - - DEM_TYPE='SRTM1' - Proj = 'EQA' - - DEM = 'dem.tif' - else: - DEM = inps.dem - - SUFIX = get_sufix(DEM) - SS ='.' + SUFIX - DTIF = DEM.replace(SS,'.tif') - - if not SUFIX == 'tif': - call_str = 'gdal_translate ' + DEM + ' -of GTiff ' + DTIF - os.system(call_str) - - - DEM = DTIF - call_str = 'gdalinfo ' + DEM + ' >ttt' - os.system(call_str) - - f = open('ttt') - for line in f: - if 'Origin =' in line: - STR1 = line - AA = STR1.split('Origin =')[1] - Corner_LON = AA.split('(')[1].split(',')[0] - Corner_LAT = AA.split('(')[1].split(',')[1].split(')')[0] - elif 'Pixel Size ' in line: - STR2 = line - AA = STR2.split('Pixel Size =')[1] - Post_LON = AA.split('(')[1].split(',')[0] - Post_LAT = AA.split('(')[1].split(',')[1].split(')')[0] - - elif 'Size is' in line: - STR3 = line - AA =STR3.split('Size is')[1] - WIDTH = AA.split(',')[0] - FILE_LENGTH = AA.split(',')[1] - f.close() - - dem_data = io.imread(DEM) - if dem_data.dtype=='float32': - DATA_FORMAT='REAL*4' - else: - DATA_FORMAT='INTEGER*2' - - - if not sys.byteorder == Byteorder: - dem_data.byteswap(True) - - if processor =='gamma': - DEMDATA = Name + '.dem' - DEMPAR = Name + '.dem.par' - elif processor =='roi_pac': - DEMDATA = Name + '.dem' - DEMPAR = Name + '.dem.rsc' - - dem_data.tofile(DEMDATA) - - if processor =='gamma': - write_dempar_file(DEMPAR,Corner_LON,Corner_LAT,Post_LON,Post_LAT,WIDTH,FILE_LENGTH,DATA_FORMAT) - elif processor =='roi_pac': - write_demrsc_file(DEMPAR,Corner_LON,Corner_LAT,Post_LON,Post_LAT,WIDTH,FILE_LENGTH) - - BB =Byteorder + ' endian' - print '' - print '%s %s and %s are generated.' % (BB,DEMDATA,DEMPAR) - print 'Congratulations! Done!' - #print "Generating %s processor %s and %s is done!" % (processor,DEMDATA,DEMPAR) - sys.exit(1) - - -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/pyint/process_tsifg.py.bak b/pyint/process_tsifg.py.bak deleted file mode 100755 index 2e71d77..0000000 --- a/pyint/process_tsifg.py.bak +++ /dev/null @@ -1,148 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_coreg_all(projectName,master,slavelist,workdir): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - run_coreg_all = projectDir + "/run_coreg_all" - f_coreg = open(run_coreg_all,'w') - - for kk in range(len(slavelist)): - str_coreg = "GenOff_Gamma.py " + projectName + ' ' + master + ' ' + slavelist[kk] + ' ' + workdir + '\n' - f_coreg.write(str_coreg) - f_coreg.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Process time series of interferograms from downloading data or SLC images. - - usage: - - process_tsifg.py projectName - - e.g. process_tsifg.py PacayaT163TsxHhA - process_tsifg.py PacayaT163S1A - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - if 'S1' in projectName: - call_str='process_tsifg_sen.py ' + projectName - else: - call_str='process_tsifg_gamma.py ' + projectName - - os.system(call_str) - - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - diff --git a/pyint/process_tsifg_gamma.py.bak b/pyint/process_tsifg_gamma.py.bak deleted file mode 100755 index e5c1078..0000000 --- a/pyint/process_tsifg_gamma.py.bak +++ /dev/null @@ -1,263 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_coreg_all(projectName,master,slavelist,workdir): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - run_coreg_all = projectDir + "/run_coreg_all" - f_coreg = open(run_coreg_all,'w') - - for kk in range(len(slavelist)): - str_coreg = "GenOff_Gamma.py " + projectName + ' ' + master + ' ' + slavelist[kk] + ' ' + workdir + '\n' - f_coreg.write(str_coreg) - f_coreg.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Process time series of interferograms from downloading data or SLC images. - - usage: - - process_tsifg_gamma.py projectName - - e.g. process_tsifg_gamma.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - DEMDIR = os.getenv('DEMDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - - if not os.path.isdir(rslcDir): - call_str = 'mkdir ' + rslcDir - os.system(call_str) - - if not os.path.isdir(processDir): - call_str = 'mkdir ' + processDir - os.system(call_str) - - templateContents = read_template(templateFile) - if 'memory_Ifg' in templateContents : memory_Ifg = templateContents['memory_Ifg'] - else: memory_Ifg = '3700' - if 'walltime_Ifg' in templateContents : walltime_Ifg = templateContents['walltime_Ifg'] - else: walltime_Ifg = '1:00' - - - if 'Coreg_all' in templateContents : Coreg_all = templateContents['Coreg_all'] - else: Coreg_all = '1' - - if 'Select_pairs' in templateContents : Select_pairs = templateContents['Select_pairs'] - else: Select_pairs = '1' - - if 'GenRdcDem_Rslc_all' in templateContents : GenRdcDem_Rslc_all = templateContents['GenRdcDem_Rslc_all'] - else: GenRdcDem_Rslc_all = '1' - -########################## Check DEM ############################################### - - if 'DEM' in templateContents : - DEM = templateContents['DEM'] - if not os.path.isfile(DEM): - print 'Provided DEM is not available, a new DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - else: - print 'DEM is not provided in the template file, a DEM based on SRTM-1 will be generated.' - call_str = 'Makedem_PyInt.py ' + projectName + ' gamma' - os.system(call_str) - - call_str = 'echo DEM = ' + DEMDIR + '/' + projectName + '/' + projectName +'.dem >> ' + templateFile - os.system(call_str) - - - ListSLC = os.listdir(slcDir) - Datelist = [] - for kk in range(len(ListSLC)): - if ( is_number(ListSLC[kk]) and len(ListSLC[kk])==6 ): - DD=ListSLC[kk] - Year=int(DD[0:2]) - Month = int(DD[2:4]) - Day = int(DD[4:6]) - if ( 0 < Year < 20 and 0 < Month < 13 and 0 < Day < 32 ): - Datelist.append(ListSLC[kk]) - - - if 'masterDate' in templateContents : - masterDate = templateContents['masterDate'] - if masterDate in Datelist: - print "masterDate: %s" % masterDate - else: - print "The selected masterdate %s is not in the date list!! " % masterDate - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - else: - print "The first date is chosen as the master date: %s" % str(Datelist[0]) - masterDate = Datelist[0] - Str = 'masterDate = %s \n' %masterDate - write_template(templateFile, Str) - - rlks = templateContents['Range_Looks'] - azlks = templateContents['Azimuth_Looks'] - - masterRdcDEM = scratchDir + '/' + projectName + "/PROCESS/DEM/sim_" + masterDate + "_" + rlks + "rlks.rdc.dem" - if not os.path.isfile(masterRdcDEM): - call_str = 'Generate_RdcDEM_Gamma.py ' + projectName + ' ' + masterDate - os.system(call_str) - - - - if Coreg_all== '1': - call_str = 'COREG_ALL_Gamma.py ' + projectName - os.system(call_str) - - if GenRdcDem_Rslc_all =='1': - call_str = 'Generate_RdcDEM_Rslc_ALL.py ' + projectName - os.system(call_str) -################################################################################# - - if Select_pairs =='1': - call_str = 'SelectPairs_Gamma.py ' + projectName - os.system(call_str) - - IFGLIST = glob.glob(processDir+'/IFG_' +projectName + '_*') - - run_slc2ifg_gamma = processDir+'/run_slc2ifg_gamma' - if os.path.isfile(run_slc2ifg_gamma): - os.remove(run_slc2ifg_gamma) - - for kk in IFGLIST: - call_str = 'echo SLC2Ifg_Gamma.py ' + os.path.basename(kk) + ' >>' + run_slc2ifg_gamma - os.system(call_str) - - - call_str='$INT_SCR/createBatch.pl ' + run_slc2ifg_gamma + ' memory=' + memory_Ifg + ' walltime=' + walltime_Ifg - os.system(call_str) - - print "Time series interferograms processing is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - - diff --git a/pyint/process_tsifg_sen.py.bak b/pyint/process_tsifg_sen.py.bak deleted file mode 100755 index f1b0d86..0000000 --- a/pyint/process_tsifg_sen.py.bak +++ /dev/null @@ -1,224 +0,0 @@ -#! /usr/bin/env python -################################################################# -### This program is part of PyINT v1.0 ### -### Copy Right (c): 2017, Yunmeng Cao ### -### Author: Yunmeng Cao ### -### Email : ymcmrs@gmail.com ### -### Univ. : Central South University & University of Miami ### -################################################################# - -import numpy as np -import os -import sys -import subprocess -import getopt -import time -import glob - -def check_variable_name(path): - s=path.split("/")[0] - if len(s)>0 and s[0]=="$": - p0=os.getenv(s[1:]) - path=path.replace(path.split("/")[0],p0) - return path - -def read_template(File, delimiter='='): - '''Reads the template file into a python dictionary structure. - Input : string, full path to the template file - Output: dictionary, pysar template content - Example: - tmpl = read_template(KyushuT424F610_640AlosA.template) - tmpl = read_template(R1_54014_ST5_L0_F898.000.pi, ':') - ''' - template_dict = {} - for line in open(File): - line = line.strip() - c = [i.strip() for i in line.split(delimiter, 1)] #split on the 1st occurrence of delimiter - if len(c) < 2 or line.startswith('%') or line.startswith('#'): - next #ignore commented lines or those without variables - else: - atrName = c[0] - atrValue = str.replace(c[1],'\n','').split("#")[0].strip() - atrValue = check_variable_name(atrValue) - template_dict[atrName] = atrValue - return template_dict - -def is_number(s): - try: - int(s) - return True - except ValueError: - return False - - -def ras2jpg(input, strTitle): - call_str = "convert " + input + ".ras " + input + ".jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 250 " + input + ".thumb.jpg" - os.system(call_str) - call_str = "convert " + input + ".jpg -resize 500 " + input + ".bthumb.jpg" - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".thumb.jpg 14 " + strTitle - os.system(call_str) - call_str = "$INT_SCR/addtitle2jpg.pl " + input + ".bthumb.jpg 24 " + strTitle - os.system(call_str) - -def UseGamma(inFile, task, keyword): - if task == "read": - f = open(inFile, "r") - while 1: - line = f.readline() - if not line: break - if line.count(keyword) == 1: - strtemp = line.split(":") - value = strtemp[1].strip() - return value - print "Keyword " + keyword + " doesn't exist in " + inFile - f.close() - -def write_template(File, Str): - f = open(File,'a') - f.write(Str) - f.close() - -def write_run_coreg_all(projectName,master,slavelist,workdir): - scratchDir = os.getenv('SCRATCHDIR') - projectDir = scratchDir + '/' + projectName - run_coreg_all = projectDir + "/run_coreg_all" - f_coreg = open(run_coreg_all,'w') - - for kk in range(len(slavelist)): - str_coreg = "GenOff_Gamma.py " + projectName + ' ' + master + ' ' + slavelist[kk] + ' ' + workdir + '\n' - f_coreg.write(str_coreg) - f_coreg.close() - - -def usage(): - print ''' -****************************************************************************************************** - - Processing time series Sentinel-1 datasets. - - usage: - - process_tsifg_sen.py projectName - - e.g. process_tsifg_sen.py PacayaT163TsxHhA - -******************************************************************************************************* - ''' - -def main(argv): - - if len(sys.argv)==2: - if argv[0] in ['-h','--help']: usage(); sys.exit(1) - else: projectName=sys.argv[1] - else: - usage();sys.exit(1) - - - scratchDir = os.getenv('SCRATCHDIR') - templateDir = os.getenv('TEMPLATEDIR') - templateFile = templateDir + "/" + projectName + ".template" - - projectDir = scratchDir + '/' + projectName - processDir = scratchDir + '/' + projectName + "/PROCESS" - slcDir = scratchDir + '/' + projectName + "/SLC" - rslcDir = scratchDir + '/' + projectName + "/RSLC" - - - - templateContents = read_template(templateFile) - if 'memory_Ifg' in templateContents : memory_Ifg = templateContents['memory_Ifg'] - else: memory_Ifg = '3700' - if 'walltime_Ifg' in templateContents : walltime_Ifg = templateContents['walltime_Ifg'] - else: walltime_Ifg = '1:00' - - if 'DOWNLOAD' in templateContents : DOWNLOAD = templateContents['DOWNLOAD'] - else: DOWNLOAD = '1' - - if 'DOWN2SLC' in templateContents : DOWN2SLC = templateContents['DOWN2SLC'] - else: DOWN2SLC = '1' - - if 'EXTRACT_BURST' in templateContents : EXTRACT_BURST = templateContents['EXTRACT_BURST'] - else: EXTRACT_BURST = '1' - - if 'COREG_ALL' in templateContents : COREG_ALL = templateContents['COREG_ALL'] - else: COREG_ALL = '1' - - if 'GEN_DEM_ALL' in templateContents : GEN_DEM_ALL = templateContents['GEN_DEM_ALL'] - else: GEN_DEM_ALL = '1' - - if 'Gen_IFG_DIR' in templateContents : Gen_IFG_DIR= templateContents['Gen_IFG_DIR'] - else: Gen_IFG_DIR = '1' - - if 'SLC2IFG' in templateContents : SLC2IFG = templateContents['SLC2IFG'] - else: SLC2IFG = '1' - - if 'Load_Data' in templateContents : Load_Data = templateContents['Load_Data'] - else: Load_Data = '1' - - - if DOWNLOAD == '1': - call_str = 'DownloadSen.py ' + projectName - os.system(call_str) - - - if DOWN2SLC=='1': - call_str = 'Down2SLC_Sen_All.py ' + projectName - os.system(call_str) - - call_str = 'Sen_Orbit_Cor_all.py ' + projectName - os.system(call_str) - - if EXTRACT_BURST =='1': - call_str = 'Check_Common_Burst_All.py ' + projectName - os.system(call_str) - - call_str = 'Extract_Burst_Slave_All.py ' + projectName - os.system(call_str) - - if COREG_ALL == '1': - call_str = 'COREG_ALL_Sen_Gamma.py ' + projectName - os.system(call_str) - - if GEN_DEM_ALL =='1': - call_str = 'Generate_RdcDEM_Sen_ALL.py ' + projectName - os.system(call_str) - - if Gen_IFG_DIR=='1': - call_str = 'SelectPairs_Gamma.py ' + projectName - os.system(call_str) - - if SLC2IFG=='1': - call_str='$INT_SCR/createBatch.pl ' + processDir+'/run_slc2ifg_gamma memory=' + memory_Ifg + ' walltime=' + walltime_Ifg - os.system(call_str) - - if Load_Data=='1': - call_str = 'load_data_gamma.py ' + projectName - os.system(call_str) - - print "Time series interferograms processing is done! " - sys.exit(1) - -if __name__ == '__main__': - main(sys.argv[:]) - - - - - - - - - - - - - - - - - - -