Merge branch 'master' of https://github.com/isce-framework/isce2 into UAVSAR

LT1AB
Eric J. Fielding 2019-12-17 18:08:13 -08:00
commit baf2ae6e35
13 changed files with 113 additions and 105 deletions

View File

@ -216,43 +216,12 @@ else:
### End of GPU branch-specific modifications ### End of GPU branch-specific modifications
file = '__init__.py' env.Install(inst, '__init__.py')
if not os.path.exists(file): env.Install(inst, 'release_history.py')
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'
if not os.path.exists(inst): if not os.path.exists(inst):
os.makedirs(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 v = 0
if isrerun == 'no': if isrerun == 'no':
cmd = 'scons -Q install --isrerun=yes' cmd = 'scons -Q install --isrerun=yes'

View File

@ -25,13 +25,9 @@
# Author: Giangi Sacco # Author: Giangi Sacco
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from .release_history import release_version, release_svn_revision, release_date
svn_revision = release_svn_revision
version = release_history # compatibility alias
from __future__ import print_function
from .version import release_version, release_svn_revision, release_date
from .version import svn_revision
__version__ = release_version __version__ = release_version

View File

@ -9,7 +9,6 @@ from isceobj.Constants import SPEED_OF_LIGHT
import numpy as np import numpy as np
import gdal import gdal
from scipy import ndimage
try: try:
import cv2 import cv2
except ImportError: except ImportError:
@ -296,6 +295,8 @@ def fill(data, invalid=None):
Output: Output:
Return a filled array. Return a filled array.
""" """
from scipy import ndimage
if invalid is None: invalid = np.isnan(data) if invalid is None: invalid = np.isnan(data)
ind = ndimage.distance_transform_edt(invalid, ind = ndimage.distance_transform_edt(invalid,

View File

@ -75,6 +75,7 @@ def runResampleSlc(self, kind='coarse'):
if kind in ['coarse', 'refined']: if kind in ['coarse', 'refined']:
azname = os.path.join(offsetsDir, self.insar.azimuthOffsetFilename) azname = os.path.join(offsetsDir, self.insar.azimuthOffsetFilename)
rgname = os.path.join(offsetsDir, self.insar.rangeOffsetFilename) rgname = os.path.join(offsetsDir, self.insar.rangeOffsetFilename)
flatten = True
else: else:
azname = os.path.join(offsetsDir, self.insar.azimuthRubbersheetFilename) azname = os.path.join(offsetsDir, self.insar.azimuthRubbersheetFilename)
if self.doRubbersheetingRange: if self.doRubbersheetingRange:

View File

@ -6,7 +6,6 @@
import isce import isce
import isceobj import isceobj
from osgeo import gdal from osgeo import gdal
from scipy import ndimage
import numpy as np import numpy as np
import os import os
@ -24,6 +23,9 @@ def fill(data, invalid=None):
Output: Output:
Return a filled array. Return a filled array.
""" """
from scipy import ndimage
if invalid is None: invalid = np.isnan(data) if invalid is None: invalid = np.isnan(data)
ind = ndimage.distance_transform_edt(invalid, ind = ndimage.distance_transform_edt(invalid,
@ -35,6 +37,8 @@ def fill(data, invalid=None):
def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName):
#masking and Filtering #masking and Filtering
from scipy import ndimage
##Read in the offset file ##Read in the offset file
ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly)
Offset = ds.GetRasterBand(1).ReadAsArray() Offset = ds.GetRasterBand(1).ReadAsArray()

View File

@ -9,14 +9,14 @@
import isce import isce
import isceobj import isceobj
from osgeo import gdal from osgeo import gdal
from scipy import ndimage
from astropy.convolution import convolve
import numpy as np import numpy as np
import os import os
def mask_filterNoSNR(denseOffsetFile,filterSize,outName): def mask_filterNoSNR(denseOffsetFile,filterSize,outName):
# Masking the offsets with a data-based approach # Masking the offsets with a data-based approach
from scipy import ndimage
# Open the offsets # Open the offsets
ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly) ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly)
off_az = ds.GetRasterBand(1).ReadAsArray() off_az = ds.GetRasterBand(1).ReadAsArray()
@ -79,6 +79,9 @@ def mask_filterNoSNR(denseOffsetFile,filterSize,outName):
def off_masking(off,filterSize,thre=2): def off_masking(off,filterSize,thre=2):
from scipy import ndimage
# Define the mask to fill the offsets # Define the mask to fill the offsets
vram = ndimage.median_filter(off.real, filterSize) vram = ndimage.median_filter(off.real, filterSize)
vazm = ndimage.median_filter(off.imag, 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): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName):
#masking and Filtering #masking and Filtering
from scipy import ndimage
##Read in the offset file ##Read in the offset file
ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly)
Offset = ds.GetRasterBand(band).ReadAsArray() Offset = ds.GetRasterBand(band).ReadAsArray()
@ -154,7 +159,9 @@ def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outNam
return None return None
def fill_with_smoothed(off,filterSize): def fill_with_smoothed(off,filterSize):
from astropy.convolution import convolve
off_2filt=np.copy(off) off_2filt=np.copy(off)
kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize) kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize)
loop = 0 loop = 0

