contrib/stack/topsStack/s1_select_ion.py
def check_small_number_of_acquisitions_with_same_starting_ranges(group, threshold=1):
    '''
    for the same subswath starting ranges,
    if the number of acquistions < threshold, remove these acquistions 
    '''

    print('\nchecking small-number of acquistions with same starting ranges')

    ngroup = len(group)

    starting_ranges = [x[0].startingRanges for x in group]
    
    #get unique starting_ranges
    starting_ranges_unique = []
    for i in range(ngroup):
        if starting_ranges[i] not in starting_ranges_unique:
            starting_ranges_unique.append(starting_ranges[i])

    #get number of acquistions for each unique starting ranges
    ngroup_unique = len(starting_ranges_unique)
    starting_ranges_unique_number = [0 for i in range(ngroup_unique)]
    for k in range(ngroup_unique):
        for i in range(ngroup):
            if starting_ranges_unique[k] == starting_ranges[i]:
                starting_ranges_unique_number[k] += 1

    #get starting ranges to be removed (number of acquistions < threshold)
    starting_ranges_removed = []
    for k in range(ngroup_unique):
        if starting_ranges_unique_number[k] < threshold:
            starting_ranges_removed.append(starting_ranges_unique[k])

    #remove acquistions
    if starting_ranges_removed != []:
        group_new = [group[i] for i in range(ngroup) if group[i][0].startingRanges not in starting_ranges_removed]

        print('acquistions removed:')
        for i in range(ngroup):
            if group[i][0].startingRanges in starting_ranges_removed:
                for j in range(len(group[i])):
                    print('%s %3d'%(os.path.basename(group[i][j].safe_file), i+1))

    else:
        group_new = group
        print('no acquistions removed')

    return group_new

    for the same subswath starting ranges,
    if the number of acquistions < threshold, remove these acquistions 
    
for the same subswath starting ranges,
if the number of acquistions < threshold, remove these acquistions
for the same subswath starting ranges if the number of acquistions < threshold remove these acquistions
def check_small_number_of_acquisitions_with_same_starting_ranges(group, threshold=1):
    print('\nchecking small-number of acquistions with same starting ranges')
    ngroup = len(group)
    starting_ranges = [x[0].startingRanges for x in group]
    starting_ranges_unique = []
    for i in range(ngroup):
        if starting_ranges[i] not in starting_ranges_unique:
            starting_ranges_unique.append(starting_ranges[i])
    ngroup_unique = len(starting_ranges_unique)
    starting_ranges_unique_number = [0 for i in range(ngroup_unique)]
    for k in range(ngroup_unique):
        for i in range(ngroup):
            if starting_ranges_unique[k] == starting_ranges[i]:
                starting_ranges_unique_number[k] += 1
    starting_ranges_removed = []
    for k in range(ngroup_unique):
        if starting_ranges_unique_number[k] < threshold:
            starting_ranges_removed.append(starting_ranges_unique[k])
    if starting_ranges_removed != []:
        group_new = [group[i] for i in range(ngroup) if group[i][0].startingRanges not in starting_ranges_removed]
        print('acquistions removed:')
        for i in range(ngroup):
            if group[i][0].startingRanges in starting_ranges_removed:
                for j in range(len(group[i])):
                    print('%s %3d'%(os.path.basename(group[i][j].safe_file), i+1))
    else:
        group_new = group
        print('no acquistions removed')
    return group_new
def check_small_number_of_acquisitions_with_same_starting_ranges ( group , threshold = 1 ) : print ( '\nchecking small-number of acquistions with same starting ranges' ) ngroup = len ( group ) starting_ranges = [ x [ 0 ] . startingRanges for x in group ] starting_ranges_unique = [ ] for i in range ( ngroup ) : if starting_ranges [ i ] not in starting_ranges_unique : starting_ranges_unique . append ( starting_ranges [ i ] ) ngroup_unique = len ( starting_ranges_unique ) starting_ranges_unique_number = [ 0 for i in range ( ngroup_unique ) ] for k in range ( ngroup_unique ) : for i in range ( ngroup ) : if starting_ranges_unique [ k ] == starting_ranges [ i ] : starting_ranges_unique_number [ k ] += 1 starting_ranges_removed = [ ] for k in range ( ngroup_unique ) : if starting_ranges_unique_number [ k ] < threshold : starting_ranges_removed . append ( starting_ranges_unique [ k ] ) if starting_ranges_removed != [ ] : group_new = [ group [ i ] for i in range ( ngroup ) if group [ i ] [ 0 ] . startingRanges not in starting_ranges_removed ] print ( 'acquistions removed:' ) for i in range ( ngroup ) : if group [ i ] [ 0 ] . startingRanges in starting_ranges_removed : for j in range ( len ( group [ i ] ) ) : print ( '%s %3d' % ( os . path . basename ( group [ i ] [ j ] . safe_file ) , i + 1 ) ) else : group_new = group print ( 'no acquistions removed' ) return group_new
for the same subswath starting ranges,
if the number of acquistions < threshold, remove these acquistions
for the same subswath starting ranges if the number of acquistions < threshold remove these acquistions
'''
    for the same subswath starting ranges,
    if the number of acquistions < threshold, remove these acquistions 
    ''' #get unique starting_ranges #get number of acquistions for each unique starting ranges #get starting ranges to be removed (number of acquistions < threshold) #remove acquistions
group
threshold