Ejemplo n.º 1
0
def estimateOffsetField(reference, secondary, inps=None):
    '''
    Estimate offset field between burst and simamp.
    '''

    ###Loading the secondary image object
    sim = isceobj.createSlcImage()
    sim.load(secondary+'.xml')
    sim.setAccessMode('READ')
    sim.createImage()

    ###Loading the reference image object
    sar = isceobj.createSlcImage()
    sar.load(reference + '.xml')
    sar.setAccessMode('READ')
    sar.createImage()

    width = sar.getWidth()
    length = sar.getLength()

    objOffset = DenseAmpcor(name='dense')
    objOffset.configure()

#   objOffset.numberThreads = 6
    objOffset.setWindowSizeWidth(inps.winwidth)
    objOffset.setWindowSizeHeight(inps.winhgt)
    objOffset.setSearchWindowSizeWidth(inps.srcwidth)
    objOffset.setSearchWindowSizeHeight(inps.srchgt)
    objOffset.skipSampleAcross = inps.skipwidth
    objOffset.skipSampleDown = inps.skiphgt
    objOffset.margin = inps.margin 
    objOffset.oversamplingFactor = inps.oversample

    objOffset.setAcrossGrossOffset(inps.rgshift)
    objOffset.setDownGrossOffset(inps.azshift)

    objOffset.setFirstPRF(1.0)
    objOffset.setSecondPRF(1.0)
    if sar.dataType.startswith('C'):
        objOffset.setImageDataType1('mag')
    else:
        objOffset.setImageDataType1('real')

    if sim.dataType.startswith('C'):
        objOffset.setImageDataType2('mag') 
    else:
        objOffset.setImageDataType2('real')

    objOffset.offsetImageName = inps.outprefix + '.bil'
    objOffset.snrImageName = inps.outprefix +'_snr.bil'

    
    objOffset.denseampcor(sar, sim)

    sar.finalizeImage()
    sim.finalizeImage()
    return objOffset