View File

@ -9,15 +9,14 @@
import isce import isce
import isceobj import isceobj
from osgeo import gdal from osgeo import gdal
from scipy import ndimage
import numpy as np import numpy as np
import os import os
from astropy.convolution import convolve
def mask_filterNoSNR(denseOffsetFile,filterSize,outName): def mask_filterNoSNR(denseOffsetFile,filterSize,outName):
# Masking the offsets with a data-based approach # Masking the offsets with a data-based approach
from scipy import ndimage
# Open the offsets # Open the offsets
ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly) ds = gdal.Open(denseOffsetFile+'.vrt',gdal.GA_ReadOnly)
off_az = ds.GetRasterBand(1).ReadAsArray() off_az = ds.GetRasterBand(1).ReadAsArray()
@ -78,6 +77,9 @@ def mask_filterNoSNR(denseOffsetFile,filterSize,outName):
return return
def off_masking(off,filterSize,thre=2): def off_masking(off,filterSize,thre=2):
from scipy import ndimage
vram = ndimage.median_filter(off.real, filterSize) vram = ndimage.median_filter(off.real, filterSize)
vazm = ndimage.median_filter(off.imag, filterSize) vazm = ndimage.median_filter(off.imag, filterSize)
@ -100,6 +102,8 @@ def fill(data, invalid=None):
Output: Output:
Return a filled array. Return a filled array.
""" """
from scipy import ndimage
if invalid is None: invalid = np.isnan(data) if invalid is None: invalid = np.isnan(data)
ind = ndimage.distance_transform_edt(invalid, ind = ndimage.distance_transform_edt(invalid,
@ -108,7 +112,9 @@ def fill(data, invalid=None):
return data[tuple(ind)] return data[tuple(ind)]
def fill_with_smoothed(off,filterSize): def fill_with_smoothed(off,filterSize):
from astropy.convolution import convolve
off_2filt=np.copy(off) off_2filt=np.copy(off)
kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize) kernel = np.ones((filterSize,filterSize),np.float32)/(filterSize*filterSize)
loop = 0 loop = 0
@ -131,6 +137,8 @@ def fill_with_smoothed(off,filterSize):
def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName): def mask_filter(denseOffsetFile, snrFile, band, snrThreshold, filterSize, outName):
#masking and Filtering #masking and Filtering
from scipy import ndimage
##Read in the offset file ##Read in the offset file
ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly) ds = gdal.Open(denseOffsetFile + '.vrt', gdal.GA_ReadOnly)
Offset = ds.GetRasterBand(band).ReadAsArray() Offset = ds.GetRasterBand(band).ReadAsArray()
@ -236,6 +244,8 @@ def resampleOffset(maskedFiltOffset, geometryOffset, outName):
def runRubbersheetRange(self): def runRubbersheetRange(self):
from scipy import ndimage
if not self.doRubbersheetingRange: if not self.doRubbersheetingRange:
print('Rubber sheeting in azimuth not requested ... skipping') print('Rubber sheeting in azimuth not requested ... skipping')
return return

View File

