From 6a78c4e6d64e65ab4949817cbb15e9fd1d513ba3 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Tue, 28 Apr 2020 16:21:26 -0700 Subject: [PATCH] skip filtering if --filter_strength <= 0 + FilterAndCoherence: skip filtering if input filter strength <= 0 and use original phase for coherence estimation + Stack: do not add filt_ prefix to output file if input filter strength <= 0 --- contrib/stack/stripmapStack/FilterAndCoherence.py | 12 +++++++++--- contrib/stack/stripmapStack/Stack.py | 11 ++++++++--- contrib/stack/stripmapStack/stackStripMap.py | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/contrib/stack/stripmapStack/FilterAndCoherence.py b/contrib/stack/stripmapStack/FilterAndCoherence.py index 948afc4..6c86b7d 100755 --- a/contrib/stack/stripmapStack/FilterAndCoherence.py +++ b/contrib/stack/stripmapStack/FilterAndCoherence.py @@ -28,7 +28,6 @@ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - import logging import isce import isceobj @@ -36,6 +35,7 @@ import argparse import os logger = logging.getLogger('isce.tops.runFilter') + def runFilter(infile, outfile, filterStrength): from mroipac.filter.Filter import Filter logger.info("Applying power-spectral filter") @@ -61,10 +61,11 @@ def runFilter(infile, outfile, filterStrength): intImage.finalizeImage() filtImage.finalizeImage() - + def estCoherence(outfile, corfile): from mroipac.icu.Icu import Icu + logger.info("Estimating spatial coherence based phase sigma") #Create phase sigma correlation file here filtImage = isceobj.createIntImage() @@ -110,6 +111,7 @@ def createParser(): return parser + def cmdLineParse(iargs=None): parser = createParser() return parser.parse_args(args=iargs) @@ -121,7 +123,11 @@ def main(iargs=None): if inps.filtfile is None: inps.filtfile = 'filt_' + inps.infile - runFilter(inps.infile, inps.filtfile, inps.filterstrength) + if inps.filterstrength <= 0.: + inps.filtfile = inps.infile + logger.info('input filter strength "{}" <= 0, skip filtering.'.format(inps.filterstrength)) + else: + runFilter(inps.infile, inps.filtfile, inps.filterstrength) estCoherence(inps.filtfile, inps.cohfile) diff --git a/contrib/stack/stripmapStack/Stack.py b/contrib/stack/stripmapStack/Stack.py index 8a8af7d..51b6ae4 100755 --- a/contrib/stack/stripmapStack/Stack.py +++ b/contrib/stack/stripmapStack/Stack.py @@ -614,10 +614,15 @@ class run(object): pair[0] + '_' + pair[1]) configObj.generateIgram('[Function-1]') + configObj.igram = configObj.outDir+'.int' - configObj.filtIgram = os.path.dirname(configObj.outDir) + '/filt_' + pair[0] + '_' + pair[1] + '.int' - configObj.coherence = os.path.dirname(configObj.outDir) + '/filt_' + pair[0] + '_' + pair[1] + '.cor' - #configObj.filtStrength = filtStrength + if float(configObj.filtStrength) > 0.: + configObj.filtIgram = os.path.dirname(configObj.outDir) + '/filt_' + pair[0] + '_' + pair[1] + '.int' + configObj.coherence = os.path.dirname(configObj.outDir) + '/filt_' + pair[0] + '_' + pair[1] + '.cor' + else: + # do not add prefix filt_ to output file if no filtering is applied. + configObj.filtIgram = os.path.dirname(configObj.outDir) + '/' + pair[0] + '_' + pair[1] + '.int' + configObj.coherence = os.path.dirname(configObj.outDir) + '/' + pair[0] + '_' + pair[1] + '.cor' configObj.filterCoherence('[Function-2]') # skip phase unwrapping if input method == no diff --git a/contrib/stack/stripmapStack/stackStripMap.py b/contrib/stack/stripmapStack/stackStripMap.py index 132351c..f25158d 100755 --- a/contrib/stack/stripmapStack/stackStripMap.py +++ b/contrib/stack/stripmapStack/stackStripMap.py @@ -58,11 +58,11 @@ def createParser(): help='SAR sensor used to define square multi-look pixels') parser.add_argument('-u', '--unw_method', dest='unwMethod', type=str, default='snaphu', - help='unwrapping method (icu, snaphu, or snaphu2stage)') + help='unwrapping method (icu, snaphu, or snaphu2stage), no to skip phase unwrapping.') parser.add_argument('-f','--filter_strength', dest='filtStrength', type=str, default=filtStrength, help='strength of Goldstein filter applied to the wrapped phase before spatial coherence estimation.' - ' Default: {}'.format(filtStrength)) + ' Default: {}. 0 to skip filtering.'.format(filtStrength)) iono = parser.add_argument_group('Ionosphere', 'Configurationas for ionospheric correction') iono.add_argument('-L', '--low_band_frequency', dest='fL', type=str, default=None,