Example #1
0
def main(argv):

    inps = cmdLineParse()
    Mdate = inps.Mdate
    Sdate = inps.Sdate

    projectName = inps.projectName
    Sdate = inps.Sdate
    Mdate = inps.Mdate

    scratchDir = os.getenv('SCRATCHDIR')
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"
    templateDict = ut.update_template(templateFile)
    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']

    processDir = scratchDir + '/' + projectName + "/PROCESS"
    slcDir = scratchDir + '/' + projectName + "/SLC"
    rslcDir = scratchDir + '/' + projectName + '/RSLC'
    ifgDir = scratchDir + '/' + projectName + '/ifgrams'

    Pair = Mdate + '-' + Sdate
    workDir = ifgDir + '/' + Pair

    ################ copy file for parallel processing ###############
    Mamp0 = rslcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar0 = rslcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    Samp0 = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar0 = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.par'

    Mamp = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    Samp = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp.par'

    ut.copy_file(Mamp0, Mamp)
    ut.copy_file(Samp0, Samp)
    ut.copy_file(MampPar0, MampPar)
    ut.copy_file(SampPar0, SampPar)
    ###############################################################

    nWidth = ut.read_gamma_par(MampPar, 'read', 'range_samples')
    nLine = ut.read_gamma_par(MampPar, 'read', 'azimuth_lines')

    CORMASK = workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt.cor'
    WRAPlks = workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt'
    UNWlks = workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt.unw'

    CORMASKbmp = CORMASK.replace('.diff_filt.cor', '.diff_filt.cor_mask.bmp')

    if os.path.isfile(CORMASKbmp):
        os.remove(CORMASKbmp)

    call_str = 'rascc_mask ' + CORMASK + ' ' + Mamp + ' ' + nWidth + ' 1 1 0 1 1 ' + templateDict[
        'unwrapThreshold'] + ' 0.0 0.1 0.9 1. .35 1 ' + CORMASKbmp  # based on int coherence
    os.system(call_str)

    call_str = 'mcf ' + WRAPlks + ' ' + CORMASK + ' ' + CORMASKbmp + ' ' + UNWlks + ' ' + nWidth + ' ' + templateDict[
        'mcf_triangular'] + ' - - - - ' + templateDict[
            'unwrap_patr'] + ' ' + templateDict['unwrap_pataz']
    os.system(call_str)

    call_str = 'rasrmg ' + UNWlks + ' ' + Mamp + ' ' + nWidth + ' - - - - - - - - - - '
    os.system(call_str)

    os.remove(Mamp)
    os.remove(Samp)
    #os.remove(MampPar)
    #os.remove(SampPar)
    print("Uwrapping interferometric phase is done!")
    sys.exit(1)
