Merge pull request #82 from rtburns-jpl/hide-imports

Hide rubbersheeting scipy/astropy imports
LT1AB
piyushrpt 2019-12-16 21:12:55 -08:00 committed by GitHub
commit db8930151f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 18 deletions

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

@ -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)