Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tidy based on PR feedback
  • Loading branch information
hardreddata committed Jul 22, 2022
commit d4b1f99ef0f5cc97e7be93248517f69e2606d4b9
43 changes: 21 additions & 22 deletions contrib/stack/topsStack/Stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,19 @@ def denseOffset(self, function):
#self.f.write('ww : 256\n')
#self.f.write('wh : 128\n')

def write_wrapper_config2run_file(self, configName, line_cnt, last_line = False, numProcess = 1):
def write_wrapper_config2run_file(self, configName, line_cnt = 1, last_line = False, numProcess = 1):
# dispassionate list of commands for single process
if numProcess == 1:
self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + '\n')
# aggregate background commands between wait blocks for speed gains
elif numProcess > 1:
self.runf.write(self.text_cmd + 'SentinelWrapper.py -c ' + configName + ' &\n')
if line_cnt == numProcess:
if line_cnt % numProcess == 0:
self.runf.write('wait\n\n')
line_cnt = 0
# last line of file, wait for any background processes to complete
if last_line:
self.runf.write('wait\n')
return line_cnt

def finalize(self):
self.f.close()
Expand Down Expand Up @@ -320,7 +319,7 @@ def unpackSLC(self, acquisitionDates, safe_dict):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj

def unpackStackReferenceSLC(self, safe_dict):
Expand All @@ -341,7 +340,7 @@ def unpackStackReferenceSLC(self, safe_dict):
configObj.finalize()

line_cnt = 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj

def unpackSecondarysSLC(self, stackReferenceDate, secondaryList, safe_dict):
Expand All @@ -361,7 +360,7 @@ def unpackSecondarysSLC(self, stackReferenceDate, secondaryList, safe_dict):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
del configObj

def averageBaseline(self, stackReferenceDate, secondaryList):
Expand All @@ -378,7 +377,7 @@ def averageBaseline(self, stackReferenceDate, secondaryList):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
del configObj

def gridBaseline(self, stackReferenceDate, secondaryList):
Expand All @@ -395,7 +394,7 @@ def gridBaseline(self, stackReferenceDate, secondaryList):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj
# also add the reference in itself to be consistent with the SLC dir
configName = os.path.join(self.config_path,'config_baselinegrid_reference')
Expand All @@ -408,7 +407,7 @@ def gridBaseline(self, stackReferenceDate, secondaryList):
configObj.finalize()

line_cnt = 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj


Expand Down Expand Up @@ -443,7 +442,7 @@ def geo2rdr_offset(self, secondaryList, fullBurst='False'):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
del configObj

def resample_with_carrier(self, secondaryList, fullBurst='False'):
Expand Down Expand Up @@ -473,7 +472,7 @@ def resample_with_carrier(self, secondaryList, fullBurst='False'):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, secondary == secondaryList[-1], self.numProcess)
del configObj


Expand Down Expand Up @@ -524,7 +523,7 @@ def pairs_misregistration(self, dateList, safe_dict):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
del configObj
########################

Expand Down Expand Up @@ -563,7 +562,7 @@ def generate_burstIgram(self, dateList, safe_dict, pairs):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
del configObj


Expand Down Expand Up @@ -597,7 +596,7 @@ def igram_mergeBurst(self, dateList, safe_dict, pairs):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
del configObj

def mergeSecondarySLC(self, secondaryList, virtual='True'):
Expand All @@ -622,7 +621,7 @@ def mergeSecondarySLC(self, secondaryList, virtual='True'):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj


Expand All @@ -645,7 +644,7 @@ def mergeReference(self, stackReference, virtual='True'):
configObj.finalize()

line_cnt = 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj

geometryList = ['lat*rdr', 'lon*rdr', 'los*rdr', 'hgt*rdr', 'shadowMask*rdr','incLocal*rdr']
Expand Down Expand Up @@ -673,7 +672,7 @@ def mergeReference(self, stackReference, virtual='True'):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj

def mergeSLC(self, aquisitionDates, virtual='True'):
Expand All @@ -697,7 +696,7 @@ def mergeSLC(self, aquisitionDates, virtual='True'):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)


geometryList = ['lat*rdr', 'lon*rdr', 'los*rdr', 'hgt*rdr', 'shadowMask*rdr','incLocal*rdr']
Expand All @@ -722,7 +721,7 @@ def mergeSLC(self, aquisitionDates, virtual='True'):
configObj.finalize()

g_line_cnt += 1
g_line_cnt = configObj.write_wrapper_config2run_file(configName, g_line_cnt)
configObj.write_wrapper_config2run_file(configName, g_line_cnt)
del configObj

def filter_coherence(self, pairs):
Expand All @@ -749,7 +748,7 @@ def filter_coherence(self, pairs):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
del configObj


Expand All @@ -775,7 +774,7 @@ def unwrap(self, pairs):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
configObj.write_wrapper_config2run_file(configName, line_cnt, pair == pairs[-1], self.numProcess)
del configObj

def denseOffsets(self, pairs):
Expand All @@ -795,7 +794,7 @@ def denseOffsets(self, pairs):
configObj.finalize()

line_cnt += 1
line_cnt = configObj.write_wrapper_config2run_file(configName, line_cnt)
configObj.write_wrapper_config2run_file(configName, line_cnt)
del configObj

def finalize(self):
Expand Down