From 431f857ba7e37f29aca24ffb726d2157f81c8689 Mon Sep 17 00:00:00 2001 From: piyushrpt Date: Mon, 11 Nov 2019 10:42:11 -0800 Subject: [PATCH 1/7] Look for autorift --- contrib/SConscript | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/SConscript b/contrib/SConscript index fb91670..268c0cb 100644 --- a/contrib/SConscript +++ b/contrib/SConscript @@ -78,3 +78,6 @@ SConscript(rfi) SConscript('PyCuAmpcor/SConscript') SConscript('splitSpectrum/SConscript') SConscript('alos2proc/SConscript') + +if os.path.exists('geoAutorift'): + SConscript('geoAutorift/SConscript') From 6e36a73fb0a0e34cc2e30bb06ca5995bd14deb3a Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Mon, 18 Mar 2019 19:00:18 -0400 Subject: [PATCH 2/7] stripmapStack/unwrap: enable corrlooks for SNAPHU Stack: + add alks and rlks while writing config file for unwrap unwrap: + calculate the az/rg spacing/resolution and the equivalent number of independent looks in extractInfoFromPickle() + uncomment corrlooks setting in runUnwrap() --- contrib/stack/stripmapStack/Stack.py | 2 ++ contrib/stack/stripmapStack/unwrap.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/contrib/stack/stripmapStack/Stack.py b/contrib/stack/stripmapStack/Stack.py index 74d0df4..b0a116e 100755 --- a/contrib/stack/stripmapStack/Stack.py +++ b/contrib/stack/stripmapStack/Stack.py @@ -197,6 +197,8 @@ class config(object): self.f.write('nomcf : ' + self.noMCF + '\n') self.f.write('master : ' + self.master + '\n') self.f.write('defomax : ' + self.defoMax + '\n') + self.f.write('alks : ' + self.alks + '\n') + self.f.write('rlks : ' + self.rlks + '\n') self.f.write('method : ' + self.unwMethod + '\n') self.f.write('##########################'+'\n') diff --git a/contrib/stack/stripmapStack/unwrap.py b/contrib/stack/stripmapStack/unwrap.py index bae4893..f1de7f9 100755 --- a/contrib/stack/stripmapStack/unwrap.py +++ b/contrib/stack/stripmapStack/unwrap.py @@ -113,9 +113,19 @@ def extractInfoFromPickle(pckfile, inps): data['earthRadius'] = elp.local_radius_of_curvature(llh.lat, hdg) #azspacing = burst.azimuthTimeInterval * sv.getScalarVelocity() - azres = 20.0 + #azres = 20.0 + azspacing = sv.getScalarVelocity() / burst.PRF + azres = burst.platform.antennaLength / 2.0 + azfact = azres / azspacing + + burst.getInstrument() + rgBandwidth = burst.instrument.pulseLength * burst.instrument.chirpSlope + rgres = abs(SPEED_OF_LIGHT / (2.0 * rgBandwidth)) + rgspacing = burst.instrument.rangePixelSize + rgfact = rgres / rgspacing #data['corrlooks'] = inps.rglooks * inps.azlooks * azspacing / azres + data['corrlooks'] = inps.rglooks * inps.azlooks / (azfact * rgfact) data['rglooks'] = inps.rglooks data['azlooks'] = inps.azlooks @@ -149,7 +159,7 @@ def runUnwrap(infile, outfile, corfile, config, costMode = None,initMethod = Non altitude = config['altitude'] rangeLooks = config['rglooks'] azimuthLooks = config['azlooks'] - #corrLooks = config['corrlooks'] + corrLooks = config['corrlooks'] maxComponents = 20 snp = Snaphu() @@ -163,7 +173,7 @@ def runUnwrap(infile, outfile, corfile, config, costMode = None,initMethod = Non snp.setAltitude(altitude) snp.setCorrfile(corfile) snp.setInitMethod(initMethod) - # snp.setCorrLooks(corrLooks) + snp.setCorrLooks(corrLooks) snp.setMaxComponents(maxComponents) snp.setDefoMaxCycles(defomax) snp.setRangeLooks(rangeLooks) From 43aee1dcb327df8c6e2d2f4d8d53f8aa82e78244 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Thu, 21 Nov 2019 13:29:34 -0800 Subject: [PATCH 3/7] stripmapStack/unwrap: adjust indentation --- contrib/stack/stripmapStack/unwrap.py | 90 ++++++++++++++------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/contrib/stack/stripmapStack/unwrap.py b/contrib/stack/stripmapStack/unwrap.py index f1de7f9..77080ce 100755 --- a/contrib/stack/stripmapStack/unwrap.py +++ b/contrib/stack/stripmapStack/unwrap.py @@ -258,33 +258,34 @@ def runUnwrapIcu(infile, outfile): unwImage.finalizeImage() unwImage.renderHdr() -def runUnwrap2Stage(unwrappedIntFilename,connectedComponentsFilename,unwrapped2StageFilename, unwrapper_2stage_name=None, solver_2stage=None): +def runUnwrap2Stage(unwrappedIntFilename,connectedComponentsFilename,unwrapped2StageFilename, + 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 = unwrappedIntFilename - ccFile = connectedComponentsFilename - outFile = 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 + 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 = unwrappedIntFilename + ccFile = connectedComponentsFilename + outFile = 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 def main(iargs=None): @@ -303,24 +304,26 @@ def main(iargs=None): if inps.method != 'icu': - masterShelveDir = os.path.join(interferogramDir , 'masterShelve') - if not os.path.exists(masterShelveDir): - os.makedirs(masterShelveDir) + masterShelveDir = os.path.join(interferogramDir , 'masterShelve') + if not os.path.exists(masterShelveDir): + os.makedirs(masterShelveDir) + + inps.master = os.path.dirname(inps.master) + cpCmd='cp ' + os.path.join(inps.master, 'data*') +' '+masterShelveDir + os.system(cpCmd) + pckfile = os.path.join(masterShelveDir,'data') + print(pckfile) + metadata = extractInfoFromPickle(pckfile, inps) - inps.master = os.path.dirname(inps.master) - cpCmd='cp ' + os.path.join(inps.master, 'data*') +' '+masterShelveDir - os.system(cpCmd) - pckfile = os.path.join(masterShelveDir,'data') - print(pckfile) - metadata = extractInfoFromPickle(pckfile, inps) ######## print ('unwrapping method : ' , inps.method) if inps.method == 'snaphu': - if inps.nomcf: - fncall = runUnwrap - else: - fncall = runUnwrapMcf - fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax) + if inps.nomcf: + fncall = runUnwrap + else: + fncall = runUnwrapMcf + fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax) + elif inps.method == 'snaphu2stage': if inps.nomcf: fncall = runUnwrap @@ -329,11 +332,12 @@ def main(iargs=None): fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax) # adding in the two-stage - runUnwrap2Stage(inps.unwprefix + '_snaphu.unw', inps.unwprefix + '_snaphu.unw.conncomp',inps.unwprefix + '_snaphu2stage.unw') - + runUnwrap2Stage(inps.unwprefix + '_snaphu.unw', + inps.unwprefix + '_snaphu.unw.conncomp', + inps.unwprefix + '_snaphu2stage.unw') elif inps.method == 'icu': - runUnwrapIcu(inps.intfile, inps.unwprefix + '_icu.unw') + runUnwrapIcu(inps.intfile, inps.unwprefix + '_icu.unw') if __name__ == '__main__': From 21675df72476af2dfa81d5aba557ab07527ce535 Mon Sep 17 00:00:00 2001 From: piyushrpt Date: Tue, 10 Dec 2019 09:54:36 -0800 Subject: [PATCH 4/7] Bug fixes for rubbersheeting --- components/isceobj/StripmapProc/runResampleSlc.py | 1 + examples/input_files/stripmapApp.xml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/isceobj/StripmapProc/runResampleSlc.py b/components/isceobj/StripmapProc/runResampleSlc.py index c108c98..b1dfa72 100644 --- a/components/isceobj/StripmapProc/runResampleSlc.py +++ b/components/isceobj/StripmapProc/runResampleSlc.py @@ -75,6 +75,7 @@ def runResampleSlc(self, kind='coarse'): if kind in ['coarse', 'refined']: azname = os.path.join(offsetsDir, self.insar.azimuthOffsetFilename) rgname = os.path.join(offsetsDir, self.insar.rangeOffsetFilename) + flatten = True else: azname = os.path.join(offsetsDir, self.insar.azimuthRubbersheetFilename) if self.doRubbersheetingRange: diff --git a/examples/input_files/stripmapApp.xml b/examples/input_files/stripmapApp.xml index f4eff23..87c1365 100644 --- a/examples/input_files/stripmapApp.xml +++ b/examples/input_files/stripmapApp.xml @@ -12,7 +12,8 @@ /Users/fattahi/process/test_roiApp/Alos_Maule_T116/demLat_S39_S35_Lon_W074_W071.dem.wgs84 True True From 80d25ca7279b447cf27d49593e293eecc165f61c Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Sat, 14 Dec 2019 15:30:51 -0800 Subject: [PATCH 5/7] Simplify python version info --- SConstruct | 35 ++--------------------------------- __init__.py | 10 +++------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/SConstruct b/SConstruct index 8e653fe..a979b3c 100644 --- a/SConstruct +++ b/SConstruct @@ -216,43 +216,12 @@ else: ### End of GPU branch-specific modifications -file = '__init__.py' -if not os.path.exists(file): - fout = open(file,"w") - fout.write("#!/usr/bin/env python3") - fout.close() - -env.Install(inst,file) -try: - from subprocess import check_output - svn_revision = check_output('svnversion').strip() or 'Unknown' - if sys.version_info[0] == 3: - svn_revision = svn_revision.decode('utf-8') -except ImportError: - try: - import popen2 - stdout, stdin, stderr = popen2.popen3('svnversion') - svn_revision = stdout.read().strip() - if stderr.read(): - raise Exception - except Exception: - svn_revision = 'Unknown' -except OSError: - svn_revision = 'Unknown' +env.Install(inst, '__init__.py') +env.Install(inst, 'release_history.py') if not os.path.exists(inst): os.makedirs(inst) -fvers = open(os.path.join(inst,'version.py'),'w') - -from release_history import release_version, release_svn_revision, release_date -fvers_lines = ["release_version = '"+release_version+"'\n", - "release_svn_revision = '"+release_svn_revision+"'\n", - "release_date = '"+release_date+"'\n", - "svn_revision = '"+svn_revision+"'\n\n"] - -fvers.write(''.join(fvers_lines)) -fvers.close() v = 0 if isrerun == 'no': cmd = 'scons -Q install --isrerun=yes' diff --git a/__init__.py b/__init__.py index 138b442..a6e2c5b 100755 --- a/__init__.py +++ b/__init__.py @@ -25,13 +25,9 @@ # Author: Giangi Sacco #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - -from __future__ import print_function - -from .version import release_version, release_svn_revision, release_date -from .version import svn_revision +from .release_history import release_version, release_svn_revision, release_date +svn_revision = release_svn_revision +version = release_history # compatibility alias __version__ = release_version From 537bae03d958fd7b1aee216bd7700f6f07f62da6 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Sat, 14 Dec 2019 12:20:41 -0800 Subject: [PATCH 6/7] Hide rubbersheeting scipy/astropy imports Recent rubbersheeting changes added scipy and astropy imports which are not otherwise needed. Due to isce2's eager import behavior this causes errors when using unrelated functionality. We can fix this by tucking these imports away inside their function definitions. To reproduce: `python3 -c "import isce; from stripmapApp import Insar"` (without scipy/astropy installed) --- .../isceobj/StripmapProc/runRubbersheet.py | 6 +++++- .../StripmapProc/runRubbersheetAzimuth.py | 15 ++++++++++---- .../StripmapProc/runRubbersheetRange.py | 20 ++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/components/isceobj/StripmapProc/runRubbersheet.py b/components/isceobj/StripmapProc/runRubbersheet.py index b16a58e..ea417bd 100644 --- a/components/isceobj/StripmapProc/runRubbersheet.py +++ b/components/isceobj/StripmapProc/runRubbersheet.py @@ -6,7 +6,6 @@ import isce import isceobj from osgeo import gdal -from scipy import ndimage import numpy as np import os @@ -24,6 +23,9 @@ def fill(data, invalid=None): Output: Return a filled array. """ + + from scipy import ndimage + if invalid is None: invalid = np.isnan(data) ind = ndimage.distance_transform_edt(invalid, @@ -35,6 +37,8 @@ def fill(data, invalid=None): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName): #masking and Filtering + from scipy import ndimage + ##Read in the offset file ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) Offset = ds.GetRasterBand(1).ReadAsArray() diff --git a/components/isceobj/StripmapProc/runRubbersheetAzimuth.py b/components/isceobj/StripmapProc/runRubbersheetAzimuth.py index 75583f1..43ee4a8 100755 --- a/components/isceobj/StripmapProc/runRubbersheetAzimuth.py +++ b/components/isceobj/StripmapProc/runRubbersheetAzimuth.py @@ -9,14 +9,14 @@ import isce import isceobj from osgeo import gdal -from scipy import ndimage -from astropy.convolution import convolve import numpy as np import os def mask_filterNoSNR(denseOffsetFile,filterSize,outName): # Masking the offsets with a data-based approach - + + from scipy import ndimage + # Open the offsets ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly) off_az = ds.GetRasterBand(1).ReadAsArray() @@ -79,6 +79,9 @@ def mask_filterNoSNR(denseOffsetFile,filterSize,outName): def off_masking(off,filterSize,thre=2): + + from scipy import ndimage + # Define the mask to fill the offsets vram = ndimage.median_filter(off.real, filterSize) vazm = ndimage.median_filter(off.imag, filterSize) @@ -112,6 +115,8 @@ def fill(data, invalid=None): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName): #masking and Filtering + from scipy import ndimage + ##Read in the offset file ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) Offset = ds.GetRasterBand(band).ReadAsArray() @@ -154,7 +159,9 @@ def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outNam return None def fill_with_smoothed(off,filterSize): - + + from astropy.convolution import convolve + off_2filt=np.copy(off) kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize) loop = 0 diff --git a/components/isceobj/StripmapProc/runRubbersheetRange.py b/components/isceobj/StripmapProc/runRubbersheetRange.py index 2f1ab3f..04fc2a2 100755 --- a/components/isceobj/StripmapProc/runRubbersheetRange.py +++ b/components/isceobj/StripmapProc/runRubbersheetRange.py @@ -9,15 +9,14 @@ import isce import isceobj from osgeo import gdal -from scipy import ndimage import numpy as np import os -from astropy.convolution import convolve - def mask_filterNoSNR(denseOffsetFile,filterSize,outName): # Masking the offsets with a data-based approach - + + from scipy import ndimage + # Open the offsets ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly) off_az = ds.GetRasterBand(1).ReadAsArray() @@ -78,6 +77,9 @@ def mask_filterNoSNR(denseOffsetFile,filterSize,outName): return def off_masking(off,filterSize,thre=2): + + from scipy import ndimage + vram = ndimage.median_filter(off.real, filterSize) vazm = ndimage.median_filter(off.imag, filterSize) @@ -100,6 +102,8 @@ def fill(data, invalid=None): Output: Return a filled array. """ + from scipy import ndimage + if invalid is None: invalid = np.isnan(data) ind = ndimage.distance_transform_edt(invalid, @@ -108,7 +112,9 @@ def fill(data, invalid=None): return data[tuple(ind)] def fill_with_smoothed(off,filterSize): - + + from astropy.convolution import convolve + off_2filt=np.copy(off) kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize) loop = 0 @@ -131,6 +137,8 @@ def fill_with_smoothed(off,filterSize): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName): #masking and Filtering + from scipy import ndimage + ##Read in the offset file ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) Offset = ds.GetRasterBand(band).ReadAsArray() @@ -236,6 +244,8 @@ def resampleOffset(maskedFiltOffset, geometryOffset, outName): def runRubbersheetRange(self): + from scipy import ndimage + if not self.doRubbersheetingRange: print('Rubber sheeting in azimuth not requested ... skipping') return From e2a81bbd6aca1b121e6612e07e21b17e37bab0f9 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Mon, 16 Dec 2019 10:22:01 -0800 Subject: [PATCH 7/7] Hide scipy imports for stripmapapp --- components/isceobj/StripmapProc/runDispersive.py | 3 ++- components/isceobj/TopsProc/runIon.py | 12 +++++++----- components/isceobj/TopsProc/runOffsetFilter.py | 3 ++- components/isceobj/TopsProc/runPrepESD.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/isceobj/StripmapProc/runDispersive.py b/components/isceobj/StripmapProc/runDispersive.py index 305022b..724c189 100644 --- a/components/isceobj/StripmapProc/runDispersive.py +++ b/components/isceobj/StripmapProc/runDispersive.py @@ -9,7 +9,6 @@ from isceobj.Constants import SPEED_OF_LIGHT import numpy as np import gdal -from scipy import ndimage try: import cv2 except ImportError: @@ -296,6 +295,8 @@ def fill(data, invalid=None): Output: Return a filled array. """ + from scipy import ndimage + if invalid is None: invalid = np.isnan(data) ind = ndimage.distance_transform_edt(invalid, diff --git a/components/isceobj/TopsProc/runIon.py b/components/isceobj/TopsProc/runIon.py index 8407287..d0c4af6 100644 --- a/components/isceobj/TopsProc/runIon.py +++ b/components/isceobj/TopsProc/runIon.py @@ -9,9 +9,6 @@ import shutil import datetime import numpy as np import numpy.matlib -import scipy.signal as ss -from scipy import interpolate -from scipy.interpolate import interp1d import isceobj import logging @@ -638,6 +635,7 @@ def cal_coherence(inf, win=5, edge=0): 4: keep all samples ''' + import scipy.signal as ss if win % 2 != 1: raise Exception('window size must be odd!') @@ -1682,6 +1680,9 @@ def computeDopplerOffset(burst, firstline, lastline, firstcolumn, lastcolumn, nr output: first lines > 0, last lines < 0 ''' + from scipy import interpolate + from scipy.interpolate import interp1d + Vs = np.linalg.norm(burst.orbit.interpolateOrbit(burst.sensingMid, method='hermite').getVelocity()) Ks = 2 * Vs * burst.azimuthSteeringRate / burst.radarWavelength @@ -1830,6 +1831,7 @@ def adaptive_gaussian(ionos, wgt, size_max, size_min): size_max: maximum window size size_min: minimum window size ''' + import scipy.signal as ss length = (ionos.shape)[0] width = (ionos.shape)[1] @@ -1892,6 +1894,8 @@ def filt_gaussian(self, ionParam): currently not implemented. a less accurate method is to use ionsphere without any projection ''' + from scipy import interpolate + from scipy.interpolate import interp1d ################################################# #SET PARAMETERS HERE @@ -2659,5 +2663,3 @@ def runIon(self): #esd_noion(self, ionParam) return - - \ No newline at end of file diff --git a/components/isceobj/TopsProc/runOffsetFilter.py b/components/isceobj/TopsProc/runOffsetFilter.py index 51735d9..e9989d9 100644 --- a/components/isceobj/TopsProc/runOffsetFilter.py +++ b/components/isceobj/TopsProc/runOffsetFilter.py @@ -3,7 +3,6 @@ # Copyright 2016 # -from scipy.ndimage.filters import median_filter import numpy as np import isce import isceobj @@ -20,6 +19,8 @@ def runOffsetFilter(self): if not self.doDenseOffsets: return + from scipy.ndimage.filters import median_filter + offsetfile = os.path.join(self._insar.mergedDirname, self._insar.offsetfile) snrfile = os.path.join(self._insar.mergedDirname, self._insar.snrfile) print('\n======================================') diff --git a/components/isceobj/TopsProc/runPrepESD.py b/components/isceobj/TopsProc/runPrepESD.py index 5d65b78..0cf9c3c 100755 --- a/components/isceobj/TopsProc/runPrepESD.py +++ b/components/isceobj/TopsProc/runPrepESD.py @@ -8,7 +8,6 @@ import numpy as np import os import isceobj import logging -import scipy.signal as SS from isceobj.Util.ImageUtil import ImageLib as IML import datetime import pprint @@ -177,6 +176,7 @@ def createCoherence(intfile, win=5): ''' Compute coherence using scipy convolve 2D. ''' + import scipy.signal as SS corfile = os.path.splitext(intfile)[0] + '.cor' filt = np.ones((win,win))/ (1.0*win*win)