Example #2
0
def main(argv):

    inps = cmdLineParse()
    projectName = inps.projectName
    Sdate = inps.sdate

    scratchDir = os.getenv('SCRATCHDIR')
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"

    slcDir = scratchDir + '/' + projectName + "/SLC"
    rslcDir = scratchDir + '/' + projectName + "/RSLC"
    if not os.path.isdir(rslcDir): os.mkdir(rslcDir)
    #workDir    = processDir + '/' + igramDir
    workDir = rslcDir + '/' + Sdate
    if not os.path.isdir(workDir): os.mkdir(workDir)

    templateDict = ut.update_template(templateFile)
    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']
    Mdate = templateDict['masterDate']

    demDir = scratchDir + '/' + projectName + '/DEM'

    #  Definition of file
    MslcDir = slcDir + '/' + Mdate
    SslcDir = slcDir + '/' + Sdate
    Samp = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.par'
    Sampbmp = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.bmp'

    Mslc = slcDir + '/' + Mdate + '/' + Mdate + '.slc'
    Mslcpar = slcDir + '/' + Mdate + '/' + Mdate + '.slc.par'
    Mamp = slcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar = slcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    Mampbmp = slcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.bmp'

    SLC1_INF_tab0 = MslcDir + '/' + Mdate + '_SLC_Tab'
    SLC2_INF_tab = SslcDir + '/' + Sdate + '_SLC_Tab'
    RSLC_tab = SslcDir + '/' + Sdate + '_RSLC_Tab'
    SLC1_INF_tab = SslcDir + '/' + Mdate + '_SLC_Tab_coreg'

    HGTSIM = demDir + '/' + Mdate + '_' + rlks + 'rlks.rdc.dem'
    if not os.path.isfile(HGTSIM):
        call_str = 'generate_rdc_dem.py ' + projectName
        os.system(call_str)

    ############## copy master files into slave folder for parallel process ###########

    #if not templateDict['coreg_all_parallel'] == '1':
    #    Mslc = slcDir  + '/' + Sdate + '/' + Mdate + '.slc'
    #    Mslcpar = slcDir  + '/' + Sdate + '/' + Mdate + '.slc.par'
    #    Mamp = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    #    MampPar = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    #    HGTSIM      = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.rdc.dem'

    #else:

    #    Mslc = Mslc0
    #    Mslcpar = Mslcpar0
    #    Mamp = Mamp0
    #    MampPar = MampPar0
    #    HGTSIM  = HGTSIM0

    #Mslc = slcDir  + '/' + Sdate + '/' + Mdate + '.slc'
    #Mslcpar = slcDir  + '/' + Sdate + '/' + Mdate + '.slc.par'
    #Mamp = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    #MampPar = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    #HGTSIM      = slcDir  + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.rdc.dem'
    SLC1_INF_tab1 = SslcDir + '/' + Mdate + '_SLC_Tab'
    ut.copy_file(SLC1_INF_tab0, SLC1_INF_tab1)
    ##############################################################################
    with open(SLC1_INF_tab1, "r") as f:
        lines = f.readlines()

    with open(SLC1_INF_tab, "w") as fw:
        lines_coreg = []
        for k0 in lines:
            k00 = k0.replace(MslcDir, SslcDir)
            lines_coreg.append(k00)
            fw.write(k00)

    S_IW = ut.read_txt2array(SLC1_INF_tab1)
    S_IW = S_IW.flatten()
    #M_IW = ut.read_txt2array(SLC1_INF_tab1)
    #M_IW = M_IW.flatten()
    #S_IW = ut.read_txt2array(SLC1_INF_tab)
    #S_IW = S_IW.flatten()

    #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)
    #TEST = workDir + '/' + Sdate +'_' + rlks + 'rlks.amp.par'
    TEST = workDir + '/' + Sdate + '.rslc.par'

    k0 = 0
    if os.path.isfile(TEST):
        if os.path.getsize(TEST) > 0:
            k0 = 1

    if k0 == 0:
        if not Mdate == Sdate:
            call_str = 'S1_coreg_TOPS ' + SLC1_INF_tab1 + ' ' + Mdate + ' ' + SLC2_INF_tab + ' ' + Sdate + ' ' + RSLC_tab + ' ' + HGTSIM + ' ' + rlks + ' ' + azlks + ' - - 0.6 0.01 1.2 1'
            os.system(call_str)

            #### clean large file ####
            mslc = workDir + '/' + Mdate + '.slc'
            mrslc = workDir + '/' + Mdate + '.rslc'
            sslc = workDir + '/' + Sdate + '.slc'
            srslc = workDir + '/' + Sdate + '.rslc'
            srslcPar = workDir + '/' + Sdate + '.rslc.par'

            call_str = 'multi_look ' + srslc + ' ' + srslcPar + ' ' + Samp + ' ' + SampPar + ' ' + rlks + ' ' + azlks
            os.system(call_str)
            nWIDTH = ut.read_gamma_par(SampPar, 'read', 'range_samples')
            if os.path.isfile(mslc): os.remove(mslc)
            if os.path.isfile(mrslc): os.remove(mrslc)
            if os.path.isfile(sslc): os.remove(sslc)

            call_str = 'raspwr ' + Samp + ' ' + nWIDTH
            os.system(call_str)

            #call_str = 'rm *mli*'
            #os.system(call_str)

            #call_str = 'rm *IW*'
            #os.system(call_str)

            #call_str = 'rm *off*'
            #os.system(call_str)

            #call_str = 'rm *diff'
            #os.system(call_str)

            #call_str = 'rm *diff_par*'
            #os.system(call_str)

            #call_str = 'rm ' + Mdate + '.*'
            #os.system(call_str)

        else:
            call_str = 'cp ' + Mslc + ' ' + workDir + '/' + Mdate + '.rslc'
            os.system(call_str)

            call_str = 'cp ' + Mslcpar + ' ' + workDir + '/' + Mdate + '.rslc.par'
            os.system(call_str)

            call_str = 'cp ' + Mamp + ' ' + workDir + '/' + Mdate + '_' + rlks + 'rlks.amp'
            os.system(call_str)

            call_str = 'cp ' + MampPar + ' ' + workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
            os.system(call_str)

            ut.copy_file(Mampbmp, Sampbmp)

    ################   clean redundant files #############

    #if not Mdate ==Sdate:

    #    if not templateDict['diff_all_parallel'] == '1':
    #        for i in range(len(S_IW)):
    #            if os.path.isfile(S_IW[i]):
    #                os.remove(S_IW[i])
    #        if os.path.isfile(Mslc): os.remove(Mslc)
    #        if os.path.isfile(Mslcpar): os.remove(Mslcpar)
    #        if os.path.isfile(Mamp): os.remove(Mamp)
    #        if os.path.isfile(HGTSIM): os.remove(HGTSIM)

    print("Coregister TOP SLC image to the reference TOPS image is done !!")
    sys.exit(1)
Example #3
0
def main(argv):
    
    inps = cmdLineParse() 
    projectName = inps.projectName
    Pair = inps.pair
    
    scratchDir = os.getenv('SCRATCHDIR')
    ifgDir = scratchDir + '/' + projectName + "/ifgrams"
    demDir = scratchDir + '/' + projectName + "/DEM"
    workDir = ifgDir + '/' + Pair

    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"
    templateDict=ut.update_template(templateFile)
    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']
    masterDate = templateDict['masterDate']
    
    slcDir     = scratchDir + '/' + projectName + "/SLC" 
    rslcDir    = scratchDir + '/' + projectName + "/RSLC"
    demDir     = scratchDir + '/' + projectName + '/DEM'
    
    ######### copy common file for parallel processing #############
    
    Mamp0    = rslcDir + '/' + masterDate + '/' + masterDate + '_' + rlks + 'rlks.amp'
    MampPar0 = rslcDir + '/' + masterDate + '/' + masterDate + '_' + rlks + 'rlks.amp.par'
    
    Mamp     = workDir + '/' + masterDate + '_' + rlks + 'rlks.amp'
    MampPar  = workDir + '/' + masterDate + '_' + rlks + 'rlks.amp.par'
    
    ut.copy_file(Mamp0,Mamp)
    ut.copy_file(MampPar0,MampPar)
    
    #################################################################
    UNWIFG     =  workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt.unw'
    DIFFIFG    =  workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt'
    CORIFG     =  workDir + '/' + Pair + '_' + rlks + 'rlks.diff_filt.cor'
    
    GeoMamp    =  workDir + '/geo_' + masterDate + '_' + rlks + 'rlks.amp'
    GeoCOR    =  workDir + '/geo_' + masterDate + '_' + rlks + 'rlks.diff_filt.cor'
    GeoUNW     =  workDir + '/geo_' + Pair + '_' + rlks + 'rlks.diff_filt.unw'
    GeoDIFF    =  workDir + '/geo_' + Pair + '_' + rlks + 'rlks.diff_filt'
    
    UTMTORDC0 = demDir + '/' + masterDate + '_' + rlks + 'rlks.UTM_TO_RDC'
    UTMDEMpar0 = demDir + '/' + masterDate + '_' + rlks + 'rlks.utm.dem.par'
    
    UTMTORDC = workDir + '/' + masterDate + '_' + rlks + 'rlks.UTM_TO_RDC'
    UTMDEMpar = workDir + '/' + masterDate + '_' + rlks + 'rlks.utm.dem.par'
    
    ut.copy_file(UTMTORDC0,UTMTORDC)
    ut.copy_file(UTMDEMpar0,UTMDEMpar)

    nWidth = ut.read_gamma_par(MampPar, 'read', 'range_samples')
    nWidthUTMDEM = ut.read_gamma_par(UTMDEMpar, 'read', 'width')
    nLineUTMDEM = ut.read_gamma_par(UTMDEMpar, 'read', 'nlines')
    print(nWidth)
    
    if 'geo_interp' in templateDict: geo_interp = templateDict['geo_interp']
    else: geo_interp = '0'
    
    geocode(Mamp, GeoMamp, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM, geo_interp)
    geocode(CORIFG, GeoCOR, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM, geo_interp)
    geocode(DIFFIFG, GeoDIFF, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM, geo_interp)
    geocode(UNWIFG, GeoUNW, UTMTORDC, nWidth, nWidthUTMDEM, nLineUTMDEM, geo_interp)

    call_str = 'rasmph_pwr ' + GeoDIFF + ' ' + GeoMamp + ' ' + nWidthUTMDEM + ' - - - - - - - - - ' + GeoCOR + ' - - ' 
    os.system(call_str)

    call_str = 'raspwr ' + GeoMamp + ' ' + nWidthUTMDEM + ' - - - - - - - - - - ' 
    os.system(call_str)
    
    call_str = 'rasrmg ' + GeoUNW + ' ' + GeoMamp + ' ' + nWidthUTMDEM + ' - - - - - - - - - - - '  + GeoCOR + ' - - ' 
    os.system(call_str)
    
    os.remove(Mamp)
    #os.remove(MampPar)
    
    os.remove(UTMTORDC)
    os.remove(UTMDEMpar)
    
    print("Geocoding is done!") 
    sys.exit(1)