@ -9,9 +9,6 @@ import shutil
import datetime import datetime
import numpy as np import numpy as np
import numpy.matlib import numpy.matlib
import scipy.signal as ss
from scipy import interpolate
from scipy.interpolate import interp1d
import isceobj import isceobj
import logging import logging
@ -638,6 +635,7 @@ def cal_coherence(inf, win=5, edge=0):
4: keep all samples 4: keep all samples
''' '''
import scipy.signal as ss
if win % 2 != 1: if win % 2 != 1:
raise Exception('window size must be odd!') 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 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()) Vs = np.linalg.norm(burst.orbit.interpolateOrbit(burst.sensingMid, method='hermite').getVelocity())
Ks = 2 * Vs * burst.azimuthSteeringRate / burst.radarWavelength 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_max: maximum window size
size_min: minimum window size size_min: minimum window size
''' '''
import scipy.signal as ss
length = (ionos.shape)[0] length = (ionos.shape)[0]
width = (ionos.shape)[1] width = (ionos.shape)[1]
@ -1892,6 +1894,8 @@ def filt_gaussian(self, ionParam):
currently not implemented. currently not implemented.
a less accurate method is to use ionsphere without any projection a less accurate method is to use ionsphere without any projection
''' '''
from scipy import interpolate
from scipy.interpolate import interp1d
################################################# #################################################
#SET PARAMETERS HERE #SET PARAMETERS HERE
@ -2659,5 +2663,3 @@ def runIon(self):
#esd_noion(self, ionParam) #esd_noion(self, ionParam)
return return

View File

@ -3,7 +3,6 @@
# Copyright 2016 # Copyright 2016
# #
from scipy.ndimage.filters import median_filter
import numpy as np import numpy as np
import isce import isce
import isceobj import isceobj
@ -20,6 +19,8 @@ def runOffsetFilter(self):
if not self.doDenseOffsets: if not self.doDenseOffsets:
return return
from scipy.ndimage.filters import median_filter
offsetfile = os.path.join(self._insar.mergedDirname, self._insar.offsetfile) offsetfile = os.path.join(self._insar.mergedDirname, self._insar.offsetfile)
snrfile = os.path.join(self._insar.mergedDirname, self._insar.snrfile) snrfile = os.path.join(self._insar.mergedDirname, self._insar.snrfile)
print('\n======================================') print('\n======================================')

View File

@ -8,7 +8,6 @@ import numpy as np
import os import os
import isceobj import isceobj
import logging import logging
import scipy.signal as SS
from isceobj.Util.ImageUtil import ImageLib as IML from isceobj.Util.ImageUtil import ImageLib as IML
import datetime import datetime
import pprint import pprint
@ -177,6 +176,7 @@ def createCoherence(intfile, win=5):
''' '''
Compute coherence using scipy convolve 2D. Compute coherence using scipy convolve 2D.
''' '''
import scipy.signal as SS
corfile = os.path.splitext(intfile)[0] + '.cor' corfile = os.path.splitext(intfile)[0] + '.cor'
filt = np.ones((win,win))/ (1.0*win*win) filt = np.ones((win,win))/ (1.0*win*win)

View File

