Ejemplo n.º 1
0
def unwrap_2stage(inpFile, ccFile, outFile, unwrapper_2stage_name=None, solver_2stage=None):
    if unwrapper_2stage_name is None:
        unwrapper_2stage_name = 'REDARC0'

    if solver_2stage is None:
        # If unwrapper_2state_name is MCF then solver is ignored
        # and relaxIV MCF solver is used by default
        solver_2stage = 'pulp'

    print('Unwrap 2 Stage Settings:')
    print('Name: %s' % unwrapper_2stage_name)
    print('Solver: %s' % solver_2stage)

    #inpFile = os.path.join(self._insar.mergedDirname, self._insar.unwrappedIntFilename)
    #ccFile = inpFile + '.conncomp'
    #outFile = os.path.join(self._insar.mergedDirname, self.insar.unwrapped2StageFilename)

    ds_conn = gdal.Open(ccFile + '.vrt', gdal.GA_ReadOnly)
    conn_comp = ds_conn.GetRasterBand(1).ReadAsArray()

    if np.nanmax(conn_comp) > 1:
        # Hand over to 2Stage unwrap
        unw = UnwrapComponents()
        unw.setInpFile(inpFile)
        unw.setConnCompFile(ccFile)
        unw.setOutFile(outFile)
        unw.setSolver(solver_2stage)
        unw.setRedArcs(unwrapper_2stage_name)
        unw.unwrapComponents()
    else:
        print('Single connected component in image. 2 Stage will not have effect')

    if os.path.exists(outFile):
        os.system('rm -rf {} {} {}'.format(inpFile, inpFile+'.vrt', inpFile+'.xml'))
    else:
        os.system('mv {} {}'.format(inpFile, outFile))
        os.system('mv {} {}'.format(inpFile + '.vrt', outFile + '.vrt'))
        os.system('mv {} {}'.format(inpFile + '.xml', outFile + '.xml'))

    return
Ejemplo n.º 2
0
def runUnwrap2Stage(self, unwrapper_2stage_name=None, solver_2stage=None):

    if unwrapper_2stage_name is None:
        unwrapper_2stage_name = 'REDARC0'

    if solver_2stage is None:
        # If unwrapper_2state_name is MCF then solver is ignored
        # and relaxIV MCF solver is used by default
        solver_2stage = 'pulp'

    print('Unwrap 2 Stage Settings:')
    print('Name: %s' % unwrapper_2stage_name)
    print('Solver: %s' % solver_2stage)

    inpFile = self.insar.unwrappedIntFilename
    ccFile = self.insar.connectedComponentsFilename
    outFile = self.insar.unwrapped2StageFilename

    # Hand over to 2Stage unwrap
    unw = UnwrapComponents()
    unw.setInpFile(inpFile)
    unw.setConnCompFile(ccFile)
    unw.setOutFile(outFile)
    unw.setSolver(solver_2stage)
    unw.setRedArcs(unwrapper_2stage_name)
    unw.unwrapComponents()
    return
Ejemplo n.º 3
0
 def two_stage_unwrap(self, unwrappedIntFilename, ccFile,unwrapped2StageFilename = None, unwrapper_2stage_name = None, solver_2stage = None):
     
     if unwrapper_2stage_name is None:
         unwrapper_2stage_name = 'REDARC0'
 
     if solver_2stage is None:
         # If unwrapper_2state_name is MCF then solver is ignored
         # and relaxIV MCF solver is used by default
         solver_2stage = 'pulp'
     if unwrapped2StageFilename is None:
         unwrapped2StageFilename = unwrappedIntFilename.replace('.unw','_2stage.unw')
     print('Unwrap 2 Stage Settings:')
     print('Name: %s'%unwrapper_2stage_name)
     print('Solver: %s'%solver_2stage)
 
 
     inpFile = os.path.join(unwrappedIntFilename)
     outFile = os.path.join(unwrapped2StageFilename)
 
     # Hand over to 2Stage unwrap
     unw = UnwrapComponents()
     unw.setInpFile(inpFile)
     unw.setConnCompFile(ccFile)
     unw.setOutFile(outFile)
     unw.setSolver(solver_2stage)
     unw.setRedArcs(unwrapper_2stage_name)
     unw.unwrapComponents()