topsStack: ignore coreg_secondary images with inconsistent num of bursts (#195)

* ImageLib: fix str syntax

* stackSentl: rename slc workflow merge for consistency

rename the mergeSLC step in "slc" workflow, to be consistent with the other workflows.

* topsStack: check inconsistent num of bursts in secondary images

+ extractCommonValidRegion.py: add dropSecondarysWithDifferentNumberOfBursts() to discard those acquisitions during the common region calculation

+ mergeBursts.py: skip secondarys with inconsistent num of bursts by raise exception and exit

+ s1a_isce_utils.adjustValidSampleLine_V2(): remove a redundant line

Co-authored-by: Zhang Yunjun <yunjunz@users.noreply.github.com>
LT1AB
Zhang Yunjun 2020-10-24 09:31:48 -07:00 committed by GitHub
parent 3fb325a51e
commit 55b9d2c037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 5 deletions

View File

@ -262,7 +262,7 @@ class memmap(object):
nyy = nbytes//(fsize*nchannels*nxx)
if (nxx*nyy*fsize*nchannels) != nbytes:
raise ValueError('File size mismatch for %s. Fractional number of lines'(fname))
raise ValueError('File size mismatch for %s. Fractional number of lines'%(fname))
elif (nxx*nyy*fsize*nchannels) > nbytes:
raise ValueError('File size mismatch for %s. Number of bytes expected: %d'%(nbytes))

View File

@ -39,6 +39,7 @@ def updateValidRegion(topReference, secondaryPath, swath):
####Load relevant products
#topReference = ut.loadProduct(os.path.join(inps.reference , 'IW{0}.xml'.format(swath)))
print(secondaryPath)
topCoreg = ut.loadProduct(os.path.join(secondaryPath , 'IW{0}.xml'.format(swath)))
topIfg = ut.coregSwathSLCProduct()
@ -67,6 +68,34 @@ def updateValidRegion(topReference, secondaryPath, swath):
return topReference
def dropSecondarysWithDifferentNumberOfBursts(secondaryList, reference, swathList):
'''Drop secondary acquisitions that have different number of bursts
than the reference acquisition.
'''
print('checking the number of bursts in coreg_secondarys against the one in reference')
secondaryList2Drop = []
for swath in swathList:
prodReference = ut.loadProduct(os.path.join(reference, 'IW{0}.xml'.format(swath)))
numBursts = len(prodReference.bursts)
for secondary in secondaryList:
prodSecondary = ut.loadProduct(os.path.join(secondary, 'IW{0}.xml'.format(swath)))
if len(prodSecondary.bursts) != numBursts:
msg = 'WARNING: {} has different number of bursts ({}) than the reference {} ({}) for swath {}'.format(
os.path.basename(secondary), len(prodSecondary.bursts),
os.path.basename(reference), numBursts, swath)
msg += ' --> exclude it for common region calculation'
print(msg)
secondaryList2Drop.append(secondary)
secondaryList2Drop = list(sorted(set(secondaryList2Drop)))
if len(secondaryList2Drop) == 0:
print('all secondary images have the same number of bursts as the reference')
secondaryList = list(sorted(set(secondaryList) - set(secondaryList2Drop)))
return secondaryList
def main(iargs=None):
'''extract common valid overlap region for the stack.
@ -88,6 +117,8 @@ def main(iargs=None):
secondaryList = glob.glob(os.path.join(inps.secondary,'2*'))
secondarySwathList = ut.getSwathList(secondaryList[0]) # assuming all secondarys have the same swaths
swathList = list(sorted(set(referenceSwathList+secondarySwathList)))
# discard secondarys with different number of bursts than the reference
secondaryList = dropSecondarysWithDifferentNumberOfBursts(secondaryList, inps.reference, swathList)
for swath in swathList:
print('******************')

View File

@ -362,6 +362,12 @@ def main(iargs=None):
stack = ut.loadProduct(os.path.join(inps.stack , 'IW{0}.xml'.format(swath)))
if inps.isaligned:
reference = ifg.reference
# checking inconsistent number of bursts in the secondary acquisitions
if reference.numberOfBursts != ifg.numberOfBursts:
raise ValueError('{} has different number of bursts ({}) than the reference ({})'.format(
inps.reference, ifg.numberOfBursts, reference.numberOfBursts))
else:
reference = ifg
@ -376,9 +382,7 @@ def main(iargs=None):
if inps.stack:
minStack = stack.bursts[0].burstNumber
print('Updating the valid region of each burst to the common valid region of the stack')
####Updating the valid region of each burst to the common valid region of the stack
for ii in range(minBurst, maxBurst + 1):
ifg.bursts[ii-minBurst].firstValidLine = stack.bursts[ii-minStack].firstValidLine
ifg.bursts[ii-minBurst].firstValidSample = stack.bursts[ii-minStack].firstValidSample
ifg.bursts[ii-minBurst].numValidLines = stack.bursts[ii-minStack].numValidLines

View File

@ -161,7 +161,6 @@ def adjustValidSampleLine_V2(reference, secondary, minAz=0, maxAz=0, minRng=0, m
elif (minAz < 0) and (maxAz < 0):
reference.firstValidLine = secondary.firstValidLine - int(np.floor(minAz) - 4)
lastValidLine = reference.firstValidLine + secondary.numValidLines + int(np.floor(minAz) - 8)
lastValidLine = reference.firstValidLine + secondary.numValidLines - 8
if lastValidLine < reference.numberOfLines:
reference.numValidLines = secondary.numValidLines - 8

View File

@ -523,7 +523,7 @@ def slcStack(inps, acquisitionDates, stackReferenceDate, secondaryDates, safe_di
if mergeSLC:
i+=1
runObj = run()
runObj.configure(inps, 'run_{:02d}_merge'.format(i))
runObj.configure(inps, 'run_{:02d}_merge_reference_secondary_slc'.format(i))
runObj.mergeReference(stackReferenceDate, virtual = 'False')
runObj.mergeSecondarySLC(secondaryDates, virtual = 'False')
runObj.finalize()