예제 #1
0
def run(method, ampImage, widthInt, infos, stdWriter, catalog=None, sceneid='NO_ID'):
    logger.info("Calculating Coherence: %s" % sceneid)

    # Initialize the flattened inteferogram
    topoflatIntFilename = infos['outputPath'] + '.' + infos['topophaseFlatFilename']
    intImage = isceobj.createIntImage()
    intImage.setFilename(topoflatIntFilename)
    intImage.setWidth(widthInt)
    intImage.setAccessMode('read')
    intImage.createImage()

    # Create the coherence image
    cohFilename = topoflatIntFilename.replace('.flat', '.cor')
    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(cohFilename)
    cohImage.setWidth(widthInt)
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='interferogram', object=intImage)
    cor.wireInputPort(name='amplitude', object=ampImage)
    cor.wireOutputPort(name='correlation', object=cohImage)

    try:
        CORRELATION_METHOD[method](cor)
    except KeyError:
        print("Unrecognized correlation method")
        sys.exit(1)
        pass
    return None
예제 #2
0
def computeCoherence(slc1name, slc2name, corname, virtual=True):

    slc1 = isceobj.createImage()
    slc1.load(slc1name + '.xml')
    slc1.createImage()

    slc2 = isceobj.createImage()
    slc2.load(slc2name + '.xml')
    slc2.createImage()

    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(corname)
    cohImage.setWidth(slc1.getWidth())
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='slc1', object=slc1)
    cor.wireInputPort(name='slc2', object=slc2)
    cor.wireOutputPort(name='correlation', object=cohImage)
    cor.coregisteredSlcFlag = True
    cor.calculateCorrelation()

    cohImage.finalizeImage()
    slc1.finalizeImage()
    slc2.finalizeImage()
    return
예제 #3
0
def runCoherence(self, method="phase_gradient"):

    logger.info("Calculating Coherence")

    # Initialize the amplitude
    #    resampAmpImage =  self.insar.resampAmpImage
    #    ampImage = isceobj.createAmpImage()
    #    IU.copyAttributes(resampAmpImage, ampImage)
    #    ampImage.setAccessMode('read')
    #    ampImage.createImage()
    #    ampImage = self.insar.getResampOnlyAmp().copy(access_mode='read')
    ampImage = isceobj.createImage()
    ampImage.load(self.insar.getResampOnlyAmp().filename + '.xml')
    ampImage.setAccessMode('READ')
    ampImage.createImage()

    # Initialize the flattened inteferogram
    topoflatIntFilename = self.insar.topophaseFlatFilename
    intImage = isceobj.createImage()
    intImage.load(self.insar.topophaseFlatFilename + '.xml')
    intImage.setAccessMode('READ')
    intImage.createImage()

    #    widthInt = self.insar.resampIntImage.getWidth()
    #    intImage.setFilename(topoflatIntFilename)
    #    intImage.setWidth(widthInt)
    #    intImage.setAccessMode('read')
    #    intImage.createImage()

    # Create the coherence image
    cohFilename = topoflatIntFilename.replace('.flat', '.cor')
    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(cohFilename)
    cohImage.setWidth(intImage.width)
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='interferogram', object=intImage)
    cor.wireInputPort(name='amplitude', object=ampImage)
    cor.wireOutputPort(name='correlation', object=cohImage)

    cohImage.finalizeImage()
    intImage.finalizeImage()
    ampImage.finalizeImage()

    cor.calculateCorrelation()
    #    try:
    #        CORRELATION_METHOD[method](cor)
    #    except KeyError:
    #        print("Unrecognized correlation method")
    #        sys.exit(1)
    #        pass
    return None
예제 #4
0
def coherence(amplitudeFile,
              interferogramFile,
              coherenceFile,
              method="cchz_wave",
              windowSize=5):
    ''' 
    compute coherence using a window
    '''
    import operator
    from mroipac.correlation.correlation import Correlation

    CORRELATION_METHOD = {
        'phase_gradient':
        operator.methodcaller('calculateEffectiveCorrelation'),
        'cchz_wave': operator.methodcaller('calculateCorrelation')
    }

    ampImage = isceobj.createAmpImage()
    ampImage.load(amplitudeFile + '.xml')
    ampImage.setAccessMode('read')
    ampImage.createImage()

    intImage = isceobj.createIntImage()
    intImage.load(interferogramFile + '.xml')
    intImage.setAccessMode('read')
    intImage.createImage()

    #there is no coherence image in the isceobj/Image
    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(coherenceFile)
    cohImage.setWidth(ampImage.width)
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='amplitude', object=ampImage)
    cor.wireInputPort(name='interferogram', object=intImage)
    cor.wireOutputPort(name='correlation', object=cohImage)

    cor.windowSize = windowSize

    cohImage.finalizeImage()
    intImage.finalizeImage()
    ampImage.finalizeImage()

    try:
        CORRELATION_METHOD[method](cor)
    except KeyError:
        print("Unrecognized correlation method")
        sys.exit(1)
        pass
    return None