@ -197,6 +197,8 @@ class config(object):
self.f.write('nomcf : ' + self.noMCF + '\n') self.f.write('nomcf : ' + self.noMCF + '\n')
self.f.write('master : ' + self.master + '\n') self.f.write('master : ' + self.master + '\n')
self.f.write('defomax : ' + self.defoMax + '\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('method : ' + self.unwMethod + '\n')
self.f.write('##########################'+'\n') self.f.write('##########################'+'\n')

View File

@ -113,9 +113,19 @@ def extractInfoFromPickle(pckfile, inps):
data['earthRadius'] = elp.local_radius_of_curvature(llh.lat, hdg) data['earthRadius'] = elp.local_radius_of_curvature(llh.lat, hdg)
#azspacing = burst.azimuthTimeInterval * sv.getScalarVelocity() #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 * azspacing / azres
data['corrlooks'] = inps.rglooks * inps.azlooks / (azfact * rgfact)
data['rglooks'] = inps.rglooks data['rglooks'] = inps.rglooks
data['azlooks'] = inps.azlooks data['azlooks'] = inps.azlooks
@ -149,7 +159,7 @@ def runUnwrap(infile, outfile, corfile, config, costMode = None,initMethod = Non
altitude = config['altitude'] altitude = config['altitude']
rangeLooks = config['rglooks'] rangeLooks = config['rglooks']
azimuthLooks = config['azlooks'] azimuthLooks = config['azlooks']
#corrLooks = config['corrlooks'] corrLooks = config['corrlooks']
maxComponents = 20 maxComponents = 20
snp = Snaphu() snp = Snaphu()
@ -163,7 +173,7 @@ def runUnwrap(infile, outfile, corfile, config, costMode = None,initMethod = Non
snp.setAltitude(altitude) snp.setAltitude(altitude)
snp.setCorrfile(corfile) snp.setCorrfile(corfile)
snp.setInitMethod(initMethod) snp.setInitMethod(initMethod)
# snp.setCorrLooks(corrLooks) snp.setCorrLooks(corrLooks)
snp.setMaxComponents(maxComponents) snp.setMaxComponents(maxComponents)
snp.setDefoMaxCycles(defomax) snp.setDefoMaxCycles(defomax)
snp.setRangeLooks(rangeLooks) snp.setRangeLooks(rangeLooks)
@ -248,33 +258,34 @@ def runUnwrapIcu(infile, outfile):
unwImage.finalizeImage() unwImage.finalizeImage()
unwImage.renderHdr() 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: if unwrapper_2stage_name is None:
unwrapper_2stage_name = 'REDARC0' unwrapper_2stage_name = 'REDARC0'
if solver_2stage is None: if solver_2stage is None:
# If unwrapper_2state_name is MCF then solver is ignored # If unwrapper_2state_name is MCF then solver is ignored
# and relaxIV MCF solver is used by default # and relaxIV MCF solver is used by default
solver_2stage = 'pulp' solver_2stage = 'pulp'
print('Unwrap 2 Stage Settings:') print('Unwrap 2 Stage Settings:')
print('Name: %s'%unwrapper_2stage_name) print('Name: %s'%unwrapper_2stage_name)
print('Solver: %s'%solver_2stage) print('Solver: %s'%solver_2stage)
inpFile = unwrappedIntFilename inpFile = unwrappedIntFilename
ccFile = connectedComponentsFilename ccFile = connectedComponentsFilename
outFile = unwrapped2StageFilename outFile = unwrapped2StageFilename
# Hand over to 2Stage unwrap # Hand over to 2Stage unwrap
unw = UnwrapComponents() unw = UnwrapComponents()
unw.setInpFile(inpFile) unw.setInpFile(inpFile)
unw.setConnCompFile(ccFile) unw.setConnCompFile(ccFile)
unw.setOutFile(outFile) unw.setOutFile(outFile)
unw.setSolver(solver_2stage) unw.setSolver(solver_2stage)
unw.setRedArcs(unwrapper_2stage_name) unw.setRedArcs(unwrapper_2stage_name)
unw.unwrapComponents() unw.unwrapComponents()
return return
def main(iargs=None): def main(iargs=None):
@ -293,24 +304,26 @@ def main(iargs=None):
if inps.method != 'icu': if inps.method != 'icu':
masterShelveDir = os.path.join(interferogramDir , 'masterShelve') masterShelveDir = os.path.join(interferogramDir , 'masterShelve')
if not os.path.exists(masterShelveDir): if not os.path.exists(masterShelveDir):
os.makedirs(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) print ('unwrapping method : ' , inps.method)
if inps.method == 'snaphu': if inps.method == 'snaphu':
if inps.nomcf: if inps.nomcf:
fncall = runUnwrap fncall = runUnwrap
else: else:
fncall = runUnwrapMcf fncall = runUnwrapMcf
fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax) fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax)
elif inps.method == 'snaphu2stage': elif inps.method == 'snaphu2stage':
if inps.nomcf: if inps.nomcf:
fncall = runUnwrap fncall = runUnwrap
@ -319,11 +332,12 @@ def main(iargs=None):
fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax) fncall(inps.intfile, inps.unwprefix + '_snaphu.unw', inps.cohfile, metadata, defomax=inps.defomax)
# adding in the two-stage # 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': elif inps.method == 'icu':
runUnwrapIcu(inps.intfile, inps.unwprefix + '_icu.unw') runUnwrapIcu(inps.intfile, inps.unwprefix + '_icu.unw')
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -12,7 +12,8 @@
<value>/Users/fattahi/process/test_roiApp/Alos_Maule_T116/demLat_S39_S35_Lon_W074_W071.dem.wgs84</value> <value>/Users/fattahi/process/test_roiApp/Alos_Maule_T116/demLat_S39_S35_Lon_W074_W071.dem.wgs84</value>
</property> </property>
<!-- <!--
<property name="do rubbersheeting">True</property> <property name="do rubbersheetingAzimuth">True</property>
<property name="do rubbersheetingRange">False</property>
--> -->
<property name="do denseoffsets">True</property> <property name="do denseoffsets">True</property>
<property name="do split spectrum">True</property> <property name="do split spectrum">True</property>