def runEstimateHeights(self):
    from isceobj.Catalog import recordInputsAndOutputs
    chv = []
    for frame, orbit, tag in zip((self._insar.getMasterFrame(),
                                  self._insar.getSlaveFrame()),
                                 (self.insar.masterOrbit,
                                  self.insar.slaveOrbit),
                                 ('master', 'slave')):

        (time, position, velocity, offset) = orbit._unpackOrbit()

        half = len(position)//2 - 1
        xyz = position[half]
        import math
        sch = frame._ellipsoid.xyz_to_sch(xyz)

        chv.append(stdproc.createCalculateFdHeights())
        chv[-1].height = sch[2]

        recordInputsAndOutputs(self.procDoc, chv[-1],
                               "runEstimateHeights.CHV_"+tag, logger,
                               "runEstimateHeights.CHV_"+tag)

    self.insar.fdH1, self.insar.fdH2 = [item.height for item in chv]
    return None
Exemplo n.º 2
0
def runOrbit2sch_new(self):
    from isceobj.Catalog import recordInputsAndOutputs
    logger.info("Converting the orbit to SCH coordinates")
    pegHAvg = self.insar.averageHeight
    peg = self.insar.peg
    planet = self.insar.planet

    masterOrbit = self.insar.masterOrbit
    slaveOrbit = self.insar.slaveOrbit

    objOrbit2sch1 = stdproc.createOrbit2sch(averageHeight=pegHAvg)
    objOrbit2sch1.stdWriter = self.stdWriter.set_file_tags(
        "orbit2sch", "log", "err", "log")
    objOrbit2sch2 = stdproc.createOrbit2sch(averageHeight=pegHAvg)
    objOrbit2sch2.stdWriter = self.stdWriter

    ## loop over master/slave orbits
    for obj, orb, tag in zip((objOrbit2sch1, objOrbit2sch2),
                             (self.insar.masterOrbit, self.insar.slaveOrbit),
                             ('master', 'slave')):
        obj(planet=planet, orbit=orb, peg=peg)
        recordInputsAndOutputs(self.insar.procDoc, obj, "runOrbit2sch." + tag,
                               logger, "runOrbit2sch." + tag)

    self.insar.masterOrbit = objOrbit2sch1.orbit
    self.insar.slaveOrbit = objOrbit2sch2.orbit
    return None
Exemplo n.º 3
0
def runOrbit2sch(self):
    from isceobj.Catalog import recordInputsAndOutputs
    import numpy
    logger.info("Converting the orbit to SCH coordinates")

    # Piyush
    ####We don't know the correct SCH heights yet.
    ####Not computing average peg height yet.
    peg = self.insar.peg
    pegHavg = self.insar.averageHeight
    planet = self.insar.planet

