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
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