Merge pull request #323 from yunjunz/tops_stack

stackSentinel: expose virtual merge via -V / --virtual_merge option
LT1AB
Ryan Burns 2021-08-16 15:59:37 -07:00 committed by GitHub
commit d63c40a30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 100 additions and 88 deletions

View File

@ -37,7 +37,7 @@ The following calibration auxliary (AUX_CAL) file is used for **antenna pattern
Run the command below to download the AUX_CAL file once and store it somewhere (_i.e._ ~/aux/aux_cal) so that you can use it all the time, for `stackSentinel.py -a` or `auxiliary data directory` in `topsApp.py`. Run the command below to download the AUX_CAL file once and store it somewhere (_i.e._ ~/aux/aux_cal) so that you can use it all the time, for `stackSentinel.py -a` or `auxiliary data directory` in `topsApp.py`.
``` ```
wget https://aux.sentinel1.eo.esa.int/AUX_CAL/2014/09/08/S1A_AUX_CAL_V20140908T000000_G20190626T100201.SAFE/ --no-check-certificate --recursive --level=1 --cut-dirs=4 -nH wget https://qc.sentinel1.groupcls.com/product/S1A/AUX_CAL/2014/09/08/S1A_AUX_CAL_V20140908T000000_G20190626T100201.SAFE.TGZ
``` ```
#### 1. Create your project folder somewhere #### #### 1. Create your project folder somewhere ####
@ -53,7 +53,7 @@ Download of DEM (need to use wgs84 version) using the ISCE DEM download script.
``` ```
mkdir DEM; cd DEM mkdir DEM; cd DEM
dem.py -a stitch -b 18 20 -100 -97 -r -s 1 c dem.py -a stitch -b 18 20 -100 -97 -r -s 1 -c
rm demLat*.dem demLat*.dem.xml demLat*.dem.vrt rm demLat*.dem demLat*.dem.xml demLat*.dem.vrt
cd .. cd ..
``` ```

View File