#    if self.pegSelect.upper() == 'MASTER':
#        pegHavg = self.insar.getFirstAverageHeight()
#    elif self.pegSelect.upper() == 'SLAVE':
#        pegHavg = self.insar.getSecondAverageHeight()
#    elif self.pegSelect.upper() == 'AVERAGE':
#        pegHavg = self.insar.averageHeight
#    else:
#        raise Exception('Unknown peg selection method: ', self.pegSelect)

    masterOrbit = self.insar.masterOrbit
    slaveOrbit = self.insar.slaveOrbit

    objOrbit2sch1 = stdproc.createOrbit2sch(averageHeight=pegHavg)
    objOrbit2sch1.stdWriter = self.stdWriter.set_file_tags("orbit2sch",
                                                           "log",
                                                           "err",
                                                           "log")
    objOrbit2sch2 = stdproc.createOrbit2sch(averageHeight=pegHavg)
    objOrbit2sch2.stdWriter = self.stdWriter

    ## loop over master/slave orbits
    for obj, orb, tag, order in zip((objOrbit2sch1, objOrbit2sch2),
                                    (self.insar.masterOrbit, self.insar.slaveOrbit),
                                    ('master', 'slave'),
                                    ('First', 'Second')):
        obj(planet=planet, orbit=orb, peg=peg)
        recordInputsAndOutputs(self.insar.procDoc, obj,
                               "runOrbit2sch." + tag,
                               logger,
                               "runOrbit2sch." + tag)

        #equivalent to self.insar.masterOrbit =
        setattr(self.insar,'%sOrbit'%(tag), obj.orbit)

        #Piyush
        ####The heights and the velocities need to be updated now.
        (ttt, ppp, vvv, rrr) = obj.orbit._unpackOrbit()

        #equivalent to self.insar.setFirstAverageHeight()
        # SCH heights replacing the earlier llh heights
        # getattr(self.insar,'set%sAverageHeight'%(order))(numpy.sum(numpy.array(ppp),axis=0)[2] /(1.0*len(ppp)))

        #equivalent to self.insar.setFirstProcVelocity()
        getattr(self.insar,'set%sProcVelocity'%(order))(vvv[len(vvv)//2][0])

    return None
Exemplo n.º 4
0
def master(self, deltaf=None):
    from isceobj.Catalog import recordInputsAndOutputs
    from iscesys.ImageUtil.ImageUtil import ImageUtil as IU




    v,h = self.insar.vh()
   
    objRaw = self.insar.rawMasterIQImage.clone()
    objRaw.accessMode = 'read'
    objFormSlc = stdproc.createFormSLC(name='insarapp_formslc_master')
    objFormSlc.setBodyFixedVelocity(v)
    objFormSlc.setSpacecraftHeight(h)
    objFormSlc.setAzimuthPatchSize(self.patchSize)
    objFormSlc.setNumberValidPulses(self.goodLines)
    objFormSlc.setNumberPatches(self.numPatches)
    objFormSlc.setLookSide(self.insar._lookSide)
    objFormSlc.setNumberAzimuthLooks(self.insar.numberAzimuthLooks)
    logger.info("Focusing Master image")
    objFormSlc.stdWriter = self.stdWriter

    if (deltaf is not None) and (objFormSlc.azimuthResolution is None):
        ins = self.insar.masterFrame.getInstrument()
        prf = ins.getPulseRepetitionFrequency()
        res = ins.getPlatform().getAntennaLength() / 2.0
        azbw = min(v/res, prf)
        res = v/azbw 

        factor = 1.0 - (abs(deltaf)/azbw)
        logger.info('MASTER AZIMUTH BANDWIDTH FACTOR = %f'%(factor))
        azres = res / factor
        #jng This is a temporary solution seems it looks that same banding problem
        #can be resolved by doubling the azres. The default azResFactor  is still one.
        objFormSlc.setAzimuthResolution(azres*self.insar.azResFactor)
   
    ####newInputs
    objSlc = objFormSlc(rawImage=objRaw,
                orbit=self.insar.masterOrbit,
                frame=self.insar.masterFrame,
                planet=self.insar.masterFrame.instrument.platform.planet,
                doppler=self.insar.dopplerCentroid,
                peg=self.insar.peg)

    imageSlc = isceobj.createSlcImage()
    IU.copyAttributes(objSlc, imageSlc)
    imageSlc.setAccessMode('read')
    objSlc.finalizeImage()
    objRaw.finalizeImage()
    recordInputsAndOutputs(self.insar.procDoc, objFormSlc,
        "runFormSLC.master", logger, "runFormSLC.master")

    logger.info('New Width = %d'%(imageSlc.getWidth()))
    self.insar.masterSlcImage = imageSlc
    self.insar.formSLC1 = objFormSlc
    return objFormSlc.numberPatches
Exemplo n.º 5
0
def secondary(self, deltaf=None):
    from isceobj.Catalog import recordInputsAndOutputs
    from iscesys.ImageUtil.ImageUtil import ImageUtil as IU

    v, h = self.insar.vh()

    objRaw = self.insar.rawSecondaryIQImage.clone()
    objRaw.accessMode = 'read'
    objFormSlc = stdproc.createFormSLC(name='insarapp_formslc_secondary')
    objFormSlc.setBodyFixedVelocity(v)
    objFormSlc.setSpacecraftHeight(h)
    objFormSlc.setAzimuthPatchSize(self.patchSize)
    objFormSlc.setNumberValidPulses(self.goodLines)
    objFormSlc.setNumberPatches(self.numPatches)
    objFormSlc.setNumberAzimuthLooks(self.insar.numberAzimuthLooks)
    objFormSlc.setLookSide(self.insar._lookSide)
    logger.info("Focusing Reference image")
    objFormSlc.stdWriter = self.stdWriter

    if (deltaf is not None) and (objFormSlc.azimuthResolution is None):
        ins = self.insar.secondaryFrame.getInstrument()
        prf = ins.getPulseRepetitionFrequency()
        res = ins.getPlatform().getAntennaLength() / 2.0
        azbw = min(v / res, prf)
        res = v / azbw
        factor = 1.0 - (abs(deltaf) / azbw)
        logger.info('SECONDARY AZIMUTH BANDWIDTH FACTOR = %f' % (factor))
        azres = res / factor
        objFormSlc.setAzimuthResolution(azres)

    objSlc = objFormSlc(
        rawImage=objRaw,
        orbit=self.insar.secondaryOrbit,
        frame=self.insar.secondaryFrame,
        planet=self.insar.secondaryFrame.instrument.platform.planet,
        doppler=self.insar.dopplerCentroid,
        peg=self.insar.peg)

    imageSlc = isceobj.createSlcImage()
    IU.copyAttributes(objSlc, imageSlc)
    imageSlc.setAccessMode('read')
    objSlc.finalizeImage()
    objRaw.finalizeImage()
    recordInputsAndOutputs(self.insar.procDoc, objFormSlc,
                           "runFormSLC.secondary", logger,
                           "runFormSLC.secondary")

    logger.info('New Width = %d' % (imageSlc.getWidth()))
    self.insar.secondarySlcImage = imageSlc
    self.insar.formSLC2 = objFormSlc
    return objFormSlc.numberPatches
Exemplo n.º 6
0
def runEstimateHeights(self):
    from isceobj.Catalog import recordInputsAndOutputs
    chv = []
    for frame, orbit, tag in zip(
        (self._insar.getMasterFrame(), self._insar.getSlaveFrame()),
        (self.insar.masterOrbit, self.insar.slaveOrbit), ('master', 'slave')):
        chv.append(stdproc.createCalculateFdHeights())
        chv[-1](frame=frame, orbit=orbit, planet=self.planet)

        recordInputsAndOutputs(self.procDoc, chv[-1],
                               "runEstimateHeights.CHV_" + tag, logger,
                               "runEstimateHeights.CHV_" + tag)

    self.insar.fdH1, self.insar.fdH2 = [item.height for item in chv]
    return None
def runShadecpx2rg(self):

    imageAmp = self._insar.getResampAmpImage()
    widthAmp = imageAmp.getWidth()
    endian = self._insar.getMachineEndianness()

    filenameSimAmp = self._insar.getSimAmpImageName()
    objSimAmp = isceobj.createImage()
    widthSimAmp = widthAmp
    objSimAmp.initImage(filenameSimAmp, 'read', widthSimAmp, 'FLOAT')

    imageSimAmp = isceobj.createImage()
    IU.copyAttributes(objSimAmp, imageSimAmp)
    self._insar.setSimAmpImage(imageSimAmp)
    objSimAmp.setAccessMode('write')
    objSimAmp.createImage()
    filenameHt = self._insar.getHeightFilename()
    widthHgtImage = widthAmp  # they have same width by construction
    objHgtImage = isceobj.createImage()
    objHgtImage.initImage(filenameHt, 'read', widthHgtImage, 'FLOAT')
    imageHgt = isceobj.createImage()
    IU.copyAttributes(objHgtImage, imageHgt)
    self._insar.setHeightTopoImage(imageHgt)

    objHgtImage.createImage()

    logger.info("Running Shadecpx2rg")
    objShade = isceobj.createSimamplitude()
    #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("simamplitude", "log")
    self._stdWriter.setFileTag("simamplitude", "err")
    self._stdWriter.setFileTag("simamplitude", "out")
    objShade.setStdWriter(self._stdWriter)

    shade = self._insar.getShadeFactor()

    objShade.simamplitude(objHgtImage, objSimAmp, shade=shade)

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objShade, "runSimamplitude", \
                  logger, "runSimamplitude")

    objHgtImage.finalizeImage()
    objSimAmp.finalizeImage()
    objSimAmp.renderHdr()
Exemplo n.º 8
0
def runOffoutliers(self, distance, errorLimit=100):
    #offoutliers returns a list of modified locations
    #the list of lists is
    #list[0] = location across
    #list[1] = location  across offset
    #list[2] = location down
    #list[3] = location  down offset
    #list[4] = snr
    #list[5] = sig
    logger.info('Error limit = %d' % (errorLimit))
    warnLimit = errorLimit * 3
    logger.info("Culling offset field outliers")
    rgOffsets = self._insar.getRefinedOffsetField()
    logger.info('Number of input offsets: %d' % (len(rgOffsets._offsets)))
    logger.info('Distance: %f' % (distance))
    objOff = isceobj.createOffoutliers()
    objOff.wireInputPort(name='offsets', object=rgOffsets)
    objOff.setSNRThreshold(2.0)
    objOff.setDistance(distance)
    #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("offoutliers", "log")
    self._stdWriter.setFileTag("offoutliers", "err")
    self._stdWriter.setFileTag("offoutliers", "out")
    objOff.setStdWriter(self._stdWriter)

    objOff.offoutliers()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objOff, "runOffoutliers",
                           logger, "runOffoutliers")

    refinedOffsets = objOff.getRefinedOffsetField()
    lenOut = len(refinedOffsets._offsets)
    logger.info('Number of offsets left after culling: %d' % (lenOut))
    if lenOut < errorLimit:
        logger.error(
            'Small number of output Offsets after culling: %d .\n Increase number of windows (or) window sizes (or) provide gross offset manually.'
            % (lenOut))
        raise Exception('Offset estimation Failed.')
    elif lenOut < warnLimit:
        logger.warn(
            'Number of output offsets after culling are low: %d. Might be ok to continue.'
            % (lenOut))

    self._insar.setRefinedOffsetField(refinedOffsets)
