def run(imageAmp, imageSim, prf, infos, stdWriter, catalog=None, sceneid='NO_ID'): logger.info("Running Rgoffset: %s" % sceneid) firstAc = infos['firstSampleAcross'] firstDown = infos['firstSampleDown'] numLocationAcross = infos['numberLocationAcross'] numLocationDown = infos['numberLocationDown'] objAmp = isceobj.createIntImage() IU.copyAttributes(imageAmp, objAmp) objAmp.setAccessMode('read') objAmp.createImage() widthAmp = objAmp.getWidth() intLength = objAmp.getLength() lastAc = widthAmp - firstAc lastDown = intLength - firstDown objSim = isceobj.createImage() IU.copyAttributes(imageSim, objSim) objSim.setAccessMode('read') objSim.createImage() objOffset = isceobj.createEstimateOffsets() objOffset.setSearchWindowSize(infos['offsetSearchWindowSize'], infos['sensorName']) objOffset.setFirstSampleAcross(firstAc) objOffset.setLastSampleAcross(lastAc) objOffset.setNumberLocationAcross(numLocationAcross) objOffset.setFirstSampleDown(firstDown) objOffset.setLastSampleDown(lastDown) objOffset.setNumberLocationDown(numLocationDown) #set the tag used in the outfile. each message is precided by this tag #if the writer is not of "file" type the call has no effect objOffset.stdWriter = stdWriter.set_file_tags("rgoffset", "log", "err", "out") objOffset.setFirstPRF(prf) objOffset.setSecondPRF(prf) objOffset.setAcrossGrossOffset(0) objOffset.setDownGrossOffset(0) objOffset.estimateoffsets(image1=objSim, image2=objAmp, band1=0, band2=0) if catalog is not None: # Record the inputs and outputs isceobj.Catalog.recordInputsAndOutputs(catalog, objOffset, "runRgoffset.%s" % sceneid, logger, "runRgoffset.%s" % sceneid) objAmp.finalizeImage() objSim.finalizeImage() return objOffset.getOffsetField()
def run(frame1, frame2, orbit1, orbit2, formSlc1, formSlc2, imSlc1, imSlc2, infos, catalog=None, sceneid='NO_ID'): logger.info("Calculate offset between slcs: %s" % sceneid) prf1 = frame1.getInstrument().getPulseRepetitionFrequency() prf2 = frame2.getInstrument().getPulseRepetitionFrequency() nearRange1 = formSlc1.startingRange nearRange2 = formSlc2.startingRange fs1 = frame1.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'] widthSlc = imSlc1.getWidth() coarseRange = (nearRange1 - nearRange2) / (CN.SPEED_OF_LIGHT / (2 * fs1)) coarseAcross = int(coarseRange + 0.5) if (coarseRange <= 0): coarseAcross = int(coarseRange - 0.5) grossRg = infos['grossRg'] print("gross Rg: ", grossRg) if grossRg is not None: coarseAcross = grossRg time1, schPosition1, schVelocity1, offset1 = orbit1._unpackOrbit() time2, schPosition2, schVelocity2, offset2 = orbit2._unpackOrbit() s1 = schPosition1[0][0] s1_2 = schPosition1[1][0] s2 = schPosition2[0][0] s2_2 = schPosition2[1][0] coarseAz = int((s1 - s2) / (s2_2 - s2) + prf1 * (1 / prf1 - 1 / prf2) * (patchSize - valid_az_samples) / 2) coarseDown = int(coarseAz + 0.5) if (coarseAz <= 0): coarseDown = int(coarseAz - 0.5) grossAz = infos['grossAz'] print("gross Az: ", grossAz) if grossAz is not None: coarseDown = grossAz coarseAcross = 0 + coarseAcross coarseDown = 0 + coarseDown logger.debug("Gross Across: %s" % (coarseAcross)) logger.debug("Gross Down: %s" % (coarseDown)) offAc = max(firstAc, coarseAcross) offDn = max(firstDown, coarseDown) lastAc = widthSlc - offAc lastDown = (numPatches * valid_az_samples) - offDn mSlc = isceobj.createSlcImage() IU.copyAttributes(imSlc1, mSlc) accessMode = 'read' mSlc.setAccessMode(accessMode) mSlc.createImage() sSlc = isceobj.createSlcImage() IU.copyAttributes(imSlc2, sSlc) accessMode = 'read' sSlc.setAccessMode(accessMode) sSlc.createImage() objOffset = isceobj.createEstimateOffsets() objOffset.setSearchWindowSize(infos['offsetSearchWindowSize'], infos['sensorName']) objOffset.setFirstSampleAcross(offAc) objOffset.setLastSampleAcross(lastAc) objOffset.setNumberLocationAcross(numLocationAcross) objOffset.setFirstSampleDown(offDn) objOffset.setLastSampleDown(lastDown) objOffset.setNumberLocationDown(numLocationDown) objOffset.setAcrossGrossOffset(coarseAcross) objOffset.setDownGrossOffset(coarseDown) objOffset.setFirstPRF(prf1) objOffset.setSecondPRF(prf2) if catalog is not None: # Record the inputs isceobj.Catalog.recordInputs(catalog, objOffset, "runOffsetprf.%s" % sceneid, logger, "runOffsetprf.%s" % sceneid) objOffset.estimateoffsets(image1=mSlc, image2=sSlc, band1=0, band2=0) if catalog is not None: # Record the outputs isceobj.Catalog.recordOutputs(catalog, objOffset, "runOffsetprf.%s" % sceneid, logger, "runOffsetprf.%s" % sceneid) mSlc.finalizeImage() sSlc.finalizeImage() return objOffset.getOffsetField()
def run(imageAmp, imageSim, prf, infos, stdWriter, catalog=None, sceneid='NO_ID'): logger.info("Running Rgoffset: %s" % sceneid) firstAc = infos['firstSampleAcross'] firstDown = infos['firstSampleDown'] numLocationAcross = infos['numberLocationAcross'] numLocationDown = infos['numberLocationDown'] objAmp = isceobj.createIntImage() IU.copyAttributes(imageAmp, objAmp) objAmp.setAccessMode('read') objAmp.createImage() widthAmp = objAmp.getWidth() intLength = objAmp.getLength() lastAc = widthAmp - firstAc lastDown = intLength - firstDown objSim = isceobj.createImage() IU.copyAttributes(imageSim, objSim) objSim.setAccessMode('read') objSim.createImage() # Start modify from here ML 2014-08-05 #objOffset = isceobj.createEstimateOffsets() objOffset = isceobj.createEstimateOffsets( name='insarapp_intsim_estoffset') #ML 2014-08-05 objOffset.configure() if objOffset.acrossGrossOffset is not None: coarseAcross = objOffset.acrossGrossOffset else: coarseAcross = 0 if objOffset.downGrossOffset is not None: coarseDown = objOffset.downGrossOffset else: coarseDown = 0 if objOffset.searchWindowSize is None: objOffset.setSearchWindowSize(infos['offsetSearchWindowSize'], infos['sensorName']) margin = 2 * objOffset.searchWindowSize + objOffset.windowSize simWidth = objSim.getWidth() simLength = objSim.getLength() firAc = max(firstAc, -coarseAcross) + margin + 1 firDn = max(firstDown, -coarseDown) + margin + 1 lastAc = int(min(widthAmp, simWidth - coarseAcross) - margin - 1) lastDn = int(min(intLength, simLength - coarseDown) - margin - 1) if not objOffset.firstSampleAcross: objOffset.setFirstSampleAcross(firAc) if not objOffset.lastSampleAcross: objOffset.setLastSampleAcross(lastAc) if not objOffset.numberLocationAcross: objOffset.setNumberLocationAcross(numLocationAcross) if not objOffset.firstSampleDown: objOffset.setFirstSampleDown(firDn) if not objOffset.lastSampleDown: objOffset.setLastSampleDown(lastDn) if not objOffset.numberLocationDown: objOffset.setNumberLocationDown(numLocationDown) # # old isceApp --- from here down # objOffset.setSearchWindowSize(infos['offsetSearchWindowSize'], infos['sensorName']) # objOffset.setFirstSampleAcross(firstAc) # objOffset.setLastSampleAcross(lastAc) # objOffset.setNumberLocationAcross(numLocationAcross) # objOffset.setFirstSampleDown(firstDown) # objOffset.setLastSampleDown(lastDown) # objOffset.setNumberLocationDown(numLocationDown) # #set the tag used in the outfile. each message is precided by this tag # #if the writer is not of "file" type the call has no effect objOffset.stdWriter = stdWriter.set_file_tags("rgoffset", "log", "err", "out") # objOffset.setFirstPRF(prf) # objOffset.setSecondPRF(prf) # objOffset.setAcrossGrossOffset(0) # objOffset.setDownGrossOffset(0) # objOffset.estimateoffsets(image1=objSim, image2=objAmp, band1=0, band2=0) ##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") ##objOffset.setStdWriter(self._stdWriter) ##prf = self._insar.getReferenceFrame().getInstrument().getPulseRepetitionFrequency() objOffset.setFirstPRF(prf) objOffset.setSecondPRF(prf) if not objOffset.acrossGrossOffset: objOffset.setAcrossGrossOffset(0) if not objOffset.downGrossOffset: objOffset.setDownGrossOffset(0) objOffset.estimateoffsets(image1=objSim, image2=objAmp, band1=0, band2=0) if catalog is not None: # Record the inputs and outputs isceobj.Catalog.recordInputsAndOutputs(catalog, objOffset, "runRgoffset.%s" % sceneid, logger, "runRgoffset.%s" % sceneid) objAmp.finalizeImage() objSim.finalizeImage() return objOffset.getOffsetField()
def runOffsetprf(self): from isceobj.Catalog import recordInputs logger.info("Calculate offset between slcs") 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() ###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() objSlc = self._insar.getMasterSlcImage() # widthSlc = max(self._insar.getMasterSlcImage().getWidth(), # self._insar.getSlaveSlcImage().getWidth()) widthSlc = self._insar.getMasterSlcImage().getWidth() coarseRange = (nearRange1 - nearRange2) / (CN.SPEED_OF_LIGHT / (2 * fs1)) coarseAcross = int(coarseRange + 0.5) if (coarseRange <= 0): coarseAcross = int(coarseRange - 0.5) pass print("gross Rg: ", self.grossRg) if self.grossRg is not None: coarseAcross = self.grossRg pass time1, schPosition1, schVelocity1, offset1 = masterOrbit._unpackOrbit() time2, schPosition2, schVelocity2, offset2 = slaveOrbit._unpackOrbit() s1 = schPosition1[0][0] s1_2 = schPosition1[1][0] s2 = schPosition2[0][0] s2_2 = schPosition2[1][0] 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 print("gross Az: ", self.grossAz) 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) # scheme = 'BIL' # mSlc.setInterleavedScheme(scheme) #Faster access with bands accessMode = 'read' mSlc.setAccessMode(accessMode) mSlc.createImage() sSlcImage = self._insar.getSlaveSlcImage() sSlc = isceobj.createSlcImage() IU.copyAttributes(sSlcImage, sSlc) # scheme = 'BIL' # sSlc.setInterleavedScheme(scheme) #Faster access with bands accessMode = 'read' sSlc.setAccessMode(accessMode) sSlc.createImage() objOffset = isceobj.createEstimateOffsets(name='insarapp_slcs_estoffset') objOffset.configure() if not objOffset.searchWindowSize: objOffset.setSearchWindowSize(self.offsetSearchWindowSize, self.sensorName) margin = 2 * objOffset.searchWindowSize + objOffset.windowSize offAc = max(firstAc, -coarseAcross) + margin + 1 offDn = max(firstDown, -coarseDown) + margin + 1 mWidth = mSlc.getWidth() sWidth = sSlc.getWidth() mLength = mSlc.getLength() sLength = sSlc.getLength() offDnmax = int(coarseDown + ((prf2 / prf1) - 1) * mLength) lastAc = int(min(mWidth, sWidth - coarseAcross) - margin - 1) lastDown = int(min(mLength, sLength - offDnmax) - margin - 1) if not objOffset.firstSampleAcross: objOffset.setFirstSampleAcross(offAc) if not objOffset.lastSampleAcross: objOffset.setLastSampleAcross(lastAc) if not objOffset.firstSampleDown: objOffset.setFirstSampleDown(offDn) if not objOffset.lastSampleDown: objOffset.setLastSampleDown(lastDown) if not objOffset.numberLocationAcross: objOffset.setNumberLocationAcross(numLocationAcross) if not objOffset.numberLocationDown: objOffset.setNumberLocationDown(numLocationDown) if not objOffset.acrossGrossOffset: objOffset.setAcrossGrossOffset(coarseAcross) if not objOffset.downGrossOffset: objOffset.setDownGrossOffset(coarseDown) ###Always set these values objOffset.setFirstPRF(prf1) objOffset.setSecondPRF(prf2) # Record the inputs recordInputs(self._insar.procDoc, objOffset, "runOffsetprf", logger, "runOffsetprf") objOffset.estimateoffsets(image1=mSlc, image2=sSlc, band1=0, band2=0) # Record the outputs from isceobj.Catalog import recordOutputs recordOutputs(self._insar.procDoc, objOffset, "runOffsetprf", logger, "runOffsetprf") mSlc.finalizeImage() sSlc.finalizeImage() # save the input offset field for the record self._insar.setOffsetField(objOffset.getOffsetField()) self._insar.setRefinedOffsetField(objOffset.getOffsetField())
def runOffsetprf(self): from isceobj.Catalog import recordInputs logger.info("Calculate offset between slcs") masterFrame = self._insar.getMasterFrame() slaveFrame = self._insar.getSlaveFrame() prf1 = masterFrame.getInstrument().getPulseRepetitionFrequency() prf2 = slaveFrame.getInstrument().getPulseRepetitionFrequency() fs1 = masterFrame.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() objSlc = self._insar.formSLC1.slcImage # widthSlc = max(self._insar.getMasterSlcImage().getWidth(), # self._insar.getSlaveSlcImage().getWidth()) widthSlc = objSlc.getWidth() try: bObj = Baseline() bObj.configure() bObj.baselineLocation = 'top' bObj.wireInputPort(name='masterFrame', object=masterFrame) bObj.wireInputPort(name='slaveFrame', object=slaveFrame) azoff, rgoff = bObj.baseline() coarseAcross = np.mean(rgoff) coarseDown = np.mean(azoff) except: bObj = Baseline() bObj.configure() bObj.baselineLocation = 'top' bObj.wireInputPort(name='masterFrame', object=slaveFrame) bObj.wireInputPort(name='slaveFrame', object=masterFrame) azoff, rgoff = bObj.baseline() coarseAcross = -np.mean(rgoff) coarseDown = -np.mean(azoff) print("gross Rg: ",self.grossRg) if self.grossRg is not None: coarseAcross = self.grossRg pass print("gross Az: ", self.grossAz) if self.grossAz is not None: coarseDown = self.grossAz pass coarseAcross = 0 + coarseAcross coarseDown = 0 + coarseDown mSlcImage = self._insar.formSLC1.slcImage mSlc = isceobj.createSlcImage() IU.copyAttributes(mSlcImage, mSlc) # scheme = 'BIL' # mSlc.setInterleavedScheme(scheme) #Faster access with bands accessMode = 'read' mSlc.setAccessMode(accessMode) mSlc.createImage() sSlcImage = self._insar.formSLC2.slcImage sSlc = isceobj.createSlcImage() IU.copyAttributes(sSlcImage, sSlc) # scheme = 'BIL' # sSlc.setInterleavedScheme(scheme) #Faster access with bands accessMode = 'read' sSlc.setAccessMode(accessMode) sSlc.createImage() objOffset = isceobj.createEstimateOffsets(name='insarapp_slcs_estoffset') objOffset.configure() if objOffset.acrossGrossOffset is not None: coarseAcross = objOffset.acrossGrossOffset if objOffset.downGrossOffset is not None: coarseDown = objOffset.downGrossOffset if not objOffset.searchWindowSize: objOffset.setSearchWindowSize(self.offsetSearchWindowSize, self.sensorName) margin = 2*objOffset.searchWindowSize + objOffset.windowSize offAc = max(firstAc,-coarseAcross)+margin+1 offDn = max(firstDown,-coarseDown)+margin+1 mWidth = mSlc.getWidth() sWidth = sSlc.getWidth() mLength = mSlc.getLength() sLength = sSlc.getLength() offDnmax = int(coarseDown + ((prf2/prf1)-1)*mLength) lastAc = int(min(mWidth, sWidth-coarseAcross) - margin-1) lastDown = int(min(mLength, sLength-offDnmax) - margin-1) if not objOffset.firstSampleAcross: objOffset.setFirstSampleAcross(offAc) if not objOffset.lastSampleAcross: objOffset.setLastSampleAcross(lastAc) if not objOffset.firstSampleDown: objOffset.setFirstSampleDown(offDn) if not objOffset.lastSampleDown: objOffset.setLastSampleDown(lastDown) if not objOffset.numberLocationAcross: objOffset.setNumberLocationAcross(numLocationAcross) if not objOffset.numberLocationDown: objOffset.setNumberLocationDown(numLocationDown) if not objOffset.acrossGrossOffset: objOffset.setAcrossGrossOffset(coarseAcross) if not objOffset.downGrossOffset: objOffset.setDownGrossOffset(coarseDown) ###Always set these values objOffset.setFirstPRF(prf1) objOffset.setSecondPRF(prf2) # Record the inputs recordInputs(self._insar.procDoc, objOffset, "runOffsetprf", logger, "runOffsetprf") objOffset.estimateoffsets(image1=mSlc,image2=sSlc,band1=0,band2=0) # Record the outputs from isceobj.Catalog import recordOutputs recordOutputs(self._insar.procDoc, objOffset, "runOffsetprf", logger, "runOffsetprf") mSlc.finalizeImage() sSlc.finalizeImage() # save the input offset field for the record self._insar.setOffsetField(objOffset.getOffsetField()) self._insar.setRefinedOffsetField(objOffset.getOffsetField())
def runRgoffset(self): firstAc = self._insar.getFirstSampleAcross() firstDown = self._insar.getFirstSampleDown() numLocationAcross = self._insar.getNumberLocationAcross() numLocationDown = self._insar.getNumberLocationDown() imageAmp = self._insar.getResampAmpImage() objAmp = isceobj.createIntImage() IU.copyAttributes(imageAmp, objAmp) objAmp.setAccessMode('read') objAmp.createImage() widthAmp = objAmp.getWidth() intLength = objAmp.getLength() lastAc = widthAmp - firstAc lastDown = intLength - firstDown imageSim = self._insar.getSimAmpImage() objSim = isceobj.createImage() IU.copyAttributes(imageSim, objSim) objSim.setAccessMode('read') objSim.createImage() objOffset = isceobj.createEstimateOffsets(name='insarapp_intsim_estoffset') objOffset.configure() if objOffset.acrossGrossOffset is not None: coarseAcross = objOffset.acrossGrossOffset else: coarseAcross = 0 if objOffset.downGrossOffset is not None: coarseDown = objOffset.downGrossOffset else: coarseDown = 0 if objOffset.searchWindowSize is None: objOffset.setSearchWindowSize(self.offsetSearchWindowSize, self.sensorName) margin = 2 * objOffset.searchWindowSize + objOffset.windowSize simWidth = objSim.getWidth() simLength = objSim.getLength() firAc = max(firstAc, -coarseAcross) + margin + 1 firDn = max(firstDown, -coarseDown) + margin + 1 lastAc = int(min(widthAmp, simWidth - coarseAcross) - margin - 1) lastDn = int(min(intLength, simLength - coarseDown) - margin - 1) if not objOffset.firstSampleAcross: objOffset.setFirstSampleAcross(firAc) if not objOffset.lastSampleAcross: objOffset.setLastSampleAcross(lastAc) if not objOffset.numberLocationAcross: objOffset.setNumberLocationAcross(numLocationAcross) if not objOffset.firstSampleDown: objOffset.setFirstSampleDown(firDn) if not objOffset.lastSampleDown: objOffset.setLastSampleDown(lastDn) if not objOffset.numberLocationDown: objOffset.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") objOffset.setStdWriter(self._stdWriter) prf = self._insar.getMasterFrame().getInstrument( ).getPulseRepetitionFrequency() objOffset.setFirstPRF(prf) objOffset.setSecondPRF(prf) if not objOffset.acrossGrossOffset: objOffset.setAcrossGrossOffset(0) if not objOffset.downGrossOffset: objOffset.setDownGrossOffset(0) objOffset.estimateoffsets(image1=objSim, image2=objAmp, band1=0, band2=0) # Record the inputs and outputs from isceobj.Catalog import recordInputsAndOutputs recordInputsAndOutputs(self._insar.procDoc, objOffset, "runRgoffset", \ logger, "runRgoffset") self._insar.setOffsetField(objOffset.getOffsetField()) self._insar.setRefinedOffsetField(objOffset.getOffsetField()) objAmp.finalizeImage() objSim.finalizeImage()