Exemple #1
0
def intLooks(inps):

    inWidth = getWidth(inps.input + '.xml')
    inLength = getLength(inps.input + '.xml')
    outWidth = int(inWidth / inps.rlks)
    outLength = int(inLength / inps.alks)

    #run program here
    cmd = '$INSAR_ZERODOP_BIN/look {} {} {} {} {} 4 0 0'.format(
        inps.input, inps.output, inWidth, inps.rlks, inps.alks)
    runCmd(cmd)

    #get xml file for interferogram
    create_xml(inps.output, outWidth, outLength, 'int')
Exemple #2
0
def ampLooks(inps):

    inWidth = getWidth(inps.input + '.xml')
    inLength = getLength(inps.input + '.xml')
    outWidth = int(inWidth / inps.rlks)
    outLength = int(inLength / inps.alks)

    #run it
    #cmd = 'echo -e "{}\n{}\n{} {}\n{} {}\n" | $INSAR_ZERODOP_BIN/rilooks'.format(inps.input, inps.output, inWidth, inLength, inps.rlks, inps.alks)
    #it seems that echo does not require -e in this situation, strange
    cmd = '$INSAR_ZERODOP_BIN/look {} {} {} {} {} 4 1 0'.format(
        inps.input, inps.output, inWidth, inps.rlks, inps.alks)
    runCmd(cmd)

    #get xml file for amplitude image
    create_xml(inps.output, outWidth, outLength, 'amp')
Exemple #3
0
def runSimAmp(hgtName='z.rdr', simName='simamp.rdr'):

    #get width from hgt file
    hgtImage = isceobj.createImage()
    hgtImage.load(hgtName + '.xml')
    hgtImage.setAccessMode('read')
    hgtImage.createImage()

    hgtWidth = hgtImage.getWidth()
    hgtLength = hgtImage.getLength()
    hgtImage.finalizeImage()

    #run simamp
    cmd = "$INSAR_ZERODOP_BIN/simamp {} {} {} 3.0 100.0".format(
        hgtName, simName, hgtWidth)
    #print("{}".format(cmd))
    runCmd(cmd)

    #create xml file of simamp.rdr
    create_xml(simName, hgtWidth, hgtLength, 'float')
Exemple #4
0
        parser.print_help()
        sys.exit(1)
    else:
        return parser.parse_args()


if __name__ == '__main__':

    inps = cmdLineParse()

    with open(inps.mframe, 'rb') as fid:
        masterFrame = pickle.load(fid)

    slantRangePixelSpacing = inps.rlks * 0.5 * SPEED_OF_LIGHT / masterFrame.rangeSamplingRate
    radarWavelength = masterFrame.radarWavelegth

    intfWidth = getWidth(inps.intf + '.xml')
    intfLength = getLength(inps.intf + '.xml')

    #run it
    cmd = "$INSAR_ZERODOP_BIN/flat {} {} {} {} {}".format(
        inps.intf, inps.rgoff, inps.dintf, slantRangePixelSpacing,
        radarWavelength)
    #print("{}".format(cmd))
    runCmd(cmd)

    #get xml file for interferogram
    create_xml(inps.dintf, intfWidth, intfLength, 'int')

    #./flat.py -m 20130927.slc.pck -i 20130927-20141211.int -r 20130927-20141211_rg.off -d diff_20130927-20141211.int
Exemple #5
0
        outframe.getInstrument().setRangeSamplingRate(frame2.instrument.rangeSamplingRate)
        outframe.getInstrument().setRangePixelSize(frame2.getInstrument().getRangePixelSize())


        #outframe.getInstrument().setRadarWavelength(SPEED_OF_LIGHT/centerfreq)
        #outframe.getInstrument().setPulseLength(math.fabs(overlapbandwidth/frame.instrument.chirpSlope))


        #remove orignal slc, leaving only filtered slc
        os.remove('tmp.slc')

        #output new frame pickle file
        with open(inps.frame, 'wb') as f:
            pickle.dump(outframe, f)

        create_xml(inps.slc, outWidth, outLength, 'slc')