Exemplo n.º 9
0
def runMocompbaseline(self):
    logger.info("Calculating Baseline")
    ellipsoid = self._insar.getMasterFrame().getInstrument().getPlatform(
    ).getPlanet().get_elp()
    # schPositions computed in orbit2sch
    # objFormSlc's  created during formSlc

    h = self.insar.averageHeight
    objFormSlc1 = self.insar.formSLC1
    objFormSlc2 = self.insar.formSLC2
    mocompPosition1 = objFormSlc1.getMocompPosition()
    mocompIndex1 = objFormSlc1.getMocompIndex()
    mocompPosition2 = objFormSlc2.getMocompPosition()
    mocompIndex2 = objFormSlc2.getMocompIndex()

    objMocompbaseline = stdproc.createMocompbaseline()

    objMocompbaseline.setMocompPosition1(mocompPosition1[posIndx])
    objMocompbaseline.setMocompPositionIndex1(mocompIndex1)
    objMocompbaseline.setMocompPosition2(mocompPosition2[posIndx])
    objMocompbaseline.setMocompPositionIndex2(mocompIndex2)

    objMocompbaseline.wireInputPort(name='masterOrbit',
                                    object=self.insar.masterOrbit)
    objMocompbaseline.wireInputPort(name='slaveOrbit',
                                    object=self.insar.slaveOrbit)
    objMocompbaseline.wireInputPort(name='ellipsoid', object=ellipsoid)
    objMocompbaseline.wireInputPort(name='peg', object=self.insar.peg)
    objMocompbaseline.setHeight(h)

    #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("mocompbaseline", "log")
    self._stdWriter.setFileTag("mocompbaseline", "err")
    self._stdWriter.setFileTag("mocompbaseline", "out")
    objMocompbaseline.setStdWriter(self._stdWriter)

    objMocompbaseline.mocompbaseline()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objMocompbaseline,
                           "runMocompbaseline", logger, "runMocompbaseline")

    self.insar.mocompBaseline = objMocompbaseline
    return None
Exemplo n.º 10
0
def runSetmocomppath_new(self, peg=None):
    from isceobj.Location.Peg import Peg
    from stdproc.orbit.pegManipulator import averagePeg
    from isceobj.Catalog import recordInputsAndOutputs

    logger.info("Selecting individual peg points")

    planet = self._insar.getMasterFrame().getInstrument().getPlatform(
    ).getPlanet()
    masterOrbit = self._insar.getMasterOrbit()
    slaveOrbit = self._insar.getSlaveOrbit()

    pegpts = []

    for orbitObj, order in zip((masterOrbit, slaveOrbit), ('First', 'Second')):
        objGetpeg = stdproc.createGetpeg()
        if peg:
            objGetpeg.setPeg(peg)

        objGetpeg.wireInputPort(name='planet', object=planet)
        objGetpeg.wireInputPort(name='Orbit', object=orbitObj)
        self._stdWriter.setFileTag("getpeg", "log")
        self._stdWriter.setFileTag("getpeg", "err")
        self._stdWriter.setFileTag("getpeg", "out")
        objGetpeg.setStdWriter(self._stdWriter)
        logger.info('Peg points are computed for individual SAR scenes.')
        objGetpeg.estimatePeg()
        pegpts.append(objGetpeg.getPeg())

        recordInputsAndOutputs(self._insar.procDoc, objGetpeg, "getpeg", \
                    logger, "runSetmocomppath")
        #Piyush
        # I set these values here for the sake of continuity, but they need to be updated
        # in orbit2sch as the correct peg point is not yet known
        getattr(self._insar,
                'set%sAverageHeight' % (order))(objGetpeg.getAverageHeight())
        getattr(self._insar,
                'set%sProcVelocity' % (order))(objGetpeg.getProcVelocity())

    logger.info('Combining individual peg points.')
    peg = averagePeg(pegpts, planet)
    self._insar.setPeg(peg)
Exemplo n.º 11
0
def runSetmocomppath_old(self, peg=None):
    logger.info("Selecting Peg Points")
    objSetmocomppath = stdproc.createSetmocomppath()
    if peg:
        objSetmocomppath.setPeg(peg)
    planet = self._insar.getMasterFrame().getInstrument().getPlatform(
    ).getPlanet()
    masterOrbit = self._insar.getMasterOrbit()
    slaveOrbit = self._insar.getSlaveOrbit()

    objSetmocomppath.wireInputPort(name='planet', object=planet)
    objSetmocomppath.wireInputPort(name='masterOrbit', object=masterOrbit)
    objSetmocomppath.wireInputPort(name='slaveOrbit', object=slaveOrbit)

    #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("setmocomppath", "log")
    self._stdWriter.setFileTag("setmocomppath", "err")
    self._stdWriter.setFileTag("setmocomppath", "out")
    objSetmocomppath.setStdWriter(self._stdWriter)

    objSetmocomppath.setmocomppath()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objSetmocomppath, "setmocomppath", \
                  logger, "runSetmocomppath")

    # Set peg information in the self._insar object
    peg = objSetmocomppath.getPeg()
    h1 = objSetmocomppath.getFirstAverageHeight()
    h2 = objSetmocomppath.getSecondAverageHeight()
    v1 = objSetmocomppath.getFirstProcVelocity()
    v2 = objSetmocomppath.getSecondProcVelocity()
    self._insar.setPeg(peg)
    self._insar.setFirstAverageHeight(h1)
    self._insar.setSecondAverageHeight(h2)
    self._insar.setFirstProcVelocity(v1)
    self._insar.setSecondProcVelocity(v2)