@ -5,17 +5,18 @@
# Heresh Fattahi, updated for stack processing # Heresh Fattahi, updated for stack processing
import numpy as np
import os import os
import isce import glob
import isceobj
import datetime import datetime
import logging import logging
import argparse import argparse
import numpy as np
import isce
import isceobj
from isceobj.Util.ImageUtil import ImageLib as IML from isceobj.Util.ImageUtil import ImageLib as IML
from isceobj.Util.decorators import use_api from isceobj.Util.decorators import use_api
import s1a_isce_utils as ut import s1a_isce_utils as ut
import glob
def createParser(): def createParser():
@ -39,20 +40,19 @@ def createParser():
parser.add_argument('-m', '--method', type=str, dest='method', default='avg', parser.add_argument('-m', '--method', type=str, dest='method', default='avg',
help='Method: top / bot/ avg') help='Method: top / bot/ avg')
parser.add_argument('-a', '--aligned', action='store_true', dest='isaligned', parser.add_argument('-a', '--aligned', action='store_true', dest='isaligned', default=False,
default=False, help='Use reference information instead of coreg for merged grid.') help='Use reference information instead of coreg for merged grid.')
parser.add_argument('-l', '--multilook', action='store_true', dest='multilook', default=False, parser.add_argument('-l', '--multilook', action='store_true', dest='multilook', default=False,
help='Multilook the merged products. True or False') help='Multilook the merged products. True or False')
parser.add_argument('-A', '--azimuth_looks', type=str, dest='numberAzimuthLooks', default=3, parser.add_argument('-A', '--azimuth_looks', type=str, dest='numberAzimuthLooks', default=3, help='azimuth looks')
help = 'azimuth looks')
parser.add_argument('-R', '--range_looks', type=str, dest='numberRangeLooks', default=9, parser.add_argument('-R', '--range_looks', type=str, dest='numberRangeLooks', default=9, help='range looks')
help = 'range looks')
parser.add_argument('-n', '--name_pattern', type=str, dest='namePattern', default='fine*int', parser.add_argument('-n', '--name_pattern', type=str, dest='namePattern', default='fine*int',
help = 'a name pattern of burst products that will be merged. default: fine. it can be lat, lon, los, burst, hgt, shadowMask, incLocal') help='a name pattern of burst products that will be merged. '
'default: fine. it can be lat, lon, los, burst, hgt, shadowMask, incLocal')
parser.add_argument('-v', '--valid_only', action='store_true', dest='validOnly', default=False, parser.add_argument('-v', '--valid_only', action='store_true', dest='validOnly', default=False,
help='True for SLC, int and coherence. False for geometry files (lat, lon, los, hgt, shadowMask, incLocal).') help='True for SLC, int and coherence. False for geometry files (lat, lon, los, hgt, shadowMask, incLocal).')
@ -339,9 +339,6 @@ def multilook(infile, outname=None, alks=5, rlks=15, multilook_tool="isce", no_d
#def runMergeBursts(self):
def main(iargs=None): def main(iargs=None):
''' '''
Merge burst products to make it look like stripmap. Merge burst products to make it look like stripmap.
@ -391,7 +388,8 @@ def main(iargs=None):
frames.append(ifg) frames.append(ifg)
referenceFrames.append(reference) referenceFrames.append(reference)
print('bursts: ', minBurst, maxBurst) print('bursts: ', minBurst, maxBurst)
fileList.append([os.path.join(inps.dirname, 'IW{0}'.format(swath), namePattern[0] + '_%02d.%s'%(x,namePattern[1])) for x in range(minBurst, maxBurst+1)]) fileList.append([os.path.join(inps.dirname, 'IW{0}'.format(swath), namePattern[0] + '_%02d.%s'%(x,namePattern[1]))
for x in range(minBurst, maxBurst+1)])
mergedir = os.path.dirname(inps.outfile) mergedir = os.path.dirname(inps.outfile)
os.makedirs(mergedir, exist_ok=True) os.makedirs(mergedir, exist_ok=True)
@ -399,10 +397,7 @@ def main(iargs=None):
suffix = '.full' suffix = '.full'
if (inps.numberRangeLooks == 1) and (inps.numberAzimuthLooks==1): if (inps.numberRangeLooks == 1) and (inps.numberAzimuthLooks==1):
suffix='' suffix=''
####Virtual flag is ignored for multi-swath data ####Virtual flag is ignored for multi-swath data
if (not virtual): if (not virtual):
print('User requested for multi-swath stitching.') print('User requested for multi-swath stitching.')
print('Virtual files are the only option for this.') print('Virtual files are the only option for this.')
@ -417,10 +412,12 @@ def main(iargs=None):
print(inps.multilook) print(inps.multilook)
if inps.multilook: if inps.multilook:
multilook(inps.outfile+suffix, outname = inps.outfile, multilook(inps.outfile+suffix,
alks = inps.numberAzimuthLooks, rlks=inps.numberRangeLooks, outname=inps.outfile,
multilook_tool=inps.multilookTool, no_data=inps.noData) alks=inps.numberAzimuthLooks,
rlks=inps.numberRangeLooks,
multilook_tool=inps.multilookTool,
no_data=inps.noData)
else: else:
print('Skipping multi-looking ....') print('Skipping multi-looking ....')
@ -428,5 +425,4 @@ if __name__ == '__main__' :
''' '''
Merge products burst-by-burst. Merge products burst-by-burst.
''' '''
main() main()

View File

@ -32,10 +32,10 @@ def saveProduct( obj, xmlname):
''' '''
Save the product to an XML file using Product Manager. Save the product to an XML file using Product Manager.
''' '''
# import shelve import shelve
# import os import os
# with shelve.open(os.path.dirname(xmlname) + '/'+ os.path.basename(xmlname) +'.data') as db: with shelve.open(os.path.dirname(xmlname) + '/'+ os.path.basename(xmlname) +'.data') as db:
# db['data'] = obj db['data'] = obj
from iscesys.Component.ProductManager import ProductManager as PM from iscesys.Component.ProductManager import ProductManager as PM
@ -46,6 +46,7 @@ def saveProduct( obj, xmlname):
return None return None
def getRelativeShifts(mFrame, sFrame, minBurst, maxBurst, secondaryBurstStart): def getRelativeShifts(mFrame, sFrame, minBurst, maxBurst, secondaryBurstStart):
''' '''
Estimate the relative shifts between the start of the bursts. Estimate the relative shifts between the start of the bursts.
@ -177,6 +178,7 @@ def adjustValidSampleLine_V2(reference, secondary, minAz=0, maxAz=0, minRng=0, m
return reference return reference
def adjustCommonValidRegion(reference,secondary): def adjustCommonValidRegion(reference,secondary):
# valid lines between reference and secondary # valid lines between reference and secondary
@ -264,6 +266,7 @@ def asBaseClass(inobj):
else: else:
raise Exception('Cannot be converted to TOPSSwathSLCProduct') raise Exception('Cannot be converted to TOPSSwathSLCProduct')
def getSwathList(indir): def getSwathList(indir):
swathList = [] swathList = []

View File

@ -160,9 +160,15 @@ def createParser():
parser.add_argument('-e', '--esd_coherence_threshold', dest='esdCoherenceThreshold', type=str, default='0.85', parser.add_argument('-e', '--esd_coherence_threshold', dest='esdCoherenceThreshold', type=str, default='0.85',
help='Coherence threshold for estimating azimuth misregistration using enhanced spectral diversity (default: %(default)s).') help='Coherence threshold for estimating azimuth misregistration using enhanced spectral diversity (default: %(default)s).')
parser.add_argument('-W', '--workflow', dest='workflow', type=str, default='interferogram', choices=['slc', 'correlation', 'interferogram', 'offset'], parser.add_argument('-W', '--workflow', dest='workflow', type=str, default='interferogram',
choices=['slc', 'correlation', 'interferogram', 'offset'],
help='The InSAR processing workflow (default: %(default)s).') help='The InSAR processing workflow (default: %(default)s).')
parser.add_argument('-V', '--virtual_merge', dest='virtualMerge', type=str, default=None, choices=['True', 'False'],
help='Use virtual files for the merged SLCs and geometry files.\n'
'Default: True for correlation / interferogram workflow\n'
' False for slc / offset workflow')
parser.add_argument('-useGPU', '--useGPU', dest='useGPU',action='store_true', default=False, parser.add_argument('-useGPU', '--useGPU', dest='useGPU',action='store_true', default=False,
help='Allow App to use GPU when available') help='Allow App to use GPU when available')
@ -531,15 +537,16 @@ def slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_di
def correlationStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, pairs, updateStack): def correlationStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, pairs, updateStack):
#############################
i = slcStack(inps, acquisitionDates,stackReferenceDate, secondaryDates, safe_dict, updateStack) i = slcStack(inps, acquisitionDates,stackReferenceDate, secondaryDates, safe_dict, updateStack)
# default value of virtual_merge
virtual_merge = 'True' if not inps.virtualMerge else inps.virtualMerge
i+=1 i+=1
runObj = run() runObj = run()
runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i)) runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i))
runObj.mergeReference(stackReferenceDate, virtual = 'True') runObj.mergeReference(stackReferenceDate, virtual = virtual_merge)
runObj.mergeSecondarySLC(secondaryDates, virtual = 'True') runObj.mergeSecondarySLC(secondaryDates, virtual = virtual_merge)
runObj.finalize() runObj.finalize()
i+=1 i+=1
@ -559,11 +566,14 @@ def interferogramStack(inps, acquisitionDates, stackReferenceDate, secondaryDate
i = slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, updateStack) i = slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, updateStack)
# default value of virtual_merge
virtual_merge = 'True' if not inps.virtualMerge else inps.virtualMerge
i+=1 i+=1
runObj = run() runObj = run()
runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i)) runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i))
runObj.mergeReference(stackReferenceDate, virtual = 'True') runObj.mergeReference(stackReferenceDate, virtual = virtual_merge)
runObj.mergeSecondarySLC(secondaryDates, virtual = 'True') runObj.mergeSecondarySLC(secondaryDates, virtual = virtual_merge)
runObj.finalize() runObj.finalize()
i+=1 i+=1
@ -595,11 +605,14 @@ def offsetStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe
i = slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, updateStack) i = slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_dict, updateStack)
# default value of virtual_merge
virtual_merge = 'False' if not inps.virtualMerge else inps.virtualMerge
i+=1 i+=1
runObj = run() runObj = run()
runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i)) runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i))
runObj.mergeReference(stackReferenceDate, virtual = 'False') runObj.mergeReference(stackReferenceDate, virtual = virtual_merge)
runObj.mergeSecondarySLC(secondaryDates, virtual = 'False') runObj.mergeSecondarySLC(secondaryDates, virtual = virtual_merge)
runObj.finalize() runObj.finalize()
i+=1 i+=1