Example #4
0
def main(argv):

    inps = cmdLineParse()
    projectName = inps.projectName
    Sdate = inps.sdate

    scratchDir = os.getenv('SCRATCHDIR')
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"

    slcDir = scratchDir + '/' + projectName + "/SLC"
    rslcDir = scratchDir + '/' + projectName + "/RSLC"
    if not os.path.isdir(rslcDir): os.mkdir(rslcDir)
    #workDir    = processDir + '/' + igramDir
    workDir = rslcDir + '/' + Sdate
    if not os.path.isdir(workDir): os.mkdir(workDir)

    templateDict = ut.update_template(templateFile)
    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']
    Mdate = templateDict['masterDate']

    demDir = scratchDir + '/' + projectName + '/DEM'

    SslcDir = slcDir + '/' + Sdate
    Samp = slcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar = slcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.par'
    Sramp = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SrampPar = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.par'

    Sslc = slcDir + '/' + Sdate + '/' + Sdate + '.slc'
    SslcPar = slcDir + '/' + Sdate + '/' + Sdate + '.slc.par'

    SrslcDir = rslcDir + "/" + Sdate

    Srslc = rslcDir + "/" + Sdate + ".rslc"
    SrslcPar = rslcDir + "/" + Sdate + ".rslc.par"

    Srslc0 = rslcDir + "/" + Sdate + ".rslc0"
    SrslcPar0 = rslcDir + "/" + Sdate + ".rslc0.par"

    #####################################################
    ## copy all of the master files into slave folder for parallel processing
    remove_file = []
    Mslc0 = slcDir + '/' + Mdate + '/' + Mdate + '.slc'
    MslcPar0 = slcDir + '/' + Mdate + '/' + Mdate + '.slc.par'
    Mamp0 = slcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar0 = slcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    HGTSIM0 = demDir + '/' + Mdate + '_' + rlks + 'rlks.rdc.dem'
    if not os.path.isfile(HGTSIM0):
        call_str = 'generate_rdc_dem.py ' + projectName
        os.system(call_str)

    Mslc = slcDir + '/' + Sdate + '/' + Mdate + '.slc'
    MslcPar = slcDir + '/' + Sdate + '/' + Mdate + '.slc.par'
    Mamp = slcDir + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar = slcDir + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    HGTSIM = slcDir + '/' + Sdate + '/' + Mdate + '_' + rlks + 'rlks.rdc.dem'

    ut.copy_file(HGTSIM0, HGTSIM)
    ut.copy_file(Mslc0, Mslc)
    ut.copy_file(MslcPar0, MslcPar)
    ut.copy_file(Mamp0, Mamp)
    ut.copy_file(MampPar0, MampPar)

    #######################################################
    #   define process files #
    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"
    ##############################################

    call_str = "rdc_trans " + MampPar + " " + HGTSIM + " " + SampPar + " " + lt0
    os.system(call_str)

    width_Mamp = ut.read_gamma_par(MampPar, 'read', 'range_samples')
    width_Samp = ut.read_gamma_par(SampPar, 'read', 'range_samples')
    line_Samp = ut.read_gamma_par(SampPar, 'read', 'azimuth_lines')

    call_str = "geocode " + lt0 + " " + MamprlksImg + " " + width_Mamp + " " + mli0 + " " + width_Samp + " " + line_Samp + " 2 0"
    os.system(call_str)

    call_str = "create_diff_par " + SampPar + " - " + diff0 + " 1 0"
    os.system(call_str)

    call_str = "init_offsetm " + mli0 + " " + Samp + " " + diff0 + " 1 1"
    os.system(call_str)

    call_str = "offset_pwrm " + mli0 + " " + Samp + " " + diff0 + " " + offs0 + " " + snr0 + " 256 256 " + offsets0 + " 2 32 32"
    os.system(call_str)

    call_str = "offset_fitm " + offs0 + " " + snr0 + " " + diff0 + " " + coffs0 + " " + coffsets0 + " - 4"
    os.system(call_str)

    call_str = "gc_map_fine " + lt0 + " " + width_Mamp + " " + diff0 + " " + lt1
    os.system(call_str)

    call_str = "SLC_interp_lt " + Sslc + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MampPar + " " + SampPar + " - " + Srslc0 + " " + Srslc0Par
    os.system(call_str)

    # further refinement processing for resampled SLC

    call_str = "create_offset " + MslcPar + " " + Srslc0Par + " " + off + " 1 - - 0"
    os.system(call_str)

    #call_str = "offset_pwr " + MslcImg + " " + Srslc0Img + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " 128 128 " + offsets + " 2 32 64"
    #os.system(call_str)

    #call_str = "offset_fit "  + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3"
    #os.system(call_str)

    call_str = "offset_pwr " + Mslc + " " + Srslc0 + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + templateDict[
        'rwin4cor'] + " " + templateDict[
            'azwin4cor'] + " " + offsets + " 2 " + templateDict[
                'rsample4cor'] + " " + templateDict['azsample4cor']
    os.system(call_str)

    call_str = "offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3"
    os.system(call_str)

    rfwin4cor = str(int(1 / 2 * int(templateDict['rwin4cor'])))
    azfwin4cor = str(int(1 / 2 * int(templateDict['azwin4cor'])))

    rfsample4cor = str(2 * int(templateDict['rsample4cor']))
    azfsample4cor = str(2 * int(templateDict['azsample4cor']))

    call_str = "offset_pwr " + MslcImg + " " + Srslc0 + " " + MslcPar + " " + Srslc0Par + " " + off + " " + offs + " " + snr + " " + rfwin4cor + " " + azfwin4cor + " " + offsets + " 2 " + rfsample4cor + " " + azfsample4cor
    os.system(call_str)

    call_str = "offset_fit " + offs + " " + snr + " " + off + " " + coffs + " " + coffsets + " - 3 >" + OFFSTD
    os.system(call_str)

    ############################################     Resampling     ############################################

    call_str = "SLC_interp_lt " + Sslc + " " + MslcPar + " " + SslcPar + " " + lt1 + " " + MampPar + " " + SampPar + " " + off + " " + Srslc + " " + SrslcPar
    os.system(call_str)

    call_str = 'multi_look ' + Srslc + ' ' + SrslcPar + ' ' + Sramp + ' ' + SrampPar + ' ' + rlks + ' ' + azlks
    os.system(call_str)

    nWidth = ut.read_gamma_par(SrampPar, 'read', 'range_samples')
    call_str = 'raspwr ' + Sramp + ' ' + nWidth
    os.system(call_str)

    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(Srslc0)
    os.remove(Srslc0Par)

    os.remove(Mslc)
    os.remove(Mamp)
    os.remove(HGTSIM)

    print("Coregistration with DEM is done!")

    sys.exit(1)