Exemple #6
0
        range_offset = -1.0 * rangeOffset[inps.sn]
    else:
        range_offset = 0.0


    cmd = '$INSAR_ZERODOP_BIN/rg_filter {inputf} {outputf} {nrg} {bw} {bc} {nfilter} {nfft} {beta} {zero_cf} {offset}> /dev/null'.format(
    inputf = inps.islc,
    outputf = inps.oslc,
    nrg = iframe.getNumberOfSamples(),
    bw = rgbandwidth / 3.0 / iframe.instrument.rangeSamplingRate,
    bc = bc0,
    nfilter = 129,
    nfft = 512,
    beta = 0.1,
    zero_cf = 0,
    offset = range_offset
    )
    runCmd(cmd)
    create_xml(inps.oslc, iframe.getNumberOfSamples(), iframe.getNumberOfLines(), 'slc')


    iframe.instrument.setPulseLength(iframe.instrument.pulseLength/3.0)
    iframe.getInstrument().setRadarWavelength(float(SPEED_OF_LIGHT/fx))
    if inps.oframe != 'NotSpecified':
        with open(inps.oframe, 'wb') as f:
            pickle.dump(iframe, f)




    outpck.setNumberOfSamples(outWidth * rlks)
    outpck.setNumberOfLines(outLength * alks)
    outpck.startingRange = outStartingRange
    outpck.setFarRange(outFarRange)
    outpck.setSensingStart(outSensingStart)
    outpck.setSensingStop(outSensingStop)
    #sensing mid
    outpck.setSensingMid(outpck.getSensingStart() + datetime.timedelta(
        seconds=(outpck.getSensingStop() -
                 outpck.getSensingStart()).total_seconds() / 2.0))

    with open(inps.frameoutput, 'wb') as f:
        pickle.dump(outpck, f)

    #create XML file for mosaicked interferogram
    create_xml(infOutput, outWidth, outLength, 'int')
    #create XML file for mosaicked amplitude
    create_xml(ampOutput, outWidth, outLength, 'amp')

    #######################################################################################
    #adjust phase of subsequent subswath interferograms here
    #WARNING: 1. NOW ONLY SUPPORT THE CASE THAT ALL SUBSWATH RANGE SAMPLING INTERVALS ARE THE
    #            SAME.
    #         2. phase difference calculation should also be able to work for ScanSAR-stripmap
    #            interferometry, although the overlap area may not be the center of
    #            stripmap swath.

    #parameters for this part
    nrlks2 = inps.drlks
    nalks2 = inps.dalks
    corth = 0.85