Exemplo n.º 12
0
def runOrbit2sch_old(self):
    from isceobj.Catalog import recordInputsAndOutputs
    logger.info("Converting the orbit to SCH coordinates")
    pegHAvg = self.insar.averageHeight
    peg = self.insar.peg
    planet = self.insar.planet

    masterOrbit = self.insar.masterOrbit
    slaveOrbit = self.insar.slaveOrbit

    objOrbit2sch1 = stdproc.createOrbit2sch(averageHeight=pegHAvg)
    objOrbit2sch1.stdWriter = self.stdWriter.set_file_tags(
        "orbit2sch", "log", "err", "log")

    objOrbit2sch1(planet=planet, orbit=masterOrbit, peg=peg)

    # Record the inputs and outputs
    recordInputsAndOutputs(self.insar.procDoc, objOrbit2sch1,
                           "runOrbit2sch.master", logger,
                           "runOrbit2sch.master")

    objOrbit2sch2 = stdproc.createOrbit2sch(averageHeight=pegHAvg)
    objOrbit2sch2.stdWriter = self.stdWriter

    #    objOrbit2sch2.wireInputPort(name='planet', object=planet)
    #    objOrbit2sch2.wireInputPort(name='orbit', object=slaveOrbit)
    #    objOrbit2sch2.wireInputPort(name='peg', object=peg)

    objOrbit2sch2(planet=planet, orbit=slaveOrbit, peg=peg)

    # Record the inputs and outputs
    recordInputsAndOutputs(self.insar.procDoc, objOrbit2sch2,
                           "runOrbit2sch.slave", logger, "runOrbit2sch.slave")

    self.insar.masterOrbit = objOrbit2sch1.orbit
    self.insar.slaveOrbit = objOrbit2sch2.orbit
    return None
Exemplo n.º 13
0
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()
Exemplo n.º 14
0
def runTopo(self):
    from zerodop.topozero import createTopozero
    from isceobj.Planet.Planet import Planet

    logger.info("Running topo")

    #IU.copyAttributes(demImage, objDem)
    objDem = self.insar.demImage.clone()

    info = self.insar.masterFrame
    slc = self.insar.formSLC1
    intImage = slc.slcImage


    planet = info.getInstrument().getPlatform().getPlanet()
    topo = createTopozero()

    topo.slantRangePixelSpacing = 0.5 * SPEED_OF_LIGHT / info.rangeSamplingRate
    topo.prf = info.PRF
    topo.radarWavelength = info.radarWavelegth
    topo.orbit = info.orbit
    topo.width = intImage.getWidth()
    topo.length = intImage.getLength()
    topo.wireInputPort(name='dem', object=objDem)
    topo.wireInputPort(name='planet', object=planet)
    topo.numberRangeLooks = 1
    topo.numberAzimuthLooks = 1
    topo.lookSide = info.getInstrument().getPlatform().pointingDirection
    topo.sensingStart = slc.slcSensingStart 
    topo.rangeFirstSample = slc.startingRange

    topo.demInterpolationMethod='BIQUINTIC'
    topo.latFilename = self.insar.latFilename
    topo.lonFilename = self.insar.lonFilename
    topo.losFilename = self.insar.losFilename
    topo.heightFilename = self.insar.heightFilename
#    topo.incFilename = os.path.join(info.outdir, 'inc.rdr')
#    topo.maskFilename = os.path.join(info.outdir, 'mask.rdr')


    ####Doppler adjustment
    dop = info._dopplerVsPixel[::-1]
    xx = np.linspace(0, (topo.width-1), num=len(dop)+ 1)
    x = (topo.rangeFirstSample - info.startingRange)/topo.slantRangePixelSpacing + xx * topo.numberRangeLooks
    v = np.polyval(dop, x)
    p = np.polyfit(xx, v, len(dop)-1)[::-1]

    doppler = Poly2D()
    doppler.setWidth(topo.width)
    doppler.setLength(topo.length)
    doppler.initPoly(rangeOrder = len(dop)-1, azimuthOrder=0, coeffs=[list(p)])

    topo.polyDoppler = doppler

    topo.topo()


    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, topo, "runTopo",
                           logger, "runTopo")

    self._insar.setTopo(topo)

    return topo
Exemplo n.º 15
0
def runResamp(self):
    logger.info("Resampling interferogram")

    imageSlc1 = self.insar.referenceSlcImage
    imageSlc2 = self.insar.secondarySlcImage

    resampName = self.insar.resampImageName
    resampAmp = resampName + '.amp'
    resampInt = resampName + '.int'

    azLooks = self.insar.numberAzimuthLooks
    rLooks = self.insar.numberRangeLooks

    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 = max(imageSlc1.getWidth(), imageSlc2.getWidth())
    slcWidth = imageSlc1.getWidth()
    intWidth = int(slcWidth / rLooks)
    dataType = 'CFLOAT'

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

    self.insar.resampIntImage = imageInt
    self.insar.resampAmpImage = imageAmp

    instrument = self.insar.referenceFrame.getInstrument()

    offsetField = self.insar.refinedOffsetField

    lines = self.insar.numberResampLines

    ####Modified to deal with secondary PRF correctly
    dopplerCoeff = self.insar.dopplerCentroid.getDopplerCoefficients(inHz=True)
    for num in range(len(dopplerCoeff)):
        dopplerCoeff[num] /= self.insar.secondaryFrame.getInstrument(
        ).getPulseRepetitionFrequency()

    numFitCoeff = self.insar.numberFitCoefficients

    #    pixelSpacing = self.insar.slantRangePixelSpacing
    fS = self._insar.getSecondaryFrame().getInstrument().getRangeSamplingRate()
    pixelSpacing = CN.SPEED_OF_LIGHT / (2. * fS)

    objResamp = stdproc.createResamp()
    objResamp.setNumberLines(lines)
    objResamp.setNumberFitCoefficients(numFitCoeff)
    objResamp.setNumberAzimuthLooks(azLooks)
    objResamp.setNumberRangeLooks(rLooks)
    objResamp.setSlantRangePixelSpacing(pixelSpacing)
    objResamp.setDopplerCentroidCoefficients(dopplerCoeff)

    objResamp.wireInputPort(name='offsets', object=offsetField)
    objResamp.wireInputPort(name='instrument', object=instrument)
    #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
    objResamp.stdWriter = self._writer_set_file_tags("resamp", "log", "err",
                                                     "out")
    objResamp.resamp(objSlc1, objSlc2, objInt, objAmp)
    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objResamp, "runResamp", logger,
                           "runResamp")

    objInt.finalizeImage()
    objAmp.finalizeImage()
    objSlc1.finalizeImage()
    objSlc2.finalizeImage()

    return None