예제 #5
0
def coherence(inps, method="phase_gradient"):

    #logger.info("Calculating Coherence")

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

    # Initialize the amplitude
    ampImage = isceobj.createAmpImage()
    ampImage.setFilename(inps.amp)
    ampImage.setWidth(width)
    ampImage.setAccessMode('read')
    ampImage.createImage()
    #ampImage = self.insar.getResampOnlyAmp().copy(access_mode='read')

    # Initialize the flattened inteferogram
    intImage = isceobj.createIntImage()
    intImage.setFilename(inps.intf)
    intImage.setWidth(width)
    intImage.setAccessMode('read')
    intImage.createImage()

    # Create the coherence image
    #there is no coherence image in the isceobj/Image
    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(inps.cor)
    cohImage.setWidth(width)
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='interferogram', object=intImage)
    cor.wireInputPort(name='amplitude', object=ampImage)
    cor.wireOutputPort(name='correlation', object=cohImage)
    cor.windowSize = inps.winsize

    cohImage.finalizeImage()
    intImage.finalizeImage()
    ampImage.finalizeImage()

    try:
        CORRELATION_METHOD[method](cor)
    except KeyError:
        print("Unrecognized correlation method")
        sys.exit(1)
        pass
    return None
예제 #6
0
def runCoherence(self, method="phase_gradient"):

    logger.info("Calculating Coherence")

    import os

    resampAmpImage = os.path.join(self.insar.ifgDirname,
                                  self.insar.ifgFilename)
    topoflatIntFilename = os.path.join(self.insar.ifgDirname,
                                       self.insar.ifgFilename)

    if '.flat' in resampAmpImage:
        resampAmpImage = resampAmpImage.replace('.flat', '.amp')
    elif '.int' in resampAmpImage:
        resampAmpImage = resampAmpImage.replace('.int', '.amp')
    else:
        resampAmpImage += '.amp'

    # Initialize the amplitude
#    resampAmpImage =  self.insar.resampAmpImage
#    ampImage = isceobj.createAmpImage()
#    IU.copyAttributes(resampAmpImage, ampImage)
#    ampImage.setAccessMode('read')
#    ampImage.createImage()
#    ampImage = self.insar.getResampOnlyAmp().copy(access_mode='read')
    ampImage = isceobj.createImage()
    ampImage.load(resampAmpImage + '.xml')
    ampImage.setAccessMode('READ')
    ampImage.createImage()

    # Initialize the flattened inteferogram
    #    topoflatIntFilename = self.insar.topophaseFlatFilename
    intImage = isceobj.createImage()
    intImage.load(topoflatIntFilename + '.xml')
    intImage.setAccessMode('READ')
    intImage.createImage()

    #    widthInt = self.insar.resampIntImage.getWidth()
    #    intImage.setFilename(topoflatIntFilename)
    #    intImage.setWidth(widthInt)
    #    intImage.setAccessMode('read')
    #    intImage.createImage()

    # Create the coherence image
    cohFilename = topoflatIntFilename.replace('.flat', '.cor')
    cohImage = isceobj.createOffsetImage()
    cohImage.setFilename(cohFilename)
    cohImage.setWidth(intImage.width)
    cohImage.setAccessMode('write')
    cohImage.createImage()

    cor = Correlation()
    cor.configure()
    cor.wireInputPort(name='interferogram', object=intImage)
    cor.wireInputPort(name='amplitude', object=ampImage)
    cor.wireOutputPort(name='correlation', object=cohImage)

    cohImage.finalizeImage()
    intImage.finalizeImage()
    ampImage.finalizeImage()

    cor.calculateCorrelation()

    # NEW COMMANDS added by YL --start
    import subprocess
    subprocess.getoutput(
        'MULTILOOK_FILTER_ISCE.py -a ./interferogram/topophase.amp -c ./interferogram/topophase.cor'
    )
    subprocess.getoutput(
        'CROP_ISCE_stripmapApp.py -a ./interferogram/topophase.amp -c ./interferogram/topophase.cor'
    )
    subprocess.getoutput(
        'imageMath.py -e="a_0;a_1" --a ./interferogram/topophase.amp -o ./interferogram/resampOnlyImage1.amp -s BIL -t FLOAT'
    )
    self.geocode_list += ['./interferogram/resampOnlyImage1.amp']
    # NEW COMMANDS added by YL --end

    #    try:
    #        CORRELATION_METHOD[method](cor)
    #    except KeyError:
    #        print("Unrecognized correlation method")
    #        sys.exit(1)
    #        pass
    return None