Beispiel #1
0
def runRgoffset(self):
    from isceobj.Catalog import recordInputs, recordOutputs

    coarseAcross = 0
    coarseDown = 0
    numLocationAcross = self._insar.getNumberLocationAcross()
    numLocationDown = self._insar.getNumberLocationDown()
    firstAc = self._insar.getFirstSampleAcross()
    firstDn = self._insar.getFirstSampleDown()

    ampImage = self._insar.getResampAmpImage()
    slaveWidth = ampImage.getWidth()
    slaveLength = ampImage.getLength()
    objAmp = isceobj.createSlcImage()
    objAmp.dataType = 'CFLOAT'
    objAmp.bands = 1
    objAmp.setFilename(ampImage.getFilename())
    objAmp.setAccessMode('read')
    objAmp.setWidth(slaveWidth)
    objAmp.createImage()

    simImage = self._insar.getSimAmpImage()
    masterWidth = simImage.getWidth()
    objSim = isceobj.createImage()
    objSim.setFilename(simImage.getFilename())
    objSim.dataType = 'FLOAT'
    objSim.setWidth(masterWidth)
    objSim.setAccessMode('read')
    objSim.createImage()
    masterLength = simImage.getLength()

    nStageObj = NStage(name='insarapp_intsim_nstage')
    nStageObj.configure()
    nStageObj.setImageDataType1('real')
    nStageObj.setImageDataType2('complex')

    if nStageObj.acrossGrossOffset is None:
        nStageObj.setAcrossGrossOffset(0)

    if nStageObj.downGrossOffset is None:
        nStageObj.setDownGrossOffset(0)

    # Record the inputs
    recordInputs(self._insar.procDoc, nStageObj, "runRgoffset", logger,
                 "runRgoffset")

    nStageObj.nstage(slcImage1=objSim, slcImage2=objAmp)

    recordOutputs(self._insar.procDoc, nStageObj, "runRgoffset", logger,
                  "runRgoffset")

    offField = nStageObj.getOffsetField()

    # save the input offset field for the record
    self._insar.setOffsetField(offField)
    self._insar.setRefinedOffsetField(offField)
Beispiel #2
0
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 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())
Beispiel #5
0
def runOffsetprf(self):
    from isceobj.Catalog import recordInputs, recordOutputs

    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

    print("*****************   runOffsetprf_nstage  **********************")
    print()
    print("self.grossRg, self.grossAz = ", self.grossRg, self.grossAz)
    print()
    print("*****************   runOffsetprf_nstage  **********************")
    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()

    nStageObj = NStage(name='insarapp_slcs_nstage')
    nStageObj.configure()
    nStageObj.setImageDataType1('complex')
    nStageObj.setImageDataType2('complex')
    nStageObj.setFirstPRF(prf1)
    nStageObj.setSecondPRF(prf2)
    nStageObj.setFirstRangeSpacing(delRg1)
    nStageObj.setSecondRangeSpacing(delRg2)

    if nStageObj.acrossGrossOffset is None:
        nStageObj.setAcrossGrossOffset(coarseAcross)

    if nStageObj.downGrossOffset is None:
        nStageObj.setDownGrossOffset(coarseDown)

    recordInputs(self._insar.procDoc, nStageObj, "runOffsetprf", logger,
                 "runOffsetprf")

    nStageObj.nstage(slcImage1=mSlc, slcImage2=sSlc)

    recordOutputs(self._insar.procDoc, nStageObj, "runOffsetprf", logger,
                  "runOffsetprf")
    offField = nStageObj.getOffsetField()
    # save the input offset field for the record
    self._insar.setOffsetField(offField)
    self._insar.setRefinedOffsetField(offField)