Exemplo n.º 16
0
def runSetmocomppath(self, peg=None):
    from isceobj.Location.Peg import Peg
    from stdproc.orbit.pegManipulator import averagePeg
    from isceobj.Catalog import recordInputsAndOutputs

    logger.info("Selecting individual peg points")

    planet = self._insar.getReferenceFrame().getInstrument().getPlatform().getPlanet()
    referenceOrbit = self._insar.getReferenceOrbit()
    secondaryOrbit = self._insar.getSecondaryOrbit()

    if peg:
        self._insar.setPeg(peg)
        logger.info("Using the given peg = %r", peg)
        self._insar.setFirstAverageHeight(
            averageHeightAboveElp(planet, peg, referenceOrbit))
        self._insar.setSecondAverageHeight(
            averageHeightAboveElp(planet, peg, secondaryOrbit))
        self._insar.setFirstProcVelocity(
            sVelocityAtMidOrbit(planet, peg, referenceOrbit))
        self._insar.setSecondProcVelocity(
            sVelocityAtMidOrbit(planet, peg, secondaryOrbit))

        return


    pegpts = []

    for orbitObj, order in zip((referenceOrbit, secondaryOrbit)
                                ,('First', 'Second')):
        objGetpeg = stdproc.createGetpeg()
        if peg:
            objGetpeg.setPeg(peg)

        objGetpeg.wireInputPort(name='planet', object=planet)
        objGetpeg.wireInputPort(name='Orbit', object=orbitObj)
        self._stdWriter.setFileTag("getpeg", "log")
        self._stdWriter.setFileTag("getpeg", "err")
        self._stdWriter.setFileTag("getpeg", "out")
        objGetpeg.setStdWriter(self._stdWriter)
        logger.info('Peg points are computed for individual SAR scenes.')
        objGetpeg.estimatePeg()
        pegpts.append(objGetpeg.getPeg())

        recordInputsAndOutputs(self._insar.procDoc, objGetpeg, "getpeg", \
                    logger, "runSetmocomppath")
        #Piyush
        # I set these values here for the sake of continuity, but they need to be updated
        # in orbit2sch as the correct peg point is not yet known
        getattr(self._insar,'set%sAverageHeight'%(order))(objGetpeg.getAverageHeight())
        getattr(self._insar,'set%sProcVelocity'%(order))(objGetpeg.getProcVelocity())


    logger.info('Combining individual peg points.')
    peg = averagePeg(pegpts, planet)

    if self.pegSelect.upper() == 'REFERENCE':
        logger.info('Using reference info for peg point')
        self._insar.setPeg(pegpts[0])
    elif self.pegSelect.upper() == 'SECONDARY':
        logger.info('Using secondary infor for peg point')
        self._insar.setPeg(pegpts[1])
    elif self.pegSelect.upper() == 'AVERAGE':
        logger.info('Using average peg point')
        self._insar.setPeg(peg)
    else:
        raise Exception('Unknown peg selection method')
Exemplo n.º 17
0
def runTopo(self):
    from zerodop.topozero import createTopozero
    from isceobj.Planet.Planet import Planet

    logger.info("Running topo")

    #IU.copyAttributes(demImage, objDem)
    geometryDir = self.insar.geometryDirname

    os.makedirs(geometryDir, exist_ok=True)

    demFilename = self.verifyDEM()
    objDem = isceobj.createDemImage()
    objDem.load(demFilename + '.xml')

    info = self._insar.loadProduct(self._insar.masterSlcCropProduct)
    intImage = info.getImage()

    planet = info.getInstrument().getPlatform().getPlanet()
    topo = createTopozero()

    topo.slantRangePixelSpacing = 0.5 * SPEED_OF_LIGHT / info.rangeSamplingRate
    topo.prf = info.PRF
    topo.radarWavelength = info.radarWavelegth
    topo.orbit = info.orbit
    topo.width = intImage.getWidth()
    topo.length = intImage.getLength()
    topo.wireInputPort(name='dem', object=objDem)
    topo.wireInputPort(name='planet', object=planet)
    topo.numberRangeLooks = 1
    topo.numberAzimuthLooks = 1
    topo.lookSide = info.getInstrument().getPlatform().pointingDirection
    topo.sensingStart = info.getSensingStart()
    topo.rangeFirstSample = info.startingRange

    topo.demInterpolationMethod = 'BIQUINTIC'
    topo.latFilename = os.path.join(geometryDir,
                                    self.insar.latFilename + '.full')
    topo.lonFilename = os.path.join(geometryDir,
                                    self.insar.lonFilename + '.full')
    topo.losFilename = os.path.join(geometryDir,
                                    self.insar.losFilename + '.full')
    topo.heightFilename = os.path.join(geometryDir,
                                       self.insar.heightFilename + '.full')
    #    topo.incFilename = os.path.join(info.outdir, 'inc.rdr')
    #    topo.maskFilename = os.path.join(info.outdir, 'mask.rdr')

    ####Doppler adjustment
    dop = [x / 1.0 for x in info._dopplerVsPixel]

    doppler = Poly2D()
    doppler.setWidth(topo.width // topo.numberRangeLooks)
    doppler.setLength(topo.length // topo.numberAzimuthLooks)

    if self._insar.masterGeometrySystem.lower().startswith('native'):
        doppler.initPoly(rangeOrder=len(dop) - 1, azimuthOrder=0, coeffs=[dop])
    else:
        doppler.initPoly(rangeOrder=0, azimuthOrder=0, coeffs=[[0.]])

    topo.polyDoppler = doppler

    topo.topo()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, topo, "runTopo", logger,
                           "runTopo")

    self._insar.estimatedBbox = [
        topo.minimumLatitude, topo.maximumLatitude, topo.minimumLongitude,
        topo.maximumLongitude
    ]
    return topo
Exemplo n.º 18
0
def runTopo(self):
    logger.info("Running topo")

    objMocompbaseline = self.insar.mocompBaseline
    objFormSlc1 = self.insar.formSLC1

    #objDem = isceobj.createDemImage()
    #demImage = self.insar.demImage

    #IU.copyAttributes(demImage, objDem)
    objDem = self.insar.demImage.clone()

    topoIntImage = self._insar.getTopoIntImage()
    #intImage = isceobj.createIntImage()
    #IU.copyAttributes(topoIntImage, intImage)
    intImage = topoIntImage.clone()
    intImage.setAccessMode('read')

    posIndx = 1
    mocompPosition1 = objFormSlc1.getMocompPosition()

    planet = self.insar.masterFrame.getInstrument().getPlatform().getPlanet()
    prf1 = self.insar.masterFrame.getInstrument().getPulseRepetitionFrequency()

    objTopo = stdproc.createTopo()
    objTopo.wireInputPort(name='peg', object=self.insar.peg)
    objTopo.wireInputPort(name='frame', object=self.insar.masterFrame)
    objTopo.wireInputPort(name='planet', object=planet)
    objTopo.wireInputPort(name='dem', object=objDem)
    objTopo.wireInputPort(name='interferogram', object=intImage)
    objTopo.wireInputPort(name='masterslc',
                          object=self.insar.formSLC1)  #Piyush

    centroid = self.insar.dopplerCentroid.getDopplerCoefficients(inHz=False)[0]
    objTopo.setDopplerCentroidConstantTerm(centroid)

    v = self.insar.procVelocity
    h = self.insar.averageHeight

    objTopo.setBodyFixedVelocity(v)
    objTopo.setSpacecraftHeight(h)

    objTopo.setReferenceOrbit(mocompPosition1[posIndx])

    # Options
    objTopo.setNumberRangeLooks(self.insar.numberRangeLooks)
    objTopo.setNumberAzimuthLooks(self.insar.numberAzimuthLooks)
    objTopo.setNumberIterations(self.insar.topophaseIterations)
    objTopo.setHeightSchFilename(self.insar.heightSchFilename)
    objTopo.setHeightRFilename(self.insar.heightFilename)
    objTopo.setLatFilename(self.insar.latFilename)
    objTopo.setLonFilename(self.insar.lonFilename)
    objTopo.setLosFilename(self.insar.losFilename)

    if self.insar.is_mocomp is None:
        self.insar.get_is_mocomp()

    objTopo.setISMocomp(self.insar.is_mocomp)
    #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
    objTopo.stdWriter = self._writer_set_file_tags("topo", "log", "err", "out")
    objTopo.setLookSide(self.insar._lookSide)
    objTopo.topo()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objTopo, "runTopo", logger,
                           "runTopo")

    self._insar.setTopo(objTopo)
    if self.insar.applyWaterMask:
        sw = SWBDStitcher()
        sw.toRadar(self.insar.wbdImage.filename, self.insar.latFilename,
                   self.insar.lonFilename, self.insar.waterMaskImageName)

    return objTopo
