def unwrap_snaphu(inps, length, width): import isce import isceobj from contrib.Snaphu.Snaphu import Snaphu altitude = 800000.0 earthRadius = 6371000.0 wavelength = 0.056 snp = Snaphu() snp.setInitOnly(False) snp.setInput(inps.interferogramFile) snp.setOutput(inps.unwrapFile) snp.setWidth(width) snp.setCostMode('DEFO') snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(inps.coherenceFile) snp.setInitMethod('MST') # snp.setCorrLooks(corrLooks) snp.setMaxComponents(100) snp.setDefoMaxCycles(2.0) snp.setRangeLooks(1) snp.setAzimuthLooks(1) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() write_xml(inps.unwrapFile, width, length, 2 , "FLOAT", "BIL") write_xml(inps.unwrapFile+'.conncomp', width, length, 1, "BYTE", "BIP")
def unwrap(self): snp = Snaphu() snp.setInput(self.wrapName) snp.setOutput(self.unwrapName) snp.setWidth(self.width) snp.setCostMode(self.costMode) snp.setEarthRadius(self.earthRadius) snp.setWavelength(self.wavelength) snp.setAltitude(self.altitude) snp.setCorrfile(self.corrfile) snp.setInitMethod(self.initMethod) snp.setCorrLooks(self.corrLooks) snp.setMaxComponents(self.maxComponents) snp.setDefoMaxCycles(self.defomax) snp.setRangeLooks(self.rangeLooks) snp.setAzimuthLooks(self.azimuthLooks) snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createImage() outImage.setFilename(self.unwrapName) outImage.setWidth(self.width) outImage.bands = 2 outImage.scheme = 'BIL' outImage.imageType='unw' outImage.dataType='FLOAT' outImage.setAccessMode('read') outImage.createImage() outImage.finalizeImage() outImage.renderHdr()
def main(): inputFilename = sys.argv[1] outputFilename = sys.argv[2] snaphu = Snaphu() snaphu.setInput(inputFilename) snaphu.setOutput(outputFilename) snaphu.setWidth(710) snaphu.setCostMode('DEFO') snaphu.setEarthRadius(6356236.24233467) snaphu.setWavelength(0.0562356424) snaphu.setAltitude(788151.7928135) print "Preparing" snaphu.prepare() snaphu.unwrap()
def runUnwrap(self,costMode = None,initMethod = None, defomax = None, initOnly = None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False wrapName = self.insar.topophaseFlatFilename unwrapName = self.insar.unwrappedIntFilename wavelength = self.insar.masterFrame.getInstrument().getRadarWavelength() width = self.insar.resampIntImage.width earthRadius = self.insar.peg.radiusOfCurvature altitude = self.insar.averageHeight corrfile = self.insar.getCoherenceFilename() rangeLooks = self.insar.topo.numberRangeLooks azimuthLooks = self.insar.topo.numberAzimuthLooks azres = self.insar.masterFrame.platform.antennaLength/2.0 azfact = self.insar.topo.numberAzimuthLooks *azres / self.insar.topo.azimuthSpacing rBW = self.insar.masterFrame.instrument.pulseLength * self.insar.masterFrame.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) rngfact = rgres/self.insar.topo.slantRangePixelSpacing corrLooks = self.insar.topo.numberRangeLooks * self.insar.topo.numberAzimuthLooks/(azfact*rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName+'.conncomp') #At least one can query for the name used self.insar.connectedComponentsFilename = unwrapName+'.conncomp' connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.finalizeImage() connImage.renderHdr() return
def snaphuUnwrap(track, t, wrapName, corName, unwrapName, nrlks, nalks, costMode='DEFO', initMethod='MST', defomax=4.0, initOnly=False): #runUnwrap(self, costMode = 'SMOOTH',initMethod = 'MCF', defomax = 2, initOnly = True) ''' track: track object t: time for computing earth radius and altitude, normally mid azimuth time wrapName: input interferogram corName: input coherence file unwrapName: output unwrapped interferogram nrlks: number of range looks of the interferogram nalks: number of azimuth looks of the interferogram ''' import datetime import numpy as np import isceobj from contrib.Snaphu.Snaphu import Snaphu from isceobj.Planet.Planet import Planet corImg = isceobj.createImage() corImg.load(corName + '.xml') width = corImg.width length = corImg.length #get altitude orbit = track.orbit peg = orbit.interpolateOrbit(t, method='hermite') refElp = Planet(pname='Earth').ellipsoid llh = refElp.xyz_to_llh(peg.getPosition()) hdg = orbit.getENUHeading(t) refElp.setSCH(llh[0], llh[1], hdg) earthRadius = refElp.pegRadCur altitude = llh[2] rangeLooks = nrlks azimuthLooks = nalks azfact = 0.8 rngfact = 0.8 corrLooks = rangeLooks * azimuthLooks / (azfact * rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(track.radarWavelength) snp.setAltitude(altitude) snp.setCorrfile(corName) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) if corImg.bands == 1: snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.renderVRT() outImage.createImage() outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.renderVRT() connImage.createImage() connImage.finalizeImage() connImage.renderHdr() del connImage del corImg del snp del outImage #remove wired things in no-data area amp = np.memmap(unwrapName, dtype='float32', mode='r+', shape=(length * 2, width)) wrap = np.fromfile(wrapName, dtype=np.complex64).reshape(length, width) (amp[0:length * 2:2, :])[np.nonzero(wrap == 0)] = 0 (amp[1:length * 2:2, :])[np.nonzero(wrap == 0)] = 0 del amp del wrap return
def runUnwrap(self, costMode=None, initMethod=None, defomax=None, initOnly=None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False wavelength = self.insar.masterFrame.getInstrument().getRadarWavelength() width = self.insar.resampIntImage.width earthRadius = self.insar.peg.radiusOfCurvature altitude = self.insar.averageHeight corrfile = self.insar.getCoherenceFilename() rangeLooks = self.insar.topo.numberRangeLooks azimuthLooks = self.insar.topo.numberAzimuthLooks azres = self.insar.masterFrame.platform.antennaLength / 2.0 azfact = self.insar.topo.numberAzimuthLooks * azres / self.insar.topo.azimuthSpacing rBW = self.insar.masterFrame.instrument.pulseLength * self.insar.masterFrame.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) rngfact = rgres / self.insar.topo.slantRangePixelSpacing corrLooks = self.insar.topo.numberRangeLooks * self.insar.topo.numberAzimuthLooks / ( azfact * rngfact) maxComponents = 20 #Unfortunately isce changes topophaseFlatFilename to the filtered one so need to change #it back self._unwrapList = [ (self.insar.topophaseFlatFilename.replace('filt_', ''), self.insar.topophaseFlatFilename.replace('.flat', '.unw').replace('filt_', '')), (self.insar.filt_topophaseFlatFilename, self.insar.filt_topophaseFlatFilename.replace('.flat', '.unw')) ] #need to add them to the instance so they can later be part of the geolist self._unwrappedIntFilename = self._unwrapList[0][1] self._unwrappedIntFiltFilename = self._unwrapList[1][1] for wrapName, unwrapName in self._unwrapList: snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.createImage() outImage.renderHdr() outImage.finalizeImage() return
def runUnwrap(infile, outfile, corfile, config, unwrap_2stage=False): from contrib.Snaphu.Snaphu import Snaphu costMode = 'DEFO' initMethod = config['init_method'] defomax = config['defomax'] wrapName = infile unwrapName = outfile if unwrap_2stage: unwrapName = os.path.dirname(outfile) + '/temp_filt_fine.unw' img = isceobj.createImage() img.load(infile + '.xml') wavelength = float(config['wavelength']) width = img.getWidth() length = img.getLength() earthRadius = float(config['earth_radius']) altitude = float(config['height']) rangeLooks = int(config['rglooks']) azimuthLooks = int(config['azlooks']) snp = Snaphu() snp.setInitOnly(False) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corfile) snp.setInitMethod(initMethod) snp.setMaxComponents(100) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setLength(length) outImage.setAccessMode('read') # outImage.createImage() outImage.renderHdr() outImage.renderVRT() # outImage.finalizeImage() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') # At least one can query for the name used connImage.setWidth(width) connImage.setLength(length) connImage.setAccessMode('read') connImage.setDataType('BYTE') # connImage.createImage() connImage.renderHdr() connImage.renderVRT() # connImage.finalizeImage() return
def runSnaphu(self, igramSpectrum="full", costMode=None, initMethod=None, defomax=None, initOnly=None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False print("igramSpectrum: ", igramSpectrum) if igramSpectrum == "full": ifgDirname = self.insar.ifgDirname elif igramSpectrum == "low": if not self.doDispersive: print( 'Estimating dispersive phase not requested ... skipping sub-band interferogram unwrapping' ) return ifgDirname = os.path.join(self.insar.ifgDirname, self.insar.lowBandSlcDirname) elif igramSpectrum == "high": if not self.doDispersive: print( 'Estimating dispersive phase not requested ... skipping sub-band interferogram unwrapping' ) return ifgDirname = os.path.join(self.insar.ifgDirname, self.insar.highBandSlcDirname) wrapName = os.path.join(ifgDirname, 'filt_' + self.insar.ifgFilename) if '.flat' in wrapName: unwrapName = wrapName.replace('.flat', '.unw') elif '.int' in wrapName: unwrapName = wrapName.replace('.int', '.unw') else: unwrapName = wrapName + '.unw' corName = os.path.join(ifgDirname, self.insar.coherenceFilename) referenceFrame = self._insar.loadProduct( self._insar.referenceSlcCropProduct) wavelength = referenceFrame.getInstrument().getRadarWavelength() img1 = isceobj.createImage() img1.load(wrapName + '.xml') width = img1.getWidth() #width = self.insar.resampIntImage.width orbit = referenceFrame.orbit prf = referenceFrame.PRF elp = copy.copy(referenceFrame.instrument.platform.planet.ellipsoid) sv = orbit.interpolate(referenceFrame.sensingMid, method='hermite') hdg = orbit.getHeading() llh = elp.xyz_to_llh(sv.getPosition()) elp.setSCH(llh[0], llh[1], hdg) earthRadius = elp.pegRadCur sch, vsch = elp.xyzdot_to_schdot(sv.getPosition(), sv.getVelocity()) azimuthSpacing = vsch[0] * earthRadius / ((earthRadius + sch[2]) * prf) earthRadius = elp.pegRadCur altitude = sch[2] rangeLooks = 1 # self.numberRangeLooks #insar.topo.numberRangeLooks azimuthLooks = 1 # self.numberAzimuthLooks #insar.topo.numberAzimuthLooks if not self.numberAzimuthLooks: self.numberAzimuthLooks = 1 if not self.numberRangeLooks: self.numberRangeLooks = 1 azres = referenceFrame.platform.antennaLength / 2.0 azfact = self.numberAzimuthLooks * azres / azimuthSpacing rBW = referenceFrame.instrument.pulseLength * referenceFrame.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) rngfact = rgres / referenceFrame.getInstrument().getRangePixelSize() corrLooks = self.numberRangeLooks * self.numberAzimuthLooks / (azfact * rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corName) snp.setInitMethod(initMethod) #snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.renderHdr() outImage.renderVRT() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') #At least one can query for the name used self.insar.connectedComponentsFilename = unwrapName + '.conncomp' connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.renderHdr() connImage.renderVRT() return
def runUnwrap(self, costMode=None, initMethod=None, defomax=None, initOnly=None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False wrapName = self.insar.topophaseFlatFilename unwrapName = self.insar.unwrappedIntFilename wavelength = self.insar.masterFrame.getInstrument().getRadarWavelength() width = self.insar.resampIntImage.width orbit = self.insar.masterFrame.orbit prf = self.insar.masterFrame.PRF elp = copy.copy( self.insar.masterFrame.instrument.platform.planet.ellipsoid) sv = orbit.interpolate(self.insar.masterFrame.sensingMid, method='hermite') hdg = orbit.getHeading() llh = elp.xyz_to_llh(sv.getPosition()) elp.setSCH(llh[0], llh[1], hdg) earthRadius = elp.pegRadCur sch, vsch = elp.xyzdot_to_schdot(sv.getPosition(), sv.getVelocity()) azimuthSpacing = vsch[0] * earthRadius / ((earthRadius + sch[2]) * prf) earthRadius = elp.pegRadCur altitude = sch[2] corrfile = self.insar.getCoherenceFilename() rangeLooks = self.insar.topo.numberRangeLooks azimuthLooks = self.insar.topo.numberAzimuthLooks azres = self.insar.masterFrame.platform.antennaLength / 2.0 azfact = self.insar.topo.numberAzimuthLooks * azres / azimuthSpacing rBW = self.insar.masterFrame.instrument.pulseLength * self.insar.masterFrame.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) rngfact = rgres / self.insar.topo.slantRangePixelSpacing corrLooks = self.insar.topo.numberRangeLooks * self.insar.topo.numberAzimuthLooks / ( azfact * rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.createImage() outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') #At least one can query for the name used self.insar.connectedComponentsFilename = unwrapName + '.conncomp' connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.createImage() connImage.finalizeImage() connImage.renderHdr() return
def run(frame1, width, costMode, initMethod, defomax, initOnly, infos, sceneid='NO_ID'): logger.info("Unwrapping interferogram using Snaphu %s: %s" % (initMethod, sceneid)) topo = infos['topo'] wrapName = infos['outputPath'] + '.' + infos['topophaseFlatFilename'] unwrapName = infos['outputPath'] + '.' + infos['unwrappedIntFilename'] corrfile = infos['outputPath'] + '.' + infos['coherenceFilename'] altitude = infos['averageHeight'] wavelength = frame1.getInstrument().getRadarWavelength() earthRadius = infos['peg'].radiusOfCurvature rangeLooks = topo.numberRangeLooks azimuthLooks = topo.numberAzimuthLooks azres = frame1.platform.antennaLength / 2.0 azfact = topo.numberAzimuthLooks * azres / topo.azimuthSpacing rBW = frame1.instrument.pulseLength * frame1.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) rngfact = rgres / topo.slantRangePixelSpacing corrLooks = topo.numberRangeLooks * topo.numberAzimuthLooks / (azfact * rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.imageType = 'unw' outImage.bands = 2 outImage.scheme = 'BIL' outImage.dataType = 'FLOAT' outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.finalizeImage() connImage.renderHdr()
def runUnwrap(infile, outfile, corfile, config, costMode=None, initMethod=None, defomax=None, initOnly=None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False wrapName = infile unwrapName = outfile img = isceobj.createImage() img.load(infile + '.xml') wavelength = config['wavelength'] width = img.getWidth() length = img.getLength() earthRadius = config['earthRadius'] altitude = config['altitude'] rangeLooks = config['rglooks'] azimuthLooks = config['azlooks'] #corrLooks = config['corrlooks'] maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corfile) snp.setInitMethod(initMethod) # snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setLength(length) outImage.setAccessMode('read') #outImage.createImage() outImage.renderHdr() outImage.renderVRT() #outImage.finalizeImage() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') #At least one can query for the name used connImage.setWidth(width) connImage.setLength(length) connImage.setAccessMode('read') connImage.setDataType('BYTE') # connImage.createImage() connImage.renderHdr() connImage.renderVRT() # connImage.finalizeImage() return
def runUnwrap(self,costMode = None,initMethod = None, defomax = None, initOnly = None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False wrapName = os.path.join( self._insar.mergedDirname, self._insar.filtFilename) unwrapName = os.path.join( self._insar.mergedDirname, self._insar.unwrappedIntFilename) img = isceobj.createImage() img.load(wrapName + '.xml') swathList = self._insar.getValidSwathList(self.swaths) for swath in swathList[0:1]: ifg = self._insar.loadProduct( os.path.join(self._insar.fineIfgDirname, 'IW{0}.xml'.format(swath))) wavelength = ifg.bursts[0].radarWavelength width = img.getWidth() ####tmid tstart = ifg.bursts[0].sensingStart tend = ifg.bursts[-1].sensingStop tmid = tstart + 0.5*(tend - tstart) orbit = ifg.bursts[0].orbit peg = orbit.interpolateOrbit(tmid, method='hermite') refElp = Planet(pname='Earth').ellipsoid llh = refElp.xyz_to_llh(peg.getPosition()) hdg = orbit.getENUHeading(tmid) refElp.setSCH(llh[0], llh[1], hdg) earthRadius = refElp.pegRadCur altitude = llh[2] corrfile = os.path.join(self._insar.mergedDirname, self._insar.coherenceFilename) rangeLooks = self.numberRangeLooks azimuthLooks = self.numberAzimuthLooks azfact = 0.8 rngfact = 0.8 corrLooks = rangeLooks * azimuthLooks/(azfact*rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.renderVRT() outImage.createImage() outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName+'.conncomp') #At least one can query for the name used self._insar.connectedComponentsFilename = unwrapName+'.conncomp' connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.renderVRT() connImage.createImage() connImage.finalizeImage() connImage.renderHdr() return
def runUnwrap(inps_json): costMode = 'SMOOTH' initMethod = 'MCF' defomax = 2.0 initOnly = True if isinstance(inps_json,str): inps = json.load(open(inps_json)) elif isinstance(inps_json,dict): inps = inps_json else: print('Expecting a json filename or a dictionary') raise ValueError wrapName = inps['flat_name'] unwrapName = inps['unw_name'] img = isceobj.createImage() img.load(wrapName + '.xml') width = img.getWidth() earthRadius = inps['earth_radius'] altitude = inps['altitude'] corrfile = inps['cor_name'] rangeLooks = inps['range_looks'] azimuthLooks = inps['azimuth_looks'] wavelength = inps['wavelength'] azfact = 0.8 rngfact = 0.8 corrLooks = rangeLooks * azimuthLooks/(azfact*rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.renderVRT() outImage.createImage() outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName+'.conncomp') #At least one can query for the name used connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.renderVRT() connImage.createImage() connImage.finalizeImage() connImage.renderHdr() return
def runUnwrap(inps, costMode=None, initMethod=None, defomax=None, initOnly=None): if costMode is None: costMode = 'DEFO' if initMethod is None: initMethod = 'MST' if defomax is None: defomax = 4.0 if initOnly is None: initOnly = False #get earth radius and altitude using master's orbit with open(inps.mframe, 'rb') as f: mframe = pickle.load(f) azti = 1.0 / mframe.PRF tmid = mframe.getSensingStart() + datetime.timedelta( seconds=azti * (mframe.getNumberOfLines() / 2.0)) orbit = mframe.getOrbit() peg = orbit.interpolateOrbit(tmid, method='hermite') refElp = Planet(pname='Earth').ellipsoid llh = refElp.xyz_to_llh(peg.getPosition()) hdg = orbit.getHeading(tmid) #change to the following after updated to the newest version of isce #hdg = orbit.getENUHeading(tmid) refElp.setSCH(llh[0], llh[1], hdg) earthRadius = refElp.pegRadCur altitude = llh[2] wrapName = inps.inf unwrapName = inps.unw corrfile = inps.cor width = getWidth(wrapName + '.xml') wavelength = mframe.getInstrument().getRadarWavelength() rangeLooks = inps.rlks azimuthLooks = inps.alks #calculate azimuth resolution and pixel size azres = mframe.platform.antennaLength / 2.0 vel = np.sqrt(peg.velocity[0] * peg.velocity[0] + peg.velocity[1] * peg.velocity[1] + peg.velocity[2] * peg.velocity[2]) hgt = np.sqrt(peg.position[0] * peg.position[0] + peg.position[1] * peg.position[1] + peg.position[2] * peg.position[2]) azimuthPixelSpacing = earthRadius / hgt * vel * azti azfact = azres / azimuthPixelSpacing #calculate range resolution and pixel size rBW = mframe.instrument.pulseLength * mframe.instrument.chirpSlope rgres = abs(SPEED_OF_LIGHT / (2.0 * rBW)) slantRangePixelSpacing = 0.5 * SPEED_OF_LIGHT / mframe.rangeSamplingRate rngfact = rgres / slantRangePixelSpacing print('azfact: {}, rngfact: {}'.format(azfact, rngfact)) corrLooks = azimuthLooks * rangeLooks / (azfact * rngfact) maxComponents = 20 snp = Snaphu() snp.setInitOnly(initOnly) # follow snp.setInput(wrapName) snp.setOutput(unwrapName) snp.setWidth(width) snp.setCostMode(costMode) # follow snp.setEarthRadius(earthRadius) snp.setWavelength(wavelength) snp.setAltitude(altitude) snp.setCorrfile(corrfile) snp.setInitMethod(initMethod) # follow snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) # follow snp.setRangeLooks(rangeLooks) snp.setAzimuthLooks(azimuthLooks) #snp.setCorFileFormat('FLOAT_DATA') snp.prepare() snp.unwrap() ######Render XML outImage = isceobj.Image.createUnwImage() outImage.setFilename(unwrapName) outImage.setWidth(width) outImage.setAccessMode('read') outImage.renderVRT() outImage.createImage() outImage.finalizeImage() outImage.renderHdr() #####Check if connected components was created if snp.dumpConnectedComponents: connImage = isceobj.Image.createImage() connImage.setFilename(unwrapName + '.conncomp') #At least one can query for the name used #self._insar.connectedComponentsFilename = unwrapName+'.conncomp' connImage.setWidth(width) connImage.setAccessMode('read') connImage.setDataType('BYTE') connImage.renderVRT() connImage.createImage() connImage.finalizeImage() connImage.renderHdr() return