ml3 = '_{}rlks_{}alks'.format(numberRangeLooks1*numberRangeLooks2, numberAzimuthLooks1*numberAzimuthLooks2) width2 = width length2 = length #ionrectfile1 = os.path.join(idir, pairs[0], 'insar', pairs[0] + ml3 + '.ion') #multilookDifferentialInterferogram = os.path.join(idir, pairs[0], 'insar', 'diff_' + pairs[0] + ml3 + '.int') #img = isceobj.createImage() #img.load(multilookDifferentialInterferogram + '.xml') #width3 = img.width #length3 = img.length trackParameter = os.path.join(idir, pairs[0], dateReferenceStack + '.track.xml') trackTmp = loadProduct(trackParameter) width3 = int(trackTmp.numberOfSamples / numberRangeLooks2) length3 = int(trackTmp.numberOfLines / numberAzimuthLooks2) #number of range looks output nrlo = numberRangeLooks1*numberRangeLooks2 #number of range looks input nrli = numberRangeLooks1*numberRangeLooksIon #number of azimuth looks output nalo = numberAzimuthLooks1*numberAzimuthLooks2 #number of azimuth looks input nali = numberAzimuthLooks1*numberAzimuthLooksIon cdir = os.getcwd() os.makedirs(odir, exist_ok=True) os.chdir(odir)
if __name__ == '__main__': inps = cmdLineParse() #get user parameters from input ref_date_stack_track = inps.ref_date_stack_track demGeo = inps.dem inputFile = inps.input bbox = inps.bbox geocodeInterpMethod = inps.interp_method numberRangeLooks = inps.nrlks numberAzimuthLooks = inps.nalks ####################################################### demFile = os.path.abspath(demGeo) trackReferenceStack = loadProduct(ref_date_stack_track) #compute bounding box for geocoding if bbox is not None: bbox = [float(x) for x in bbox.split('/')] if len(bbox) != 4: raise Exception('user input bbox must have four elements') else: img = isceobj.createImage() img.load(inputFile + '.xml') bbox = getBboxGeo(trackReferenceStack, useTrackOnly=True, numberOfSamples=img.width, numberOfLines=img.length, numberRangeLooks=numberRangeLooks, numberAzimuthLooks=numberAzimuthLooks)
simFile = 'radar_{}.sim'.format(ml1) self = createObject() self._insar = createObject() self._insar.dem = demFile self._insar.numberRangeLooksSim = numberRangeLooksSim self._insar.numberRangeLooks1 = numberRangeLooks1 self._insar.numberAzimuthLooksSim = numberAzimuthLooksSim self._insar.numberAzimuthLooks1 = numberAzimuthLooks1 self._insar.height = os.path.basename(height) self._insar.sim = simFile self._insar.amplitude = os.path.basename(amplitude) self._insar.wbdOut = os.path.basename(wbdOut) self._insar.radarDemAffineTransform = None referenceTrack = loadProduct(trackParameter) rdrDemOffset(self, referenceTrack, catalog=None) os.chdir(insarDir) #save the result with open(output, 'w') as f: f.write('{} {}\n{}'.format(self._insar.numberRangeLooksSim, self._insar.numberAzimuthLooksSim, self._insar.radarDemAffineTransform)) #remove amplitude image os.remove(os.path.basename(amplitude)) os.remove(os.path.basename(amplitude) + '.vrt') os.remove(os.path.basename(amplitude) + '.xml') os.chdir('../')
dateReference = inps.ref_date dateSecondary = inps.sec_date numberRangeLooks1 = inps.nrlks1 numberAzimuthLooks1 = inps.nalks1 ####################################################### pair = '{}-{}'.format(dateReference, dateSecondary) ml1 = '_{}rlks_{}alks'.format(numberRangeLooks1, numberAzimuthLooks1) dateDirs, dates, frames, swaths, dateIndexReference = stackDateStatistics( idir, dateReferenceStack) trackParameter = os.path.join(dateDirs[dateIndexReference], dates[dateIndexReference] + '.track.xml') trackReferenceStack = loadProduct(trackParameter) rangePixelSize = numberRangeLooks1 * trackReferenceStack.rangePixelSize radarWavelength = trackReferenceStack.radarWavelength insarDir = 'insar' os.makedirs(insarDir, exist_ok=True) os.chdir(insarDir) interferogram = pair + ml1 + '.int' differentialInterferogram = 'diff_' + pair + ml1 + '.int' if dateReference == dateReferenceStack: rectRangeOffset = os.path.join('../', idir, dateSecondary, 'insar', dateSecondary + ml1 + '_rg_rect.off') cmd = "imageMath.py -e='a*exp(-1.0*J*b*4.0*{}*{}/{})*(b!=0)' --a={} --b={} -o {} -t cfloat".format(
pair = '{}-{}'.format(dateReference, dateSecondary) ms = pair ml2 = '_{}rlks_{}alks'.format(numberRangeLooks1 * numberRangeLooks2, numberAzimuthLooks1 * numberAzimuthLooks2) self = createObject() self._insar = createObject() self._insar.filteredInterferogram = 'filt_' + ms + ml2 + '.int' self._insar.multilookAmplitude = ms + ml2 + '.amp' self._insar.multilookPhsig = ms + ml2 + '.phsig' self._insar.unwrappedInterferogram = 'filt_' + ms + ml2 + '.unw' self._insar.unwrappedMaskedInterferogram = 'filt_' + ms + ml2 + '_msk.unw' self._insar.multilookWbdOut = os.path.join( '../', idir, dateReferenceStack, 'insar', dateReferenceStack + ml2 + '.wbd') self._insar.numberRangeLooks1 = numberRangeLooks1 self._insar.numberAzimuthLooks1 = numberAzimuthLooks1 self._insar.numberRangeLooks2 = numberRangeLooks2 self._insar.numberAzimuthLooks2 = numberAzimuthLooks2 if waterBodyMaskStartingStep: self.waterBodyMaskStartingStep = 'unwrap' else: self.waterBodyMaskStartingStep = None trackReference = loadProduct('{}.track.xml'.format(dateReference)) unwrapSnaphu(self, trackReference)