Example #5
0
def main(argv):

    inps = cmdLineParse()
    projectName = inps.projectName
    scratchDir = os.getenv('SCRATCHDIR')
    scratchDir0 = os.getenv('SCRATCHDIR0')
    projectDir = scratchDir + '/' + projectName
    projectDir0 = scratchDir0 + '/' + projectName

    if not os.path.isdir(projectDir0):
        os.mkdir(projectDir0)

    demDir = scratchDir + '/' + projectName + '/DEM'
    rslcDir = scratchDir + '/' + projectName + '/RSLC'

    ifgDir = projectDir + '/ifgrams'
    unwFile = projectDir + '/ifgrams/*/2*rlks.diff_filt.unw'  # considering geocode unw file
    corFile = projectDir + '/ifgrams/*/2*rlks.diff_filt.cor'
    #print(unwFile)
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"
    templateDict = ut.update_template(templateFile)

    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']
    masterDate = templateDict['masterDate']
    MampPar = rslcDir + '/' + masterDate + '/' + masterDate + '_' + rlks + 'rlks.amp.par'
    date_list = ut.get_project_slcList(projectName)
    date_list = sorted(date_list)
    slc_par_list = [
        rslcDir + '/' + date0 + '/' + date0 + '.rlsc.par'
        for date0 in date_list
    ]
    ifgdir_list = glob.glob(ifgDir + '/*')
    for k0 in ifgdir_list:
        pair0 = os.path.basename(k0)
        m0 = pair0.split('-')[0]
        s0 = pair0.split('-')[1]

        workDir = k0
        mamppar0 = rslcDir + '/' + m0 + '/' + m0 + '_' + rlks + 'rlks.amp.par'
        samppar0 = rslcDir + '/' + s0 + '/' + s0 + '_' + rlks + 'rlks.amp.par'
        mrslcpar0 = rslcDir + '/' + m0 + '/' + m0 + '.rslc.par'
        srslcpar0 = rslcDir + '/' + s0 + '/' + s0 + '.rslc.par'

        mamppar = workDir + '/' + m0 + '_' + rlks + 'rlks.amp.par'
        samppar = workDir + '/' + s0 + '_' + rlks + 'rlks.amp.par'
        mrslcpar = workDir + '/' + m0 + '.rslc.par'
        srslcpar = workDir + '/' + s0 + '.rslc.par'

        ut.copy_file(mamppar0, mamppar)
        ut.copy_file(samppar0, samppar)
        ut.copy_file(mrslcpar0, mrslcpar)
        ut.copy_file(srslcpar0, srslcpar)

    #unw_list = glob.glob(ifgDir + '/*/*rlks.diff_filt.unw')
    #cor_list = glob.glob(ifgDir + '/*/*rlks.diff_filt.cor')

    dem_geo = glob.glob(demDir + '/*rlks.utm.dem')[0]
    geo_par = glob.glob(demDir + '/*rlks.utm.dem.par')[0]

    dem_rdc = glob.glob(demDir + '/*_' + rlks + 'rlks.rdc.dem')[0]
    rdc_par = glob.glob(demDir + '/*_' + rlks + 'rlks.diff_par')[0]  # diff_par
    lt = glob.glob(demDir + '/*_' + rlks + 'rlks.UTM_TO_RDC')[0]

    strPro = 'mintpy.load.processor      = gamma'
    strUNW = "mintpy.load.unwFile        = " + unwFile
    strCOR = 'mintpy.load.corFile        = ' + corFile
    strCon = 'mintpy.load.connCompFile   = auto'
    strInt = 'mintpy.load.intFile        = auto'
    strIon = 'mintpy.load.ionoFile       = auto'

    strDem = 'mintpy.load.demFile        = ' + dem_rdc
    strDemGeo = 'mintpy.load.demFile        = ' + dem_geo
    strLtY = 'mintpy.load.lookupYFile    = ' + lt
    strLtX = 'mintpy.load.lookupXFile    = ' + lt
    strInc = 'mintpy.load.incAngleFile   = auto'
    strAza = 'mintpy.load.azAngleFile    = auto'
    strSha = 'mintpy.load.shadowMaskFile = auto'
    strWat = 'mintpy.load.waterMaskFile  = auto'
    strBrp = 'mintpy.load.bperpFile      = auto'

    templateFile0 = projectDir + '/mintpy.template'

    if 'mintpy.load.processor' not in templateDict:
        write_template(strPro, templateFile0)
    if 'mintpy.load.unwFile' not in templateDict:
        write_template(strUNW, templateFile0)
    if 'mintpy.load.corFile' not in templateDict:
        write_template(strCOR, templateFile0)
    if 'mintpy.load.demFile' not in templateDict:
        write_template(strDem, templateFile0)
    if 'mintpy.load.lookupYFile' not in templateDict:
        write_template(strLtY, templateFile0)
    if 'mintpy.load.lookupXFile' not in templateDict:
        write_template(strLtX, templateFile0)

    if 'mintpy.load.connCompFile' not in templateDict:
        write_template(strCon, templateFile0)
    if 'mintpy.load.intFile' not in templateDict:
        write_template(strInt, templateFile0)
    if 'mintpy.load.ionoFile' not in templateDict:
        write_template(strIon, templateFile0)

    if 'mintpy.load.incAngleFile' not in templateDict:
        write_template(strInc, templateFile0)
    if 'mintpy.load.azAngleFile' not in templateDict:
        write_template(strAza, templateFile0)
    if 'mintpy.load.shadowMaskFile' not in templateDict:
        write_template(strSha, templateFile0)
    if 'mintpy.load.waterMaskFile' not in templateDict:
        write_template(strWat, templateFile0)
    if 'mintpy.load.bperpFile' not in templateDict:
        write_template(strBrp, templateFile0)

    os.chdir(projectDir0)
    call_str = 'load_data.py -t ' + templateFile0
    os.system(call_str)

    os.chdir(projectDir0)
    write_template(strDemGeo, templateFile0)
    call_str = 'load_data.py -t ' + templateFile0
    os.system(call_str)

    sys.exit(1)