Exemplo n.º 19
0
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()
Exemplo n.º 20
0
def runResamp_image(self):
    imageSlc = self._insar.getMasterSlcImage()
    widthSlc = max(self._insar.getMasterSlcImage().getWidth(),
                   self._insar.getSlaveSlcImage().getWidth())
    offsetField = self._insar.getRefinedOffsetField()

    instrument = self._insar.getMasterFrame().getInstrument()

    dopplerCoeff = self._insar.getDopplerCentroid().getDopplerCoefficients(
        inHz=False)

    pixelSpacing = self._insar.getSlantRangePixelSpacing()
    looks = self._insar.getNumberLooks()
    lines = self._insar.getNumberResampLines()
    numFitCoeff = self._insar.getNumberFitCoefficients()

    offsetFilename = self._insar.getOffsetImageName()
    offsetAz = 'azimuth' + offsetFilename.capitalize()
    offsetRn = 'range' + offsetFilename.capitalize()
    widthOffset = int(widthSlc / looks)
    imageAz = isceobj.createOffsetImage()
    imageAz.setFilename(offsetAz)
    imageAz.setWidth(widthOffset)
    imageRn = isceobj.createOffsetImage()
    imageRn.setFilename(offsetRn)
    imageRn.setWidth(widthOffset)

    self._insar.setOffsetAzimuthImage(imageAz)
    self._insar.setOffsetRangeImage(imageRn)

    objAz = isceobj.createOffsetImage()
    objRn = isceobj.createOffsetImage()
    IU.copyAttributes(imageAz, objAz)
    IU.copyAttributes(imageRn, objRn)
    objAz.setAccessMode('write')
    objAz.createImage()
    objRn.setAccessMode('write')
    objRn.createImage()

    objResamp_image = stdproc.createResamp_image()
    objResamp_image.wireInputPort(name='offsets', object=offsetField)
    objResamp_image.wireInputPort(name='instrument', object=instrument)
    objResamp_image.setSlantRangePixelSpacing(pixelSpacing)
    objResamp_image.setDopplerCentroidCoefficients(dopplerCoeff)
    objResamp_image.setNumberLooks(looks)
    objResamp_image.setNumberLines(lines)
    objResamp_image.setNumberRangeBin(widthSlc)
    objResamp_image.setNumberFitCoefficients(numFitCoeff)
    #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("resamp_image", "log")
    self._stdWriter.setFileTag("resamp_image", "err")
    self._stdWriter.setFileTag("resamp_image", "out")
    objResamp_image.setStdWriter(self._stdWriter)

    objResamp_image.resamp_image(objRn, objAz)

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objResamp_image, "runResamp_image", \
                  logger, "runResamp_image")

    objRn.finalizeImage()
    objAz.finalizeImage()
Exemplo n.º 21
0
def runGeocode(self, prodlist, unwrapflag, bbox):
    '''Generalized geocoding of all the files listed above.'''
    from isceobj.Catalog import recordInputsAndOutputs
    logger.info("Geocoding Image")
    insar = self.insar

    if isinstance(prodlist,str):
        from isceobj.Util.StringUtils import StringUtils as SU
        tobeGeocoded = SU.listify(prodlist)
    else:
        tobeGeocoded = prodlist

    #remove files that have not been processed
    for toGeo in tobeGeocoded:
        if not os.path.exists(toGeo):
            tobeGeocoded.remove(toGeo)
    print('Number of products to geocode: ', len(tobeGeocoded))

    stdWriter = create_writer("log", "", True, filename="geo.log")

    v,h = insar.vh()
    planet = insar.masterFrame._instrument._platform._planet


    if bbox is None:
        snwe = insar.topo.snwe
    else:
        snwe = list(bbox)
        if len(snwe) != 4:
            raise ValueError('Bounding box should be a list/tuple of length 4')

    #####Geocode one by one
    first = False
    ge = Geocodable()
    for prod in tobeGeocoded:
        objGeo = stdproc.createGeocode('insarapp_geocode_' + os.path.basename(prod).replace('.',''))
        objGeo.configure()

        ####IF statements to check for user configuration
        if objGeo.minimumLatitude is None:
            objGeo.minimumLatitude = snwe[0]

        if objGeo.maximumLatitude is None:
            objGeo.maximumLatitude = snwe[1]

        if objGeo.minimumLongitude is None:
            objGeo.minimumLongitude = snwe[2]

        if objGeo.maximumLongitude is None:
            objGeo.maximumLongitude = snwe[3]

        if objGeo.demCropFilename is None:
            objGeo.demCropFilename = insar.demCropFilename

        objGeo.referenceOrbit = insar.formSLC1.getMocompPosition(1)

        if objGeo.dopplerCentroidConstantTerm is None:
            objGeo.dopplerCentroidConstantTerm = insar.dopplerCentroid.getDopplerCoefficients(inHz=False)[0]

        if objGeo.bodyFixedVelocity is None:
            objGeo.bodyFixedVelocity = v

        if objGeo.spacecraftHeight is None:
            objGeo.spacecraftHeight = h

        if objGeo.numberRangeLooks is None:
            objGeo.numberRangeLooks = insar.numberRangeLooks

        if objGeo.numberAzimuthLooks is None:
            objGeo.numberAzimuthLooks = insar.numberAzimuthLooks

        if objGeo.isMocomp is None:
            objGeo.isMocomp = insar.is_mocomp

        objGeo.stdWriter = stdWriter

        #create the instance of the input image and the appropriate
        #geocode method
        inImage,method = ge.create(prod)
        if objGeo.method is None:
            objGeo.method = method

        if(inImage):
            #demImage = isceobj.createDemImage()
            #IU.copyAttributes(insar.demImage, demImage)
            demImage = insar.demImage.clone()
            objGeo(peg=insar.peg, frame=insar.masterFrame,
                           planet=planet, dem=demImage, tobegeocoded=inImage,
                           geoPosting=None, masterslc=insar.formSLC1)


            recordInputsAndOutputs(self._insar.procDoc, objGeo, "runGeocode",
                                       logger, "runGeocode")

    stdWriter.finalize()