Ejemplo n.º 2
0
def runDenseOffsetsCPU(self):
    '''
    Estimate dense offset field between merged master bursts and slave bursts.
    '''
    from mroipac.ampcor.DenseAmpcor import DenseAmpcor

    os.environ['VRT_SHARED_SOURCE'] = "0"

    print('\n============================================================')
    print('Configuring DenseAmpcor object for processing...\n')

    ### Determine appropriate filenames
    mf = 'master.slc'
    sf = 'slave.slc'

    if not ((self.numberRangeLooks == 1) and (self.numberAzimuthLooks == 1)):
        mf += '.full'
        sf += '.full'
    master = os.path.join(self._insar.mergedDirname, mf)
    slave = os.path.join(self._insar.mergedDirname, sf)

    ####For this module currently, we need to create an actual file on disk
    for infile in [master, slave]:
        if os.path.isfile(infile):
            continue
        cmd = 'gdal_translate -of ENVI {0}.vrt {0}'.format(infile)
        status = os.system(cmd)
        if status:
            raise Exception('{0} could not be executed'.format(status))

    ### Load the master object
    m = isceobj.createSlcImage()
    m.load(master + '.xml')
    m.setAccessMode('READ')
    #    m.createImage()

    ### Load the slave object
    s = isceobj.createSlcImage()
    s.load(slave + '.xml')
    s.setAccessMode('READ')
    #    s.createImage()

    width = m.getWidth()
    length = m.getLength()

    objOffset = DenseAmpcor(name='dense')
    objOffset.configure()

    #    objOffset.numberThreads = 1
    ### Configure dense Ampcor object
    print('\nMaster frame: %s' % (mf))
    print('Slave frame: %s' % (sf))
    print('Main window size width: %d' % (self.winwidth))
    print('Main window size height: %d' % (self.winhgt))
    print('Search window size width: %d' % (self.srcwidth))
    print('Search window size height: %d' % (self.srchgt))
    print('Skip sample across: %d' % (self.skipwidth))
    print('Skip sample down: %d' % (self.skiphgt))
    print('Field margin: %d' % (self.margin))
    print('Oversampling factor: %d' % (self.oversample))
    print('Gross offset across: %d' % (self.rgshift))
    print('Gross offset down: %d\n' % (self.azshift))

    objOffset.setWindowSizeWidth(self.winwidth)
    objOffset.setWindowSizeHeight(self.winhgt)
    objOffset.setSearchWindowSizeWidth(self.srcwidth)
    objOffset.setSearchWindowSizeHeight(self.srchgt)
    objOffset.skipSampleAcross = self.skipwidth
    objOffset.skipSampleDown = self.skiphgt
    objOffset.oversamplingFactor = self.oversample
    objOffset.setAcrossGrossOffset(self.rgshift)
    objOffset.setDownGrossOffset(self.azshift)

    objOffset.setFirstPRF(1.0)
    objOffset.setSecondPRF(1.0)
    if m.dataType.startswith('C'):
        objOffset.setImageDataType1('mag')
    else:
        objOffset.setImageDataType1('real')
    if s.dataType.startswith('C'):
        objOffset.setImageDataType2('mag')
    else:
        objOffset.setImageDataType2('real')

    objOffset.offsetImageName = os.path.join(self._insar.mergedDirname,
                                             self._insar.offsetfile)
    objOffset.snrImageName = os.path.join(self._insar.mergedDirname,
                                          self._insar.snrfile)

    print('Output dense offsets file name: %s' % (objOffset.offsetImageName))
    print('Output SNR file name: %s' % (objOffset.snrImageName))
    print('\n======================================')
    print('Running dense ampcor...')
    print('======================================\n')

    objOffset.denseampcor(m, s)  ### Where the magic happens...

    ### Store params for later
    self._insar.offset_width = objOffset.offsetCols
    self._insar.offset_length = objOffset.offsetLines
    self._insar.offset_top = objOffset.locationDown[0][0]
    self._insar.offset_left = objOffset.locationAcross[0][0]
Ejemplo n.º 3
0
def estimateOffsetField(master, slave, denseOffsetFileName,
                        ww=64, wh=64,
                        sw=20, shh=20,
                        kw=32, kh=32):
    '''
    Estimate offset field between burst and simamp.
    '''

    ###Loading the slave image object
    sim = isceobj.createSlcImage()
    sim.load(slave+'.xml')
    sim.setAccessMode('READ')
    sim.createImage()

    ###Loading the master image object
    sar = isceobj.createSlcImage()
    sar.load(master + '.xml')
    sar.setAccessMode('READ')
    sar.createImage()

    width = sar.getWidth()
    length = sar.getLength()

    objOffset = DenseAmpcor(name='dense')
    objOffset.configure()

#   objOffset.numberThreads = 6
    objOffset.setWindowSizeWidth(ww) #inps.winwidth)
    objOffset.setWindowSizeHeight(wh) #inps.winhgt)
    objOffset.setSearchWindowSizeWidth(sw) #inps.srcwidth)
    objOffset.setSearchWindowSizeHeight(shh) #inps.srchgt)
    objOffset.skipSampleAcross = kw #inps.skipwidth
    objOffset.skipSampleDown = kh #inps.skiphgt
    objOffset.margin = 50 #inps.margin
    objOffset.oversamplingFactor = 32  #inps.oversample

    objOffset.setAcrossGrossOffset(0) #inps.rgshift)
    objOffset.setDownGrossOffset(0) #inps.azshift)

    objOffset.setFirstPRF(1.0)
    objOffset.setSecondPRF(1.0)
    if sar.dataType.startswith('C'):
        objOffset.setImageDataType1('mag')
    else:
        objOffset.setImageDataType1('real')

    if sim.dataType.startswith('C'):
        objOffset.setImageDataType2('mag')
    else:
        objOffset.setImageDataType2('real')

    
    objOffset.offsetImageName = denseOffsetFileName + '.bil'
    objOffset.snrImageName = denseOffsetFileName +'_snr.bil'


    objOffset.denseampcor(sar, sim)

    sar.finalizeImage()
    sim.finalizeImage()
    return (objOffset.locationDown[0][0], objOffset.locationAcross[0][0])