Example #6
0
def main(argv):

    start_time = time.time()
    inps = cmdLineParse()
    Mdate = inps.Mdate
    Sdate = inps.Sdate

    projectName = inps.projectName
    scratchDir = os.getenv('SCRATCHDIR')
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"
    templateDict = ut.update_template(templateFile)
    rlks = templateDict['range_looks']
    azlks = templateDict['azimuth_looks']
    masterDate = templateDict['masterDate']

    projectDir = scratchDir + '/' + projectName
    demDir = scratchDir + '/' + projectName + '/DEM'

    slcDir = scratchDir + '/' + projectName + '/SLC'
    rslcDir = scratchDir + '/' + projectName + '/RSLC'
    ifgDir = projectDir + '/ifgrams'
    if not os.path.isdir(ifgDir): os.mkdir(ifgDir)

    Pair = Mdate + '-' + Sdate
    workDir = ifgDir + '/' + Pair
    if not os.path.isdir(workDir): os.mkdir(workDir)

    #######################################################################
    Mamp0 = rslcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar0 = rslcDir + '/' + Mdate + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    Samp0 = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar0 = rslcDir + '/' + Sdate + '/' + Sdate + '_' + rlks + 'rlks.amp.par'

    Mrslc = rslcDir + '/' + Mdate + '/' + Mdate + '.rslc'
    MrslcPar = rslcDir + '/' + Mdate + '/' + Mdate + '.rslc.par'
    Srslc = rslcDir + '/' + Sdate + '/' + Sdate + '.rslc'
    SrslcPar = rslcDir + '/' + Sdate + '/' + Sdate + '.rslc.par'

    HGT0 = demDir + '/' + masterDate + '_' + rlks + 'rlks.rdc.dem'

    MasterPar0 = rslcDir + '/' + masterDate + '/' + masterDate + '.rslc.par'

    ################# copy file for parallel processing ##########################
    Mamp = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp'
    MampPar = workDir + '/' + Mdate + '_' + rlks + 'rlks.amp.par'
    Samp = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp'
    SampPar = workDir + '/' + Sdate + '_' + rlks + 'rlks.amp.par'

    #Mrslc    =   workDir + '/' + Mdate + '.rslc'
    #MrslcPar =   workDir + '/' + Mdate + '.rslc.par'
    #Srslc    =   workDir + '/' + Sdate + '.rslc'
    #SrslcPar =   workDir + '/' + Sdate + '.rslc.par'

    HGT = workDir + '/' + masterDate + '_' + rlks + 'rlks.rdc.dem'
    MasterPar = workDir + '/' + masterDate + '.rslc.par'

    if not os.path.isfile(Mamp): ut.copy_file(Mamp0, Mamp)
    if not os.path.isfile(MampPar): ut.copy_file(MampPar0, MampPar)
    if not os.path.isfile(Samp): ut.copy_file(Samp0, Samp)
    if not os.path.isfile(SampPar): ut.copy_file(SampPar0, SampPar)

    #if not os.path.isfile(Mrslc): ut.copy_file(Mrslc0,Mrslc)
    #if not os.path.isfile(MrslcPar): ut.copy_file(MrslcPar0,MrslcPar)
    #if not os.path.isfile(Srslc):ut.copy_file(Srslc0,Srslc)
    #if not os.path.isfile(SrslcPar):ut.copy_file(SrslcPar0,SrslcPar)

    if not os.path.isfile(HGT): ut.copy_file(HGT0, HGT)
    if not os.path.isfile(MasterPar): ut.copy_file(MasterPar0, MasterPar)

    nWidth = ut.read_gamma_par(MampPar, 'read', 'range_samples')
    nLine = ut.read_gamma_par(MampPar, 'read', 'azimuth_lines')

    ###################### Output files #################################
    ionoDir = workDir + '/ionosphere'
    if not os.path.isdir(ionoDir):
        os.mkdir(ionoDir)

    workDir = ionoDir
    Mrslc_low = ionoDir + '/' + Mdate + '.low.rslc'
    MrslcPar_low = ionoDir + '/' + Mdate + '.low.rslc.par'
    Mrslc_high = ionoDir + '/' + Mdate + '.high.rslc'
    MrslcPar_high = ionoDir + '/' + Mdate + '.high.rslc.par'

    Srslc_low = ionoDir + '/' + Sdate + '.low.rslc'
    SrslcPar_low = ionoDir + '/' + Sdate + '.low.rslc.par'
    Srslc_high = ionoDir + '/' + Sdate + '.high.rslc'
    SrslcPar_high = ionoDir + '/' + Sdate + '.high.rslc.par'
    #########################################################
    TEST0 = MrslcPar_high
    k0 = 0
    if os.path.isfile(TEST0):
        if os.path.getsize(TEST0) > 0:
            k0 = 1

    TEST1 = SrslcPar_high
    k1 = 0
    if os.path.isfile(TEST1):
        if os.path.getsize(TEST1) > 0:
            k1 = 1

    if k0 == 0:
        call_str = 'bpf_ssi ' + Mrslc + ' ' + MrslcPar + ' ' + Mrslc_low + ' ' + MrslcPar_low + ' ' + Mrslc_high + ' ' + MrslcPar_high
        os.system(call_str)

    if k1 == 0:
        call_str = 'bpf_ssi ' + Srslc + ' ' + SrslcPar + ' ' + Srslc_low + ' ' + SrslcPar_low + ' ' + Srslc_high + ' ' + SrslcPar_high
        os.system(call_str)

