def runOffsetprf(self): from isceobj.Catalog import recordInputs logger.info("Calculate offset between slcs using ampcor") masterFrame = self._insar.getMasterFrame() slaveFrame = self._insar.getSlaveFrame() masterOrbit = self._insar.getMasterOrbit() slaveOrbit = self._insar.getSlaveOrbit() prf1 = masterFrame.getInstrument().getPulseRepetitionFrequency() prf2 = slaveFrame.getInstrument().getPulseRepetitionFrequency() nearRange1 = self.insar.formSLC1.startingRange nearRange2 = self.insar.formSLC2.startingRange fs1 = masterFrame.getInstrument().getRangeSamplingRate() fs2 = slaveFrame.getInstrument().getRangeSamplingRate() ###There seems to be no other way of determining image length - Piyush patchSize = self._insar.getPatchSize() numPatches = self._insar.getNumberPatches() valid_az_samples = self._insar.getNumberValidPulses() firstAc = self._insar.getFirstSampleAcrossPrf() firstDown = self._insar.getFirstSampleDownPrf() numLocationAcross = self._insar.getNumberLocationAcrossPrf() numLocationDown = self._insar.getNumberLocationDownPrf() delRg1 = CN.SPEED_OF_LIGHT / (2 * fs1) delRg2 = CN.SPEED_OF_LIGHT / (2 * fs2) coarseRange = (nearRange1 - nearRange2) / delRg2 coarseAcross = int(coarseRange + 0.5) if (coarseRange <= 0): coarseAcross = int(coarseRange - 0.5) pass if self.grossRg is not None: coarseAcross = self.grossRg pass s1 = self.insar.formSLC1.mocompPosition[1][0] s1_2 = self.insar.formSLC1.mocompPosition[1][1] s2 = self.insar.formSLC2.mocompPosition[1][0] s2_2 = self.insar.formSLC2.mocompPosition[1][1] coarseAz = int((s1 - s2) / (s2_2 - s2) + prf2 * (1 / prf1 - 1 / prf2) * (patchSize - valid_az_samples) / 2) coarseDown = int(coarseAz + 0.5) if (coarseAz <= 0): coarseDown = int(coarseAz - 0.5) pass if self.grossAz is not None: coarseDown = self.grossAz pass coarseAcross = 0 + coarseAcross coarseDown = 0 + coarseDown mSlcImage = self._insar.getMasterSlcImage() mSlc = isceobj.createSlcImage() IU.copyAttributes(mSlcImage, mSlc) accessMode = 'read' mSlc.setAccessMode(accessMode) mSlc.createImage() masterWidth = mSlc.getWidth() masterLength = mSlc.getLength() sSlcImage = self._insar.getSlaveSlcImage() sSlc = isceobj.createSlcImage() IU.copyAttributes(sSlcImage, sSlc) accessMode = 'read' sSlc.setAccessMode(accessMode) sSlc.createImage() slaveWidth = sSlc.getWidth() slaveLength = sSlc.getLength() objAmpcor = Ampcor(name='insarapp_slcs_ampcor') objAmpcor.configure() objAmpcor.setImageDataType1('complex') objAmpcor.setImageDataType2('complex') if objAmpcor.acrossGrossOffset: coarseAcross = objAmpcor.acrossGrossOffset if objAmpcor.downGrossOffset: coarseDown = objAmpcor.downGrossOffset logger.debug("Gross Across: %s" % (coarseAcross)) logger.debug("Gross Down: %s" % (coarseDown)) xMargin = 2 * objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2 * objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight #####Compute image positions offAc = max(firstAc, -coarseAcross) + xMargin offDn = max(firstDown, -coarseDown) + yMargin offAcmax = int(coarseAcross + ((fs2 / fs1) - 1) * masterWidth) logger.debug("Gross Max Across: %s" % (offAcmax)) lastAc = int(min(masterWidth, slaveWidth - offAcmax) - xMargin) offDnmax = int(coarseDown + ((prf2 / prf1) - 1) * masterLength) logger.debug("Gross Max Down: %s" % (offDnmax)) lastDown = int(min(masterLength, slaveLength - offDnmax) - yMargin) if not objAmpcor.firstSampleAcross: objAmpcor.setFirstSampleAcross(offAc) if not objAmpcor.lastSampleAcross: objAmpcor.setLastSampleAcross(lastAc) if not objAmpcor.numberLocationAcross: objAmpcor.setNumberLocationAcross(numLocationAcross) if not objAmpcor.firstSampleDown: objAmpcor.setFirstSampleDown(offDn) if not objAmpcor.lastSampleDown: objAmpcor.setLastSampleDown(lastDown) if not objAmpcor.numberLocationDown: objAmpcor.setNumberLocationDown(numLocationDown) #####Override gross offsets if not provided if not objAmpcor.acrossGrossOffset: objAmpcor.setAcrossGrossOffset(coarseAcross) if not objAmpcor.downGrossOffset: objAmpcor.setDownGrossOffset(coarseDown) #####User inputs are overriden here objAmpcor.setFirstPRF(prf1) objAmpcor.setSecondPRF(prf2) objAmpcor.setFirstRangeSpacing(delRg1) objAmpcor.setSecondRangeSpacing(delRg2) # Record the inputs recordInputs(self._insar.procDoc, objAmpcor, "runOffsetprf", logger, "runOffsetprf") objAmpcor.ampcor(mSlc, sSlc) # Record the outputs from isceobj.Catalog import recordOutputs recordOutputs(self._insar.procDoc, objAmpcor, "runOffsetprf", logger, "runOffsetprf") mSlc.finalizeImage() sSlc.finalizeImage() # save the input offset field for the record self._insar.setOffsetField(objAmpcor.getOffsetField()) self._insar.setRefinedOffsetField(objAmpcor.getOffsetField())
def runAmpcor(master, slave): ''' Run one ampcor process. ''' import isceobj from mroipac.ampcor.Ampcor import Ampcor mImg = isceobj.createSlcImage() mImg.load(master + '.xml') mImg.setAccessMode('READ') mImg.createImage() sImg = isceobj.createSlcImage() sImg.load(slave + '.xml') sImg.setAccessMode('READ') sImg.createImage() objAmpcor = Ampcor('ampcor_burst') objAmpcor.configure() objAmpcor.setImageDataType1('mag') objAmpcor.setImageDataType2('mag') if objAmpcor.acrossGrossOffset is None: coarseAcross = 0 if objAmpcor.downGrossOffset is None: coarseDown = 0 objAmpcor.windowSizeWidth = 64 objAmpcor.windowSizeHeight = 32 objAmpcor.searchWindowSizeWidth = 16 objAmpcor.searchWindowSizeHeight = 16 objAmpcor.oversamplingFactor = 32 xMargin = 2 * objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2 * objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight firstAc = 1000 #####Compute image positions offDn = objAmpcor.windowSizeHeight // 2 + 1 offAc = firstAc + xMargin offDnmax = mImg.getLength() - objAmpcor.windowSizeHeight // 2 - 1 lastAc = int(mImg.width - 1000 - xMargin) if not objAmpcor.firstSampleAcross: objAmpcor.setFirstSampleAcross(offAc) if not objAmpcor.lastSampleAcross: objAmpcor.setLastSampleAcross(lastAc) if not objAmpcor.numberLocationAcross: objAmpcor.setNumberLocationAcross(80) if not objAmpcor.firstSampleDown: objAmpcor.setFirstSampleDown(offDn) if not objAmpcor.lastSampleDown: objAmpcor.setLastSampleDown(offDnmax) ###Since we are only dealing with overlaps objAmpcor.setNumberLocationDown(20) #####Override gross offsets if not provided if not objAmpcor.acrossGrossOffset: objAmpcor.setAcrossGrossOffset(coarseAcross) if not objAmpcor.downGrossOffset: objAmpcor.setDownGrossOffset(coarseDown) objAmpcor.setImageDataType1('mag') objAmpcor.setImageDataType2('mag') objAmpcor.setFirstPRF(1.0) objAmpcor.setSecondPRF(1.0) objAmpcor.setFirstRangeSpacing(1.0) objAmpcor.setSecondRangeSpacing(1.0) objAmpcor(mImg, sImg) mImg.finalizeImage() sImg.finalizeImage() return objAmpcor.getOffsetField()
def run(imageAmp, imageSim, numBand, prf, fs1, infos, stdWriter, catalog=None, sceneid='NO_ID'): #fs1: range sampling rate firstAc = infos['firstSampleAcrossPrf'] firstDown = infos['firstSampleDownPrf'] numLocationAcross = infos['numberLocationAcrossPrf'] numLocationDown = infos['numberLocationDownPrf'] coarseAcross = 0 coarseDown = 0 #Fake amplitude image as a complex image objAmp = isceobj.createImage() objAmp.setAccessMode('read') objAmp.dataType = 'CFLOAT' objAmp.bands = 1 objAmp.setFilename(imageAmp.filename) objAmp.setWidth(imageAmp.width) objAmp.createImage() widthAmp = objAmp.getWidth() intLength = objAmp.getLength() objSim = isceobj.createImage() objSim.setFilename(imageSim.filename) objSim.setWidth(imageSim.width) objSim.dataType='FLOAT' objSim.setAccessMode('read') objSim.createImage() # check if it's correct delRg1 = CN.SPEED_OF_LIGHT / (2*fs1) objAmpcor = Ampcor() objAmpcor.setImageDataType1('real') objAmpcor.setImageDataType2('complex') ####Adjust first and last values using window sizes xMargin = 2*objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2*objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight offAc = max(firstAc, -coarseAcross) + xMargin offDn = max(firstDown, -coarseDown) + yMargin lastAc = int(min(widthAmp, widthAmp-offAc) - xMargin) lastDn = int(min(intLength, intLength-offDn) - yMargin) print(xMargin, yMargin) print(offAc, lastAc) print(offDn, lastDn) objAmpcor.setFirstSampleAcross(offAc) objAmpcor.setLastSampleAcross(lastAc) objAmpcor.setNumberLocationAcross(numLocationAcross) objAmpcor.setFirstSampleDown(offDn) objAmpcor.setLastSampleDown(lastDn) objAmpcor.setNumberLocationDown(numLocationDown) #set the tag used in the outfile. each message is preceded by this tag #if the writer is not of "file" type the call has no effect objAmpcor.stdWriter = stdWriter.set_file_tags("rgoffset", "log", "err", "out") objAmpcor.setFirstPRF(prf) objAmpcor.setSecondPRF(prf) objAmpcor.setAcrossGrossOffset(coarseAcross) objAmpcor.setDownGrossOffset(coarseDown) objAmpcor.setFirstRangeSpacing(delRg1) objAmpcor.setSecondRangeSpacing(delRg1) objAmpcor.ampcor(objSim,objAmp) if catalog is not None: # Record the inputs and outputs isceobj.Catalog.recordInputsAndOutputs(catalog, objAmpcor, "runRgoffset_ampcor.%s" % sceneid, logger, "runRgoffset_ampcor.%s" % sceneid) objAmp.finalizeImage() objSim.finalizeImage() return objAmpcor.getOffsetField()
def run(imageAmp, imageSim, numBand, infos, nstages, scale, stdWriter, catalog=None, sceneid='NO_ID'): logger.info("Running Rgoffset: %s" % sceneid) coarseAcross = 0 coarseDown = 0 firstAc = infos['firstSampleAcross'] firstDown = infos['firstSampleDown'] numLocationAcross = infos['numberLocationAcross'] numLocationDown = infos['numberLocationDown'] slaveWidth = imageAmp.getWidth() slaveLength = imageAmp.getLength() objAmp = isceobj.createSlcImage() objAmp.dataType = 'CFLOAT' objAmp.bands = 1 objAmp.setFilename(imageAmp.getFilename()) objAmp.setAccessMode('read') objAmp.setWidth(slaveWidth) objAmp.createImage() masterWidth = imageSim.getWidth() objSim = isceobj.createImage() objSim.setFilename(imageSim.getFilename()) objSim.dataType = 'FLOAT' objSim.setWidth(masterWidth) objSim.setAccessMode('read') objSim.createImage() masterLength = imageSim.getLength() finalIteration = False for iterNum in xrange(nstages-1,-1,-1): ####Rewind the images try: objAmp.rewind() objSim.rewind() except: print('Issues when rewinding images.') #KK sys.exit? ###### logger.debug('Starting Iteration Stage : %d'%(iterNum)) logger.debug("Gross Across: %s" % (coarseAcross)) logger.debug("Gross Down: %s" % (coarseDown)) ####Clear objs objAmpcor = None objOff = None offField = None objAmpcor = Ampcor() objAmpcor.setImageDataType1('real') objAmpcor.setImageDataType2('complex') ####Dummy values as there is no scale difference at this step objAmpcor.setFirstPRF(1.0) objAmpcor.setSecondPRF(1.0) objAmpcor.setFirstRangeSpacing(1.0) objAmpcor.setSecondRangeSpacing(1.0) #####Scale all the reference and search windows scaleFactor = scale**iterNum objAmpcor.windowSizeWidth *= scaleFactor objAmpcor.windowSizeHeight *= scaleFactor objAmpcor.searchWindowSizeWidth *= scaleFactor objAmpcor.searchWindowSizeHeight *= scaleFactor xMargin = 2*objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2*objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight #####Set image limits for search offAc = max(firstAc,-coarseAcross)+xMargin offDn = max(firstDn,-coarseDown)+yMargin offAcmax = int(coarseAcross) logger.debug("Gross Max Across: %s" % (offAcmax)) lastAc = int(min(masterWidth, slaveWidth-offAcmax) - xMargin) offDnmax = int(coarseDown) logger.debug("Gross Max Down: %s" % (offDnmax)) lastDn = int(min(masterLength, slaveLength-offDnmax) - yMargin) logger.debug("Last Down: %s" %(lastDn)) objAmpcor.setFirstSampleAcross(offAc) objAmpcor.setLastSampleAcross(lastAc) objAmpcor.setFirstSampleDown(offDn) objAmpcor.setLastSampleDown(lastDn) objAmpcor.setAcrossGrossOffset(coarseAcross) objAmpcor.setDownGrossOffset(coarseDown) if (offAc > lastAc) or (offDn > lastDn): print('Search window scale is too large.') print('Skipping Scale: %d'%(iterNum+1)) continue if ((lastAc - offAc) <= (2*xMargin)) or ((lastDn - offDn) <= (2*yMargin)): print('Image not large enough accounting for margins.') print('Skipping Scale: %d'%(iterNum+1)) continue logger.debug('Looks = %d'%scaleFactor) logger.debug('Correlation window sizes: %d %d'%(objAmpcor.windowSizeWidth, objAmpcor.windowSizeHeight)) logger.debug('Search window sizes: %d %d'%(objAmpcor.searchWindowSizeWidth, objAmpcor.searchWindowSizeHeight)) logger.debug(' Across pos: %d %d out of (%d,%d)'%(objAmpcor.firstSampleAcross, objAmpcor.lastSampleAcross, masterWidth, slaveWidth)) logger.debug(' Down pos: %d %d out of (%d,%d)'%(objAmpcor.firstSampleDown, objAmpcor.lastSampleDown, masterLength, slaveLength)) if (iterNum == 0) or finalIteration: if catalog is not None: # Record the inputs isceobj.Catalog.recordInputs(catalog, objAmpcor, "runRgoffset.%s" % sceneid, logger, "runRgoffset.%s" % sceneid) objAmpcor.setNumberLocationAcross(numLocationAcross) objAmpcor.setNumberLocationDown(numLocationDown) else: objAmpcor.setNumberLocationAcross(20) objAmpcor.setNumberLocationDown(20) objAmpcor.setAcrossLooks(scaleFactor) objAmpcor.setDownLooks(scaleFactor) objAmpcor.setZoomWindowSize(scale*objAmpcor.zoomWindowSize) objAmpcor.setOversamplingFactor(2) objAmpcor.ampcor(objSim,objAmp) offField = objAmpcor.getOffsetField() if (iterNum == 0) or finalIteration: if catalog is not None: # Record the outputs isceobj.Catalog.recordOutputs(catalog, objAmpcor, "runRgoffset.%s" % sceneid, logger, "runRgoffset.%s" % sceneid) else: objOff = isceobj.createOffoutliers() objOff.wireInputPort(name='offsets', object=offField) objOff.setSNRThreshold(2.0) objOff.setDistance(10) objOff.setStdWriter = stdWriter.set_file_tags("nstage_offoutliers"+str(iterNum), "log", "err", "out") objOff.offoutliers() coarseAcross = int(objOff.averageOffsetAcross) coarseDown = int(objOff.averageOffsetDown) objSim.finalizeImage() objAmp.finalizeImage() objOff = None objAmpcor = None return offField
def runRgoffset(self): numLocationAcross = self._insar.getNumberLocationAcrossPrf() numLocationDown = self._insar.getNumberLocationDownPrf() firstAc = self._insar.getFirstSampleAcrossPrf() firstDown = self._insar.getFirstSampleDownPrf() #Fake amplitude image as a complex image imageAmp = self._insar.getResampAmpImage() objAmp = isceobj.createImage() objAmp.setAccessMode('read') objAmp.dataType = 'CFLOAT' objAmp.bands = 1 objAmp.setFilename(imageAmp.filename) objAmp.setWidth(imageAmp.width) objAmp.createImage() widthAmp = objAmp.getWidth() intLength = objAmp.getLength() imageSim = self._insar.getSimAmpImage() objSim = isceobj.createImage() objSim.setFilename(imageSim.filename) objSim.setWidth(imageSim.width) objSim.dataType = 'FLOAT' objSim.setAccessMode('read') objSim.createImage() simWidth = imageSim.getWidth() simLength = imageSim.getLength() fs1 = self._insar.getReferenceFrame().getInstrument().getRangeSamplingRate( ) ##check delRg1 = CN.SPEED_OF_LIGHT / (2 * fs1) ## if it's correct objAmpcor = Ampcor(name='insarapp_intsim_ampcor') objAmpcor.configure() objAmpcor.setImageDataType1('real') objAmpcor.setImageDataType2('mag') ####Adjust first and last values using window sizes xMargin = 2 * objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2 * objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight if not objAmpcor.acrossGrossOffset: coarseAcross = 0 else: coarseAcross = objAmpcor.acrossGrossOffset if not objAmpcor.downGrossOffset: coarseDown = 0 else: coarseDown = objAmpcor.downGrossOffset offAc = max(firstAc, -coarseAcross) + xMargin + 1 offDn = max(firstDown, -coarseDown) + yMargin + 1 lastAc = int(min(widthAmp, simWidth - offAc) - xMargin - 1) lastDn = int(min(intLength, simLength - offDn) - yMargin - 1) if not objAmpcor.firstSampleAcross: objAmpcor.setFirstSampleAcross(offAc) if not objAmpcor.lastSampleAcross: objAmpcor.setLastSampleAcross(lastAc) if not objAmpcor.numberLocationAcross: objAmpcor.setNumberLocationAcross(numLocationAcross) if not objAmpcor.firstSampleDown: objAmpcor.setFirstSampleDown(offDn) if not objAmpcor.lastSampleDown: objAmpcor.setLastSampleDown(lastDn) if not objAmpcor.numberLocationDown: objAmpcor.setNumberLocationDown(numLocationDown) #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 self._stdWriter.setFileTag("rgoffset", "log") self._stdWriter.setFileTag("rgoffset", "err") self._stdWriter.setFileTag("rgoffset", "out") objAmpcor.setStdWriter(self._stdWriter) prf = self._insar.getReferenceFrame().getInstrument( ).getPulseRepetitionFrequency() objAmpcor.setFirstPRF(prf) objAmpcor.setSecondPRF(prf) if not objAmpcor.acrossGrossOffset: objAmpcor.setAcrossGrossOffset(coarseAcross) if not objAmpcor.downGrossOffset: objAmpcor.setDownGrossOffset(coarseDown) objAmpcor.setFirstRangeSpacing(delRg1) objAmpcor.setSecondRangeSpacing(delRg1) objAmpcor.ampcor(objSim, objAmp) # Record the inputs and outputs from isceobj.Catalog import recordInputsAndOutputs recordInputsAndOutputs(self._insar.procDoc, objAmpcor, "runRgoffset_ampcor", \ logger, "runRgoffset_ampcor") self._insar.setOffsetField(objAmpcor.getOffsetField()) self._insar.setRefinedOffsetField(objAmpcor.getOffsetField()) objAmp.finalizeImage() objSim.finalizeImage()
def run(frame1, frame2, formSlc1, formSlc2, imSlc1, imSlc2, nstages, scale, infos, stdWriter, catalog=None, sceneid='NO_ID'): logger.info( "Calculate offset between slcs using %d stages of ampcor: %s " % (nstages, sceneid)) prf1 = frame1.getInstrument().getPulseRepetitionFrequency() prf2 = frame2.getInstrument().getPulseRepetitionFrequency() nearRange1 = formSlc1.startingRange nearRange2 = formSlc2.startingRange fs1 = frame1.getInstrument().getRangeSamplingRate() fs2 = frame2.getInstrument().getRangeSamplingRate() ###There seems to be no other way of determining image length - Piyush patchSize = infos['patchSize'] numPatches = infos['numberPatches'] valid_az_samples = infos['numberValidPulses'] firstAc = infos['firstSampleAcrossPrf'] firstDown = infos['firstSampleDownPrf'] numLocationAcross = infos['numberLocationAcrossPrf'] numLocationDown = infos['numberLocationDownPrf'] delRg1 = CN.SPEED_OF_LIGHT / (2 * fs1) delRg2 = CN.SPEED_OF_LIGHT / (2 * fs2) grossRg = infos['grossRg'] if grossRg is not None: coarseAcross = grossRg else: coarseRange = (nearRange1 - nearRange2) / delRg2 coarseAcross = int(coarseRange + 0.5) if (coarseRange <= 0): coarseAcross = int(coarseRange - 0.5) grossAz = infos['grossAz'] if grossAz is not None: coarseDown = grossAz else: s1 = formSlc1.mocompPosition[1][0] s1_2 = formSlc1.mocompPosition[1][1] s2 = formSlc2.mocompPosition[1][0] s2_2 = formSlc2.mocompPosition[1][1] coarseAz = int((s1 - s2) / (s2_2 - s2) + prf2 * (1 / prf1 - 1 / prf2) * (patchSize - valid_az_samples) / 2) coarseDown = int(coarseAz + 0.5) if (coarseAz <= 0): coarseDown = int(coarseAz - 0.5) coarseAcross = 0 + coarseAcross coarseDown = 0 + coarseDown mSlc = isceobj.createSlcImage() IU.copyAttributes(imSlc1, mSlc) accessMode = 'read' mSlc.setAccessMode(accessMode) mSlc.createImage() masterWidth = mSlc.getWidth() masterLength = mSlc.getLength() sSlc = isceobj.createSlcImage() IU.copyAttributes(imSlc2, sSlc) accessMode = 'read' sSlc.setAccessMode(accessMode) sSlc.createImage() slaveWidth = sSlc.getWidth() slaveLength = sSlc.getLength() finalIteration = False for iterNum in xrange(nstages - 1, -1, -1): ####Rewind the images try: mSlc.rewind() sSlc.rewind() except: print('Issues when rewinding images.' ) #KK shouldn't it be an error? sys.exit ###### logger.debug('Starting Iteration Stage : %d' % (iterNum)) logger.debug("Gross Across: %s" % (coarseAcross)) logger.debug("Gross Down: %s" % (coarseDown)) ####Clear objs objAmpcor = None objOff = None offField = None objAmpcor = Ampcor() objAmpcor.setImageDataType1('complex') objAmpcor.setImageDataType2('complex') objAmpcor.setFirstPRF(prf1) objAmpcor.setSecondPRF(prf2) objAmpcor.setFirstRangeSpacing(delRg1) objAmpcor.setSecondRangeSpacing(delRg2) #####Scale all the reference and search windows scaleFactor = scale**iterNum objAmpcor.windowSizeWidth *= scaleFactor objAmpcor.windowSizeHeight *= scaleFactor objAmpcor.searchWindowSizeWidth *= scaleFactor objAmpcor.searchWindowSizeHeight *= scaleFactor xMargin = 2 * objAmpcor.searchWindowSizeWidth + objAmpcor.windowSizeWidth yMargin = 2 * objAmpcor.searchWindowSizeHeight + objAmpcor.windowSizeHeight #####Set image limits for search offAc = max(firstAc, -coarseAcross) + xMargin offDn = max(firstDown, -coarseDown) + yMargin offAcmax = int(coarseAcross + ((fs2 / fs1) - 1) * masterWidth) logger.debug("Gross Max Across: %s" % (offAcmax)) lastAc = int(min(masterWidth, slaveWidth - offAcmax) - xMargin) offDnmax = int(coarseDown + ((prf2 / prf1) - 1) * masterLength) logger.debug("Gross Max Down: %s" % (offDnmax)) lastDn = int(min(masterLength, slaveLength - offDnmax) - yMargin) objAmpcor.setFirstSampleAcross(offAc) objAmpcor.setLastSampleAcross(lastAc) objAmpcor.setFirstSampleDown(offDn) objAmpcor.setLastSampleDown(lastDn) objAmpcor.setAcrossGrossOffset(coarseAcross) objAmpcor.setDownGrossOffset(coarseDown) if (offAc > lastAc) or (offDn > lastDn): print('Search window scale is too large.') print('Skipping Scale: %d' % (iterNum + 1)) continue logger.debug('Looks = %d' % scaleFactor) logger.debug('Correlation window sizes: %d %d' % (objAmpcor.windowSizeWidth, objAmpcor.windowSizeHeight)) logger.debug('Search window sizes: %d %d' % (objAmpcor.searchWindowSizeWidth, objAmpcor.searchWindowSizeHeight)) logger.debug(' Across pos: %d %d out of (%d,%d)' % (objAmpcor.firstSampleAcross, objAmpcor.lastSampleAcross, masterWidth, slaveWidth)) logger.debug(' Down pos: %d %d out of (%d,%d)' % (objAmpcor.firstSampleDown, objAmpcor.lastSampleDown, masterLength, slaveLength)) if (iterNum == 0) or finalIteration: if catalog is not None: # Record the inputs isceobj.Catalog.recordInputs(catalog, objAmpcor, "runOffsetprf.%s" % sceneid, logger, "runOffsetprf.%s" % sceneid) objAmpcor.setNumberLocationAcross(numLocationAcross) objAmpcor.setNumberLocationDown(numLocationDown) else: objAmpcor.setNumberLocationAcross(10) objAmpcor.setNumberLocationDown(10) objAmpcor.setAcrossLooks(scaleFactor) objAmpcor.setDownLooks(scaleFactor) objAmpcor.setZoomWindowSize(scale * objAmpcor.zoomWindowSize) objAmpcor.setOversamplingFactor(2) objAmpcor.ampcor(mSlc, sSlc) offField = objAmpcor.getOffsetField() if (iterNum == 0) or finalIteration: if catalog is not None: # Record the outputs isceobj.Catalog.recordOutputs(catalog, objAmpcor, "runOffsetprf.%s" % sceneid, logger, "runOffsetprf.%s" % sceneid) else: objOff = isceobj.createOffoutliers() objOff.wireInputPort(name='offsets', object=offField) objOff.setSNRThreshold(2.0) objOff.setDistance(10) objOff.setStdWriter = stdWriter.set_file_tags( "nstage_offoutliers" + str(iterNum), "log", "err", "out") objOff.offoutliers() coarseAcross = int(objOff.averageOffsetAcross) coarseDown = int(objOff.averageOffsetDown) mSlc.finalizeImage() sSlc.finalizeImage() objOff = None objAmpcor = None return offField