Ejemplo n.º 4
0
def runDenseOffsets(self):
    '''
    Estimate dense offset field between merged master bursts and slave bursts.
    '''

    os.environ['VRT_SHARED_SOURCE'] = "0"

    if not self.doDenseOffsets:
        print('Dense offsets not requested. Skipping ....')
        return

    print('\n============================================================')
    print('Configuring DenseAmpcor object for processing...\n')

    ### Determine appropriate filenames
    mf = 'master.slc'
    sf = 'slave.slc'
    if not ((self.numberRangeLooks == 1) and (self.numberAzimuthLooks == 1)):
        mf += '.full'
        sf += '.full'
    master = os.path.join(self._insar.mergedDirname, mf)
    slave = os.path.join(self._insar.mergedDirname, sf)

    ### Load the master object
    m = isceobj.createSlcImage()
    m.load(master + '.xml')
    m.setAccessMode('READ')
    #    m.createImage()

    ### Load the slave object
    s = isceobj.createSlcImage()
    s.load(slave + '.xml')
    s.setAccessMode('READ')
    #    s.createImage()

    width = m.getWidth()
    length = m.getLength()

    objOffset = DenseAmpcor(name='dense')
    objOffset.configure()

    #    objOffset.numberThreads = 1
    ### Configure dense Ampcor object
    print('\nMaster frame: %s' % (mf))
    print('Slave frame: %s' % (sf))
    print('Main window size width: %d' % (self.winwidth))
    print('Main window size height: %d' % (self.winhgt))
    print('Search window size width: %d' % (self.srcwidth))
    print('Search window size height: %d' % (self.srchgt))
    print('Skip sample across: %d' % (self.skipwidth))
    print('Skip sample down: %d' % (self.skiphgt))
    print('Field margin: %d' % (self.margin))
    print('Oversampling factor: %d' % (self.oversample))
    print('Gross offset across: %d' % (self.rgshift))
    print('Gross offset down: %d\n' % (self.azshift))

    objOffset.setWindowSizeWidth(self.winwidth)
    objOffset.setWindowSizeHeight(self.winhgt)
    objOffset.setSearchWindowSizeWidth(self.srcwidth)
    objOffset.setSearchWindowSizeHeight(self.srchgt)
    objOffset.skipSampleAcross = self.skipwidth
    objOffset.skipSampleDown = self.skiphgt
    objOffset.oversamplingFactor = self.oversample
    objOffset.setAcrossGrossOffset(self.rgshift)
    objOffset.setDownGrossOffset(self.azshift)

    objOffset.setFirstPRF(1.0)
    objOffset.setSecondPRF(1.0)
    if m.dataType.startswith('C'):
        objOffset.setImageDataType1('mag')
    else:
        objOffset.setImageDataType1('real')
    if s.dataType.startswith('C'):
        objOffset.setImageDataType2('mag')
    else:
        objOffset.setImageDataType2('real')

    objOffset.offsetImageName = os.path.join(self._insar.mergedDirname,
                                             self._insar.offsetfile)
    objOffset.snrImageName = os.path.join(self._insar.mergedDirname,
                                          self._insar.snrfile)

    print('Output dense offsets file name: %s' % (objOffset.offsetImageName))
    print('Output SNR file name: %s' % (objOffset.snrImageName))
    print('\n======================================')
    print('Running dense ampcor...')
    print('======================================\n')

    objOffset.denseampcor(m, s)  ### Where the magic happens...

    ### Store params for later
    self._insar.offset_width = objOffset.offsetCols
    self._insar.offset_length = objOffset.offsetLines
    self._insar.offset_top = objOffset.locationDown[0][0]
    self._insar.offset_left = objOffset.locationAcross[0][0]