################## interferometry #####################

    off_low = workDir + '/' + Pair + '_' + rlks + 'rlks.low.off'
    call_str = 'create_offset ' + MrslcPar_low + ' ' + SrslcPar_low + ' ' + off_low + ' 1 ' + rlks + ' ' + azlks + ' 0'
    os.system(call_str)

    sim_low_unw = workDir + '/' + Pair + '.low.sim_unw'
    call_str = 'phase_sim_orb ' + MrslcPar_low + ' ' + SrslcPar_low + ' ' + off_low + ' ' + HGT + ' ' + sim_low_unw + ' ' + MasterPar + ' - - 1 1'
    os.system(call_str)

    diff_low = workDir + '/' + Pair + '_' + rlks + 'rlks.low.diff'
    call_str = 'SLC_diff_intf ' + Mrslc_low + ' ' + Srslc_low + ' ' + MrslcPar_low + ' ' + SrslcPar_low + ' ' + off_low + ' ' + sim_low_unw + ' ' + diff_low + ' ' + rlks + ' ' + azlks + ' ' + ' 1 0 0.25'
    os.system(call_str)

    off_low = workDir + '/' + Pair + '_' + rlks + 'rlks.high.off'
    call_str = 'create_offset ' + MrslcPar_high + ' ' + SrslcPar_high + ' ' + off_high + ' 1 ' + rlks + ' ' + azlks + ' 0'
    os.system(call_str)

    sim_high_unw = workDir + '/' + Pair + '.high.sim_unw'
    call_str = 'phase_sim_orb ' + MrslcPar_high + ' ' + SrslcPar_high + ' ' + off_high + ' ' + HGT + ' ' + sim_high_unw + ' ' + MasterPar + ' - - 1 1'
    os.system(call_str)

    diff_high = workDir + '/' + Pair + '_' + rlks + 'rlks.high.diff'
    call_str = 'SLC_diff_intf ' + Mrslc_high + ' ' + Srslc_high + ' ' + MrslcPar_high + ' ' + SrslcPar_high + ' ' + off_high + ' ' + sim_high_unw + ' ' + diff_high + ' ' + rlks + ' ' + azlks + ' ' + ' 1 0 0.25'
    os.system(call_str)

    ######################################################
    hl_diff = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff'
    hl_diff_cc = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff.cc'
    hl_diff_mask = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff.cc_mask.bmp'

    hl_diff1 = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff1'
    hl_diff2 = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff2'
    hl_diff3 = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff3'
    hl_diff4 = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff4'

    hl_diff4_phase = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff4_phase'

    hl_diff_jpg = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff.jpg'

    diff_low_phase = workDir + '/' + Pair + '_' + rlks + 'rlks.low.diff_phase'
    call_str = 'cpx_to_real ' + diff_low_phase + ' ' + nWidth + ' 4'
    os.system(call_str)

    call_str = 'subtract_phase ' + diff_high + ' ' + diff_low_phase + ' ' + hl_diff + ' ' + nWidth + ' 1'
    os.system(call_str)

    call_str = 'rasmph_pwr ' + Mamp + ' ' + hl_diff + ' ' + nWidth
    #call_str = 'vismph_pwr.py ' + hl_diff + ' ' + Mamp + ' ' + nWidth + ' -f 1.0 ' + ' -z 1000 ' + ' -p ' + hl_diff_jpg
    os.system(call_str)

    #### filter

    call_str = 'adf ' + hl_diff + ' ' + hl_diff1 + ' ' + hl_diff_cc + ' ' + nWidth + ' 0.2 512 7 128'
    os.system(call_str)

    call_str = 'adf ' + hl_diff1 + ' ' + hl_diff2 + ' ' + hl_diff_cc + ' ' + nWidth + ' 0.3 256 7 64'
    os.system(call_str)

    call_str = 'adf ' + hl_diff2 + ' ' + hl_diff3 + ' ' + hl_diff_cc + ' ' + nWidth + ' 0.3 128 7 64'
    os.system(call_str)

    call_str = 'adf ' + hl_diff3 + ' ' + hl_diff4 + ' ' + hl_diff_cc + ' ' + nWidth + ' 0.3 128 7 16'
    os.system(call_str)

    # unwrawp
    call_str = 'cpx_to_real ' + hl_diff4 + ' ' + hl_diff4_phase + ' ' + nWidth + ' 4'
    os.system(call_str)

    # shift to zero
    # mask very low coherence

    call_str = 'cc_ad ' + hl_diff + ' ' + Mamp + ' ' + Samp + ' - - ' + hl_diff_cc + ' ' + nWidth + ' 3 9'
    os.system(call_str)

    call_str = 'rascc_mask ' + hl_diff_cc + ' ' + Mamp + ' ' + nWidth + ' 1 1 0 1 1 0.15 0.0 0.1 0.9 1.0 0.35 1 ' + hl_diff_mask
    os.system(call_str)

    nWidth_half = str(float(nWidth) / 2)
    image_report = workDir + '/' + Pair + '.image_stat.report'

    call_str = 'image_stat ' + hl_diff4_phase + ' ' + nWidth + ' ' + nWidth_half + ' 200 200 ' + image_report
    os.system(call_str)

    mean_phase = ut.read_gamma_par(image_report, 'read', 'mean')
    std_phase = ut.read_gamma_par(image_report, 'read', 'stdev')

    hl_diff_phase_shift = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff.ph_shift'
    hl_diff_shifted = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff4.shifted'
    hl_diff_shifted_phase = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff4.shifted.phase'
    call_str = 'lin_comb 1 ' + hl_diff4_phase + ' ' + mean_phase + ' 0.0 ' + hl_diff_phase_shift + ' ' + nWidth + ' 1 ' + nLine
    os.system(call_str)

    call_str = 'subtract_phase ' + hl_diff4_phase + ' ' + hl_diff_phase_shift + ' ' + hl_diff_shifted + ' ' + nWidth + '  1'
    os.system(call_str)

    call_str = 'cpx_to_real ' + hl_diff_shifted + ' ' + hl_diff_shifted_phase + ' ' + nWidth + ' 4'
    os.system(call_str)

    call_str = 'lin_comb 1 ' + hl_diff_shifted_phase + ' ' + mean_phase + ' 1.0 ' + hl_diff4_phase + ' ' + nWidth + ' 1 ' + nLine
    os.system(call_str)

    ############# determine trend considering cc_mask using unwrapping with multi_cpx before unwrapping ###

    diff_par = workDir + '/' + Pair + 'ddiff.par'
    call_str = 'create_diff_par ' + MampPar + ' - ' + diff_par + ' 1 0'
    os.system(call_str)

    ddiff_phase_trend = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff4_phase.trend'
    call_str = 'quad_fit ' + hl_diff4_phase + ' ' + diff_par + ' 5 5 ' + hl_diff_mask + ' - 3 ' + ddiff_phase_trend
    os.system(call_str)

    #call_str = 'vistd_pwr.py ' + ddiff_phase_trend + ' ' + Mamp + ' ' + nWidth + ' -c 12.6 -z 1000 -f 1.0 -m rmg -p ' + ddiff_phase_trend + '.jpg'
    #os.system(call_str)

    hl_diff_detrend = hl_diff + '.detrend'
    call_str = 'subtract_phase ' + hl_diff + ' ' + ddiff_phase_trend + ' ' + hl_diff_detrend + ' ' + nWidth + ' 1.'
    os.system(call_str)

    #call_str = 'vismph_pwr.py ' + hl_diff_detrend + ' ' + Mamp + ' ' + nWidth + ' -f 1.0 -z 1000 -p ' +  hl_diff_detrend+'.jpg'
    #os.system(call_str)

    call_str = 'adf ' + hl_diff_detrend + ' ' + hl_diff1 + ' ' + hl_diff + '.smcc' + ' ' + nWidth + ' 0.2 512 7 128'
    os.system(call_str)

    call_str = 'adf ' + hl_diff1 + ' ' + hl_diff2 + ' ' + hl_diff + '.smcc' + ' ' + nWidth + ' 0.3 256 7 64'
    os.system(call_str)

    call_str = 'adf ' + hl_diff2 + ' ' + hl_diff3 + ' ' + hl_diff + '.smcc' + ' ' + nWidth + ' 0.3 128 7 64'
    os.system(call_str)

    hl_diff4_detrend = hl_diff4 + '.detrend'
    hl_diff_cc = hl_diff + '.sm4.cc'
    call_str = 'adf ' + hl_diff3 + ' ' + hl_diff4_detrend + ' ' + hl_diff_cc + ' ' + nWidth + ' 0.3 128 7 16'
    os.system(call_str)

    off1 = workDir + '/' + Pair + '.off1'
    call_str = 'create_offset ' + MampPar + ' ' + MampPar + ' ' + off1 + ' 1 1 1 0'
    os.system(call_str)

    hl_diff4_mask = hl_diff + '.sm4.cc_mask.bmp'
    call_str = 'rascc_mask ' + hl_diff_cc + ' ' + Mamp + ' ' + nWidth + ' 1 1 0 1 1 0.95 0.0 0.1 0.1 0.9 1.0 0.35 1 ' + hl_diff4_mask
    os.system(call_str)

    call_str = 'mask_class ' + hl_diff_mask + ' ' + hl_diff4_detrend + ' ' + hl_diff4_detrend + '.masked.tmp ' + ' 1 1 1 1 0 0.0 0.0'
    os.system(call_str)

    call_str = 'mask_class ' + hl_diff4_mask + ' ' + hl_diff4_detrend + '.masked.tmp ' + ' ' + hl_diff4_detrend + '.masked' + + ' 1 1 1 1 0 0.0 0.0'
    os.system(call_str)

    ddiff5 = workDir + '/' + Pair + '_' + rlks + 'rlks.hl.diff5'
    off5 = workDir + '/' + Pair + '.off5'
    call_str = 'multi_cpx ' + hl_diff4_detrend + '.masked' + ' ' + off1 + ddiff5 + ' ' + off5 + ' 5 5'
    os.system(call_str)

    call_str = 'multi_real ' + Mamp + ' ' + off1 + ' ' + Mamp + '.5' + off5 + ' 5 5'
    os.system(call_str)

    call_str = 'multi_real ' + hl_diff_cc + ' ' + off1 + ' ' + hl_diff_cc + '.5' + off5 + ' 5 5'
    os.system(call_str)

    nWidth5 = ut.read_gamma_par(off5, 'read', 'interferogram_width')

    ddiff5_phase_tmp = ddiff5 + '.phase.tmp'
    ddiff5_phase_interp = ddiff5 + '.phase.interp'
    call_str = 'cpx_to_real ' + ddiff5 + ' ' + ddiff5_phase_tmp + ' ' + nWidth5 + ' 4'
    os.system(call_str)

    call_str = 'fill_gaps ' + ddiff5_phase_tmp + ' ' + nWidth5 + ' ' + ddiff5_phase_interp + ' 0 4 - 1 100 4 400'
    os.system(call_str)

    #### remove outliers
    ddiff5_fspf = ddiff5_phase_interp + '.fspf'
    call_str = 'fspf ' + ddiff5_phase_interp + ' ' + ddiff5_fspf + ' ' + nWidth5 + ' 2 64 3'
    os.system(call_str)

    ddiff5_phase_interp_outliers = ddiff5_phase_interp + '.outliers'
    call_str = 'lin_comb 2 ' + ddiff5_phase_interp + ' ' + ddiff5_fspf + ' 100 1.0 -1.0 ' + ddiff5_phase_interp_outliers + ' ' + nWidth5
    os.system(call_str)

    hl_diff_cc5 = hl_diff_cc + '.5'
    hl_diff5_mask = ddiff5 + '.mask.bmp'
    call_str = 'single_class_mapping 2 ' + ddiff5_phase_interp_outliers + ' 99.95 100.05 ' + hl_diff_cc5 + ' 0.15 1.0 ' + hl_diff5_mask + ' ' + nWidth5
    os.system(call_str)

    ddiff5_phase_tmp1 = ddiff5_phase_tmp + '1'
    call_str = 'mask_class ' + hl_diff5_mask + ' ' + ddiff5_phase_tmp + ' ' + ddiff5_phase_tmp1 + ' 0 1 1 1 0 0.0 0.0'
    os.system(call_str)

    call_str = 'fill_gaps ' + ddiff5_phase_tmp1 + ' ' + ddiff5_phase_interp + ' 0 4 - 1 100 4 400'
    os.system(call_str)

    ddiff_detrend_interp_phase = hl_diff + '.detrend' + '.interp.phase'
    call_str = 'multi_real ' + ddiff5_phase_interp + ' ' + off5 + ' ' + ddiff_detrend_interp_phase + ' ' + off1 + ' -5 -5'
    os.system(call_str)

    call_str = 'fspf ' + ddiff_detrend_interp_phase + ' ' + ddiff_detrend_interp_phase + '.fspf' + ' ' + nWidth + ' 2 8 3'
    os.system(call_str)

    #call_str = ' visdt_pwr.py ' +  ddiff_detrend_interp_phase + '.fspf' + ' ' + Mamp + ' ' + nWidth + ' -c 1.6 -z 1000 -f 1.0 -m rmg -p ' + ddiff_detrend_interp_phase + '.fspf.jpg'
    #os.system(call_str)

    ###### add the solutions

    ddiff_phase_fspf = hl_diff + ' .phase.fspf'
    call_str = 'lin_comb 2 ' + ddiff_phase_trend + ' ' + ddiff_detrend_interp_phase + '.fspf' + ' 0.0 1.0 1.0 ' + ddiff_phase_fspf + ' ' + nWidth + ' 1 ' + nLine
    os.system(call_str)

    #call_str ='visdt_pwr.py ' + ddiff_phase_fspf + ' ' + Mamp + ' ' + nWidth + ' -c 1.6 -z 1000 -f 1.0 -m rmg -p ' + ddiff_phase_fspf + '.jpg'
    #os.system(call_str)

    ###################### determin scaling factor using bpf_ssi

    bpf_ssi_out = workDir + '/bpf_ssi.out'
    call_str = 'bpf_ssi ' + Mrslc + ' ' + MrslcPar + ' - - - - 0.6666 > ' + bpf_ssi_out
    os.system(call_str)

    a0 = ut.read_gamma_par(bpf_ssi_out, 'read', 'a')
    b0 = ut.read_gamma_par(bpf_ssi_out, 'read', 'b')
    x0 = ut.read_gamma_par(bpf_ssi_out, 'read', 'x')
    y0 = ut.read_gamma_par(bpf_ssi_out, 'read', 'y')
    z0 = ut.read_gamma_par(bpf_ssi_out, 'read', 'z')
    zz0 = str(float(z0) * 2)

    ddiff_phase_fspf_scaled = ddiff_phase_fspf + '.scaled'
    call_str = 'lin_comb 1 ' + ddiff_phase_fspf + ' 0.0 ' + zz0 + ' ' + ddiff_phase_fspf_scaled + ' ' + nWidth
    os.system(call_str)

    call_str = 'rasrmg ' + ddiff_phase_fspf_scaled + ' ' + Mamp + ' ' + nWidth
    #call_str = 'vismph_pwr.py ' + hl_diff + ' ' + Mamp + ' ' + nWidth + ' -f 1.0 ' + ' -z 1000 ' + ' -p ' + hl_diff_jpg
    os.system(call_str)

    #call_str ='visdt_pwr.py ' + ddiff_phase_fspf_scaled + ' ' + Mamp + ' ' + nWidth + ' -c 1.6 -z 1000 -f 1.0 -m rmg -p ' + ddiff_phase_fspf_scaled + '.jpg'
    #os.system(call_str)

    # 2_phi_iono            =  phi0 + zz * ddiff_phase_fspf
    # 2_phi_non-dispersive  =  phi0 - zz * ddiff_phase_fspf

    #call_str = ' subtract_phase ' +

    print("Estimating the scaled ionospheric phases is done!")
    ut.print_process_time(start_time, time.time())
    sys.exit(1)