Exemplo n.º 22
0
def runCorrect(self):
    logger.info("Running correct")

    objMocompbaseline = self.insar.mocompBaseline
    objFormSlc1  =  self.insar.formSLC1

    topoIntImage = self.insar.topoIntImage
    intImage = isceobj.createIntImage()
    #just pass the image object to Correct and it will handle the creation
    # and deletion of the actual image pointer  
    IU.copyAttributes(topoIntImage, intImage)

    posIndx = 1
    mocompPosition1 = objFormSlc1.mocompPosition

    planet = self.insar.masterFrame.instrument.platform.planet
    prf1 = self.insar.masterFrame.instrument.PRF
    objCorrect = stdproc.createCorrect()
    objCorrect.wireInputPort(name='peg', object=self.insar.peg)
    objCorrect.wireInputPort(name='frame', object=self.insar.masterFrame)
    objCorrect.wireInputPort(name='planet', object=planet)
    objCorrect.wireInputPort(name='interferogram', object=intImage)
    objCorrect.wireInputPort(name='masterslc', object=self.insar.formSLC1) #Piyush
    # Average velocity and height measurements       
    v = self.insar.procVelocity
    h = self.insar.averageHeight
    objCorrect.setBodyFixedVelocity(v)
    objCorrect.setSpacecraftHeight(h)
    # Need the reference orbit from Formslc       
    objCorrect.setReferenceOrbit(mocompPosition1[posIndx]) 
    objCorrect.setMocompBaseline(objMocompbaseline.baseline) 
    sch12 = objMocompbaseline.getSchs()
    objCorrect.setSch1(sch12[0])
    objCorrect.setSch2(sch12[1])
    sc = objMocompbaseline.sc
    objCorrect.setSc(sc)
    midpoint = objMocompbaseline.midpoint
    objCorrect.setMidpoint(midpoint)
    objCorrect.setLookSide(self.insar._lookSide)


    objCorrect.setNumberRangeLooks(self.insar.numberRangeLooks)
    objCorrect.setNumberAzimuthLooks(self.insar.numberAzimuthLooks)
    objCorrect.setTopophaseMphFilename(self.insar.topophaseMphFilename)
    objCorrect.setTopophaseFlatFilename(self.insar.topophaseFlatFilename)
    objCorrect.setHeightSchFilename(self.insar.heightSchFilename)

    objCorrect.setISMocomp(self.insar.is_mocomp)
    #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
    objCorrect.stdWriter = self._writer_set_file_tags("correct",
                                                      "log", "err", "out")
    
    objCorrect()#.correct()

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self.insar.procDoc, objCorrect, "runCorrect", 
                           logger, "runCorrect")


    return objCorrect
Exemplo n.º 23
0
def runResamp_only(self):
    imageInt = self._insar.getResampIntImage()
    imageAmp = self._insar.getResampAmpImage()

    objInt = isceobj.createIntImage()
    objIntOut = isceobj.createIntImage()
    IU.copyAttributes(imageInt, objInt)
    IU.copyAttributes(imageInt, objIntOut)
    outIntFilename = self._insar.getResampOnlyImageName()
    objInt.setAccessMode('read')
    objIntOut.setFilename(outIntFilename)

    self._insar.setResampOnlyImage(objIntOut)

    objIntOut.setAccessMode('write')
    objInt.createImage()
    objIntOut.createImage()

    objAmp = isceobj.createAmpImage()
    objAmpOut = isceobj.createAmpImage()
    IU.copyAttributes(imageAmp, objAmp)
    IU.copyAttributes(imageAmp, objAmpOut)
    outAmpFilename = self.insar.resampOnlyAmpName
    objAmp.setAccessMode('read')
    objAmpOut.setFilename(outAmpFilename)

    self._insar.setResampOnlyAmp(objAmpOut)

    objAmpOut.setAccessMode('write')
    objAmp.createImage()
    objAmpOut.createImage()

    numRangeBin = objInt.getWidth()
    lines = objInt.getLength()
    instrument = self._insar.getMasterFrame().getInstrument()

    offsetField = self._insar.getRefinedOffsetField()

    dopplerCoeff = self._insar.getDopplerCentroid().getDopplerCoefficients(
        inHz=False)
    numFitCoeff = self._insar.getNumberFitCoefficients()

    pixelSpacing = self._insar.getSlantRangePixelSpacing()

    objResamp = stdproc.createResamp_only()

    objResamp.setNumberLines(lines)
    objResamp.setNumberFitCoefficients(numFitCoeff)
    objResamp.setSlantRangePixelSpacing(pixelSpacing)
    objResamp.setNumberRangeBin(numRangeBin)
    objResamp.setDopplerCentroidCoefficients(dopplerCoeff)

    objResamp.wireInputPort(name='offsets', object=offsetField)
    objResamp.wireInputPort(name='instrument', object=instrument)
    #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("resamp_only", "log")
    self._stdWriter.setFileTag("resamp_only", "err")
    self._stdWriter.setFileTag("resamp_only", "out")
    objResamp.setStdWriter(self._stdWriter)

    objResamp.resamp_only(objInt, objIntOut, objAmp, objAmpOut)

    # Record the inputs and outputs
    from isceobj.Catalog import recordInputsAndOutputs
    recordInputsAndOutputs(self._insar.procDoc, objResamp, "runResamp_only", \
                  logger, "runResamp_only")
    objInt.finalizeImage()
    objIntOut.finalizeImage()
    objAmp.finalizeImage()
    objAmpOut.finalizeImage()
