def generateIgram(imageSlc1, imageSlc2, resampName, azLooks, rgLooks): objSlc1 = isceobj.createSlcImage() IU.copyAttributes(imageSlc1, objSlc1) objSlc1.setAccessMode('read') objSlc1.createImage() objSlc2 = isceobj.createSlcImage() IU.copyAttributes(imageSlc2, objSlc2) objSlc2.setAccessMode('read') objSlc2.createImage() slcWidth = imageSlc1.getWidth() intWidth = int(slcWidth / rgLooks) lines = min(imageSlc1.getLength(), imageSlc2.getLength()) if '.flat' in resampName: resampAmp = resampName.replace('.flat', '.amp') elif '.int' in resampName: resampAmp = resampName.replace('.int', '.amp') else: resampAmp += '.amp' resampInt = resampName objInt = isceobj.createIntImage() objInt.setFilename(resampInt) objInt.setWidth(intWidth) imageInt = isceobj.createIntImage() IU.copyAttributes(objInt, imageInt) objInt.setAccessMode('write') objInt.createImage() objAmp = isceobj.createAmpImage() objAmp.setFilename(resampAmp) objAmp.setWidth(intWidth) imageAmp = isceobj.createAmpImage() IU.copyAttributes(objAmp, imageAmp) objAmp.setAccessMode('write') objAmp.createImage() objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = azLooks objCrossmul.LooksAcross = rgLooks objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) for obj in [objInt, objAmp, objSlc1, objSlc2]: obj.finalizeImage() return imageInt, imageAmp
def run(imageSlc1, imageSlc2, resampName, azLooks, rgLooks): objSlc1 = isceobj.createSlcImage() #right now imageSlc1 and 2 are just text files, need to open them as image IU.copyAttributes(imageSlc1, objSlc1) objSlc1.setAccessMode('read') objSlc1.createImage() objSlc2 = isceobj.createSlcImage() IU.copyAttributes(imageSlc2, objSlc2) objSlc2.setAccessMode('read') objSlc2.createImage() slcWidth = imageSlc1.getWidth() intWidth = int(slcWidth / rgLooks) lines = min(imageSlc1.getLength(), imageSlc2.getLength()) resampAmp = resampName + '.amp' resampInt = resampName + '.int' objInt = isceobj.createIntImage() objInt.setFilename(resampInt) objInt.setWidth(intWidth) imageInt = isceobj.createIntImage() IU.copyAttributes(objInt, imageInt) objInt.setAccessMode('write') objInt.createImage() objAmp = isceobj.createAmpImage() objAmp.setFilename(resampAmp) objAmp.setWidth(intWidth) imageAmp = isceobj.createAmpImage() IU.copyAttributes(objAmp, imageAmp) objAmp.setAccessMode('write') objAmp.createImage() objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = azLooks objCrossmul.LooksAcross = rgLooks objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) for obj in [objInt, objAmp, objSlc1, objSlc2]: obj.finalizeImage() return imageInt, imageAmp
def generateIgram(slcFile1, slcFile2, ifgFile, azLooks, rgLooks, compute_cor=True): imageSlc1 = isceobj.createImage() f1 = slcFile1 + ".xml" if not slcFile1.endswith(".xml") else slcFile1 print(f"Loading {f1}") imageSlc1.load(f1) imageSlc2 = isceobj.createImage() f2 = slcFile2 + ".xml" if not slcFile2.endswith(".xml") else slcFile2 print(f"Loading {f2}") imageSlc2.load(f2) objSlc1 = isceobj.createSlcImage() IU.copyAttributes(imageSlc1, objSlc1) objSlc1.setAccessMode("read") objSlc1.createImage() objSlc2 = isceobj.createSlcImage() IU.copyAttributes(imageSlc2, objSlc2) objSlc2.setAccessMode("read") objSlc2.createImage() slcWidth = imageSlc1.getWidth() intWidth = slcWidth // rgLooks lines = min(imageSlc1.getLength(), imageSlc2.getLength()) if ".flat" in ifgFile: resampAmp = ifgFile.replace(".flat", ".amp") elif ".int" in ifgFile: resampAmp = ifgFile.replace(".int", ".amp") else: resampAmp = ifgFile + ".amp" resampInt = ifgFile objInt = isceobj.createIntImage() objInt.setFilename(resampInt) objInt.setWidth(intWidth) imageInt = isceobj.createIntImage() IU.copyAttributes(objInt, imageInt) objInt.setAccessMode("write") objInt.createImage() objAmp = isceobj.createAmpImage() objAmp.setFilename(resampAmp) objAmp.setWidth(intWidth) imageAmp = isceobj.createAmpImage() IU.copyAttributes(objAmp, imageAmp) objAmp.setAccessMode("write") objAmp.createImage() objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = azLooks objCrossmul.LooksAcross = rgLooks objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) for obj in [objInt, objAmp, objSlc1, objSlc2]: obj.finalizeImage() if compute_cor: # Compute the multilooked version of correlation (much quicker than isce's full size) with rio.open(resampInt) as src: ifg = src.read(1) with rio.open(resampAmp) as src: amp1, amp2 = src.read() cor_filename = resampAmp.replace(".amp", ".cor") # Make the isce headers create_cor_image(cor_filename, ifg.shape, access_mode="write") # calulate and save (not sure how to just save an array in isce) cor = np.abs(ifg) / np.sqrt(amp1 ** 2 * amp2 ** 2) sario.save(cor_filename, np.stack((amp1 * amp2, cor))) return imageInt, imageAmp
def generateIgram(self, imageSlc1, imageSlc2, resampName, azLooks, rgLooks, radarWavelength): objSlc1 = isceobj.createSlcImage() IU.copyAttributes(imageSlc1, objSlc1) objSlc1.setAccessMode('read') objSlc1.createImage() objSlc2 = isceobj.createSlcImage() IU.copyAttributes(imageSlc2, objSlc2) objSlc2.setAccessMode('read') objSlc2.createImage() slcWidth = imageSlc1.getWidth() if not self.doRubbersheetingRange: intWidth = int( slcWidth / rgLooks ) # Modified by V. Brancato intWidth = int(slcWidth / rgLooks) else: intWidth = int(slcWidth) lines = min(imageSlc1.getLength(), imageSlc2.getLength()) if '.flat' in resampName: resampAmp = resampName.replace('.flat', '.amp') elif '.int' in resampName: resampAmp = resampName.replace('.int', '.amp') else: resampAmp += '.amp' if not self.doRubbersheetingRange: resampInt = resampName else: resampInt = resampName + ".full" objInt = isceobj.createIntImage() objInt.setFilename(resampInt) objInt.setWidth(intWidth) imageInt = isceobj.createIntImage() IU.copyAttributes(objInt, imageInt) objInt.setAccessMode('write') objInt.createImage() objAmp = isceobj.createAmpImage() objAmp.setFilename(resampAmp) objAmp.setWidth(intWidth) imageAmp = isceobj.createAmpImage() IU.copyAttributes(objAmp, imageAmp) objAmp.setAccessMode('write') objAmp.createImage() if not self.doRubbersheetingRange: print( 'Rubbersheeting in range is off, interferogram is already flattened' ) objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = azLooks objCrossmul.LooksAcross = rgLooks objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) else: # Modified by V. Brancato 10.09.2019 (added option to add Range Rubber sheet Flat-earth back) print('Rubbersheeting in range is on, removing flat-Earth phase') objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = 1 objCrossmul.LooksAcross = 1 objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) # Remove Flat-Earth component compute_FlatEarth(self, resampInt, intWidth, lines, radarWavelength) # Perform Multilook multilook(resampInt, outname=resampName, alks=azLooks, rlks=rgLooks) #takeLooks(objAmp,azLooks,rgLooks) multilook(resampAmp, outname=resampAmp.replace(".full", ""), alks=azLooks, rlks=rgLooks) #takeLooks(objInt,azLooks,rgLooks) #os.system('rm ' + resampInt+'.full* ' + resampAmp + '.full* ') # End of modification for obj in [objInt, objAmp, objSlc1, objSlc2]: obj.finalizeImage() return imageInt, imageAmp
def run(imageSlc1, imageSlc2, resampName, azLooks, rgLooks, lines, catalog=None, sceneid='NO_ID'): logger.info("Generating interferogram: %s" % sceneid) objSlc1 = isceobj.createSlcImage() IU.copyAttributes(imageSlc1, objSlc1) objSlc1.setAccessMode('read') objSlc1.createImage() objSlc2 = isceobj.createSlcImage() IU.copyAttributes(imageSlc2, objSlc2) objSlc2.setAccessMode('read') objSlc2.createImage() slcWidth = imageSlc1.getWidth() intWidth = int(slcWidth / rgLooks) logger.info("Will ouput interferogram and amplitude: %s" % sceneid) resampAmp = resampName + '.amp' resampInt = resampName + '.int' objInt = isceobj.createIntImage() objInt.setFilename(resampInt) objInt.setWidth(intWidth) imageInt = isceobj.createIntImage() IU.copyAttributes(objInt, imageInt) objInt.setAccessMode('write') objInt.createImage() objAmp = isceobj.createAmpImage() objAmp.setFilename(resampAmp) objAmp.setWidth(intWidth) imageAmp = isceobj.createAmpImage() IU.copyAttributes(objAmp, imageAmp) objAmp.setAccessMode('write') objAmp.createImage() objCrossmul = crossmul.createcrossmul() objCrossmul.width = slcWidth objCrossmul.length = lines objCrossmul.LooksDown = azLooks objCrossmul.LooksAcross = rgLooks #set the tag used in the outfile. each message is precided by this tag #is the writer is not of "file" type the call has no effect # objCrossmul.stdWriter = stdWriter.set_file_tags("resamp", # "log", # "err", # "out") objCrossmul.crossmul(objSlc1, objSlc2, objInt, objAmp) if catalog is not None: # Record the inputs and outputs isceobj.Catalog.recordInputsAndOutputs(catalog, objCrossmul, "runCrossmul.%s" % sceneid, logger, "runCrossmul.%s" % sceneid) for obj in [objInt, objAmp, objSlc1, objSlc2]: obj.finalizeImage() return imageInt, imageAmp