Exemple #8
0
            beta=0.1)
        runCmd(cmd)

        #remove orignal slc, leaving only filtered slc
        os.remove('tmp.slc')

        #output new frame pickle file
        outframe = mframe
        outframe.getInstrument().setRadarWavelength(SPEED_OF_LIGHT /
                                                    centerfreq)
        outframe.getInstrument().setPulseLength(
            math.fabs(overlapbandwidth / mframe.instrument.chirpSlope))
        with open(inps.mframe, 'wb') as f:
            pickle.dump(outframe, f)

        create_xml(inps.mslc, mframe.getNumberOfSamples(),
                   mframe.getNumberOfLines(), 'slc')

    #2. filtering slave
    if math.fabs(centerfreq2 - centerfreq) < 1.0 and (bandwidth2 -
                                                      1.0) < overlapbandwidth:
        print('no need to range filter {}. nothing is done by this program.'.
              format(inps.sslc))
    else:
        os.rename(inps.sslc, 'tmp.slc')
        #os.remove(inps.sslc + '.par.xml')
        os.remove(inps.sslc + '.pck')
        os.remove(inps.sslc + '.xml')
        os.remove(inps.sslc + '.vrt')

        cmd = '$INSAR_ZERODOP_BIN/rg_filter {inputf} {outputf} {nrg} {bw} {bc} {nfilter} {nfft} {beta}'.format(
            inputf='tmp.slc',
Exemple #9
0
            azimuthOffset[i] += azimuthOffset2[j]


    #resample each frame
    rinfs = []
    crinfs = []
    for i, inf in enumerate(infs):
        infBase = os.path.splitext(ntpath.basename(inf))[0]
        infExt = os.path.splitext(ntpath.basename(inf))[1]
        rinfs.append("{}_{}{}".format(infBase, i, infExt))
        crinfs.append("{}_{}_corrected{}".format(infBase, i, infExt))

        if i == 0:
            os.symlink(inf, rinfs[i])
            #create xml file for rectified interferogram
            create_xml(rinfs[i], int(width[i]/rlks), int(length[i]/alks), file_type)
            if inps.phc == 1:
                os.symlink(inf, crinfs[i])
                #create xml file for corrected interferogram
                create_xml(crinfs[i], int(width[i]/rlks), int(length[i]/alks), file_type)
            continue

        rangeOffsetFrac = rangeOffset[i] - int(rangeOffset[i])
        azimuthOffsetFrac = azimuthOffset[i] - int(azimuthOffset[i])

        if file_type == 'int' or file_type == 'amp':
            rectInputInf = '''Input Image File Name  (-) = {inFile}        ! dimension of file to be rectified
Output Image File Name (-) = {outFile}       ! dimension of output
Input Dimensions       (-) = {inWidth} {inLength} ! across, down
Output Dimensions      (-) = {outWidth} {outLength} ! across, down
Affine Matrix Row 1    (-) = {m11} {m12}      ! a b
Exemple #10
0
        parser.print_help()
        sys.exit(1)
    else:
        return parser.parse_args()


if __name__ == '__main__':
    
    inps = cmdLineParse()

    #get information
    masterWidth = getWidth(inps.master + '.xml')
    masterLength = getLength(inps.master + '.xml')

    #run interf
    cmd = "$INSAR_ZERODOP_BIN/interf {} {} {} {} {}".format(inps.master, inps.slave, inps.intf, inps.amp, masterWidth)
    #print("{}".format(cmd))
    runCmd(cmd)

    #get xml file for interferogram
    create_xml(inps.intf, masterWidth, masterLength, 'int')
    #get xml file for amplitude image
    create_xml(inps.amp, masterWidth, masterLength, 'amp')


    #./interf.py -m 20130927.slc -s 20141211.slc -i 20130927-20141211.int -a 20130927-20141211.amp




Exemple #11
0
    print('mean value of phase difference: {}'.format(mv))

    flag2 = (unwl != 0) * (unwu != 0)
    index2 = np.nonzero(flag2)

    #phase for adjustment
    unwd = ((unwl - unwu)[index2] - mv) / (2.0 * np.pi)
    unw_adj = np.around(unwd) * (2.0 * np.pi)

    #ajust phase of upper band
    unwu[index2] += unw_adj

    unw_diff = (unwl - unwu)
    print('after adjustment:')
    print('max phase difference: {}'.format(np.amax(unw_diff)))
    print('min phase difference: {}'.format(np.amin(unw_diff)))

    #get two band rmg file of ajusted upper band
    unwc = np.zeros((length * 2, width))
    unwc[0:length * 2:2, :] = (np.fromfile(inps.unwu,
                                           dtype=np.float32).reshape(
                                               length * 2,
                                               width))[0:length * 2:2, :]
    unwc[1:length * 2:2, :] = unwu

    #output
    unwc.astype(np.float32).tofile(inps.unwc)

    #create xml
    create_xml(inps.unwc, width, length, 'unw')
Exemple #12
0
def runFilter(inps):
    logger.info("Applying power-spectral filter")

    #get width from the header file of input interferogram
    width = getWidth(inps.intf + '.xml')
    length = getLength(inps.intf + '.xml')

    if shutil.which('psfilt1') != None:
        cmd = "psfilt1 {int} {filtint} {width} {filterstrength} 64 16".format(
               int = inps.intf,
               filtint = inps.fintf,
               width = width,
               filterstrength = inps.alpha
               )
        runCmd(cmd)

        #get xml file for interferogram
        create_xml(inps.fintf, width, length, 'int')
    else:
        #create flattened interferogram
        intImage = isceobj.createIntImage()
        intImage.setFilename(inps.intf)
        intImage.setWidth(width)
        intImage.setAccessMode('read')
        intImage.createImage()

        #create the filtered interferogram
        filtImage = isceobj.createIntImage()
        filtImage.setFilename(inps.fintf)
        filtImage.setWidth(width)
        filtImage.setAccessMode('write')
        filtImage.createImage()

        #create filter and run it
        objFilter = Filter()
        objFilter.wireInputPort(name='interferogram',object=intImage)
        objFilter.wireOutputPort(name='filtered interferogram',object=filtImage)
        objFilter.goldsteinWerner(alpha=inps.alpha)

        intImage.finalizeImage()
        filtImage.finalizeImage()
        del filtImage


    #recreate filt image to read
    filtImage = isceobj.createIntImage()
    filtImage.setFilename(inps.fintf)
    filtImage.setWidth(width)
    filtImage.setAccessMode('read')
    filtImage.createImage()

    #create amplitude image
    ampImage = isceobj.createAmpImage()
    ampImage.setFilename(inps.amp)
    ampImage.setWidth(width)
    ampImage.setAccessMode('read')
    ampImage.createImage()

    #create phase sigma correlation file here
    phsig_tmp = 'tmp.phsig'
    phsigImage = isceobj.createImage()
    phsigImage.setFilename(phsig_tmp)
    phsigImage.setWidth(width)
    phsigImage.dataType='FLOAT'
    phsigImage.bands = 1
    phsigImage.setImageType('cor')#the type in this case is not for mdx.py displaying but for geocoding method
    phsigImage.setAccessMode('write')
    phsigImage.createImage()

    #create icu and run it
    icuObj = Icu(name='insarapp_filter_icu')
    icuObj.configure()
    icuObj.unwrappingFlag = False
    icuObj.icu(intImage = filtImage, ampImage=ampImage, phsigImage=phsigImage)
    
    phsigImage.renderHdr()

    filtImage.finalizeImage()
    ampImage.finalizeImage()
    phsigImage.finalizeImage()

    # #add an amplitude channel to phsig file
    # cmd = "imageMath.py -e='sqrt(a_0*a_1)*(b!=0);b' --a={amp} --b={phsig_tmp} -o {phsig} -s BIL".format(
    #        amp = inps.amp,
    #        phsig_tmp = phsig_tmp,
    #        phsig = inps.phsig
    #        )

    #add an amplitude channel to phsig file
    cmd = "imageMath.py -e='sqrt(a_0*a_1)*(b!=0);b' --a={amp} --b={phsig_tmp} -o {phsig} -s BIL".format(
           amp = inps.amp,
           phsig_tmp = phsig_tmp,
           phsig = inps.phsig
           )


    runCmd(cmd)

    #remove the original phsig file
    os.remove(phsig_tmp)
    os.remove(phsig_tmp + '.xml')
    os.remove(phsig_tmp + '.vrt')

    
    #rename original filtered interferogram
    filt_tmp = 'filt_tmp.int'
    os.rename(inps.fintf, filt_tmp)
    os.rename(inps.fintf + '.xml', filt_tmp + '.xml')
    os.rename(inps.fintf + '.vrt', filt_tmp + '.vrt')
    
    #do the numpy calculations
    #replace the magnitude of the filtered interferogram with magnitude of original interferogram
    #mask output file using layover mask (values 2 and 3).
    # cmd = "imageMath.py -e='a/(abs(a)+(abs(a)==0))*abs(b)*(c<2)' --a={0} --b={1} --c={2} -t CFLOAT -o={3}".format(
    #       filt_tmp,
    #       inps.intf,
    #       inps.msk,
    #       inps.fintf
    #     )

    #replacing magnitude is not good for phase unwrapping using snaphu
    cmd = "imageMath.py -e='a*(b<2)' --a={0} --b={1} -t CFLOAT -o={2}".format(
          filt_tmp,
          inps.msk,
          inps.fintf
        )

    runCmd(cmd)
    
    #remove the original filtered interferogram
    os.remove(filt_tmp)
    os.remove(filt_tmp + '.xml')
    os.remove(filt_tmp + '.vrt')
Exemple #13
0
            m22=azimuthScale[i],
            t1=0.0,
            t2=0.0,
            rlks=1,
            alks=1,
            format='REAL',
            method='Bilinear')

            rectInputFile = 'rect_with_looks_{}.in'.format(i)
            with open(rectInputFile, 'w') as ff:
                ff.write(rectInput)
            cmd = '$INSAR_ZERODOP_BIN/rect_with_looks {}'.format(rectInputFile)
            runCmd(cmd)

        #create xml file
        create_xml(rectPowName, rectWidth[i], rectLength[i], 'float')

        #STEP 3. take looks
        lookRectPowName = '{}_{}rlks_{}alks.pow'.format(
            os.path.splitext(rectPowName)[0], nrlks, nalks)
        lookRectWidth.append(int(rectWidth[i] / nrlks))
        lookRectLength.append(int(rectLength[i] / nalks))
        if inps.rlks == 1 and inps.alks == 1:
            os.symlink(rectPowName, lookRectPowName)
            create_xml(lookRectPowName, lookRectWidth[i], lookRectLength[i],
                       'float')
        else:
            cmd = 'looks.py -i {} -o {} -r {} -a {}'.format(
                rectPowName, lookRectPowName, nrlks, nalks)
            runCmd(cmd)