Exemplo n.º 24
0
def runFormSLC(self, patchSize=None, goodLines=None, numPatches=None):
    #NOTE tested the formslc() as a stand alone by passing the same inputs
    #computed in Howard terraSAR.py. The differences here arises from the
    #differences in the orbits when using the same orbits the results are very
    #close jng this will make the second term in coarseAz in offsetprf equal
    #zero. we do so since for tsx there is no such a term. Need to ask
    #confirmation
    self.insar.setPatchSize(self.insar.numberValidPulses)
    # the below value is zero because of we just did above, but just want to be
    #  explicit in the definition of is_mocomp
    self.is_mocomp = self.insar.get_is_mocomp

    v = self.insar.getFirstProcVelocity()
    h = self.insar.averageHeight
    imageSlc1 = self.insar.masterRawImage
    imSlc1 = isceobj.createSlcImage()
    IU.copyAttributes(imageSlc1, imSlc1)
    imSlc1.setAccessMode('read')
    imSlc1.createImage()
    formSlc1 = stdproc.createFormSLC()

    formSlc1.setBodyFixedVelocity(v)
    formSlc1.setSpacecraftHeight(h)
    formSlc1.wireInputPort(name='doppler', object=self.insar.dopplerCentroid)
    formSlc1.wireInputPort(name='peg', object=self.insar.peg)
    formSlc1.wireInputPort(name='frame', object=self.insar.masterFrame)
    formSlc1.wireInputPort(name='orbit', object=self.insar.masterOrbit)
    formSlc1.wireInputPort(name='rawImage', object=None)
    formSlc1.wireInputPort(
        name='planet',
        object=self.insar.masterFrame.instrument.platform.planet)
    for item in formSlc1.inputPorts:
        item()
    formSlc1.slcWidth = imSlc1.getWidth()
    formSlc1.startingRange = formSlc1.rangeFirstSample
    formSlc1.rangeChirpExtensionPoints = 0
    formSlc1.slcSensingStart = self.insar.masterFrame.getSensingStart()
    formSlc1.outOrbit = self.insar.masterOrbit

    self._stdWriter.setFileTag("formslcISCE", "log")
    self._stdWriter.setFileTag("formslcISCE", "err")
    self._stdWriter.setFileTag("formslcISCE", "out")
    formSlc1.setStdWriter(self._stdWriter)
    formSlc1.setLookSide(self.insar._lookSide)

    #    self.insar.setMasterSlcImage(formSlc1.formslc())
    #    self.insar.masterSlcImage = formSlc1()
    self.insar.formSLC1 = formSlc1
    self.insar.masterSlcImage = imSlc1
    time, position, velocity, relTo = self.insar.masterOrbit._unpackOrbit()
    mocomp_array = [[], []]
    for (t, p) in zip(time, position):
        mocomp_array[0].append(t - time[0])
        mocomp_array[1].append(p[0])

    self.insar.formSLC1.mocompPosition = mocomp_array
    self.insar.formSLC1.mocompIndx = list(range(1, len(time) + 1))
    formSlc1.dim1_mocompPosition = 2
    formSlc1.dim2_mocompPosition = len(time)
    formSlc1.dim1_mocompIndx = len(time)

    imageSlc2 = self.insar.slaveRawImage
    imSlc2 = isceobj.createSlcImage()
    IU.copyAttributes(imageSlc2, imSlc2)
    imSlc2.setAccessMode('read')
    imSlc2.createImage()
    formSlc2 = stdproc.createFormSLC()

    formSlc2.setBodyFixedVelocity(v)
    formSlc2.setSpacecraftHeight(h)
    formSlc2.wireInputPort(name='doppler', object=self.insar.dopplerCentroid)
    formSlc2.wireInputPort(name='peg', object=self.insar.peg)
    formSlc2.wireInputPort(name='frame', object=self.insar.slaveFrame)
    formSlc2.wireInputPort(name='orbit', object=self.insar.slaveOrbit)
    formSlc2.wireInputPort(name='rawImage', object=None)
    formSlc2.wireInputPort(
        name='planet', object=self.insar.slaveFrame.instrument.platform.planet)
    for item in formSlc2.inputPorts:
        item()
    formSlc2.slcWidth = imSlc2.getWidth()
    formSlc2.startingRange = formSlc2.rangeFirstSample
    formSlc2.rangeChirpExtensionPoints = 0
    formSlc2.slcSensingStart = self.insar.slaveFrame.getSensingStart()
    formSlc2.outOrbit = self.insar.slaveOrbit

    self._stdWriter.setFileTag("formslcISCE", "log")
    self._stdWriter.setFileTag("formslcISCE", "err")
    self._stdWriter.setFileTag("formslcISCE", "out")
    formSlc2.setStdWriter(self._stdWriter)
    formSlc2.setLookSide(self.insar._lookSide)
    #    self.insar.setSlaveSlcImage(formSlc2.formslc())
    self.insar.formSLC2 = formSlc2
    self.insar.slaveSlcImage = imSlc2
    time, position, velocity, relTo = self.insar.slaveOrbit._unpackOrbit()
    mocomp_array = [[], []]
    for (t, p) in zip(time, position):
        mocomp_array[0].append(t - time[0])
        mocomp_array[1].append(p[0])

    self.insar.formSLC2.mocompPosition = mocomp_array
    self.insar.formSLC2.mocompIndx = list(range(1, len(time) + 1))
    formSlc2.dim1_mocompPosition = 2
    formSlc2.dim2_mocompPosition = len(time)
    formSlc2.dim1_mocompIndx = len(time)

    self.insar.setNumberPatches(imSlc1.getLength() /
                                float(self.insar.numberValidPulses))
    imSlc1.finalizeImage()
    imSlc2.finalizeImage()
    recordInputsAndOutputs(self.insar.procDoc, formSlc1, "runFormSLC.master",
                           logger, "runFormSLC.master")
    recordInputsAndOutputs(self.insar.procDoc, formSlc2, "runFormSLC.slave",
                           logger, "runFormSLC.slave")

    self.insar.setFormSLC1(formSlc1)
    self.insar.setFormSLC2(formSlc2)