fixed a bug in new --sort

--separation option now keeps data point location as intact as meaningful after applying averaging
This commit is contained in:
Philip Eisenlohr 2011-02-01 18:32:20 +00:00
parent 669893b397
commit 05350d573e
1 changed files with 12 additions and 8 deletions

View File

@ -962,20 +962,24 @@ for incCount,increment in enumerate(increments):
groupContent = [data[group][member][chunk]['content'] for member in range(len(data[group]))] # list of each member's chunk groupContent = [data[group][member][chunk]['content'] for member in range(len(data[group]))] # list of each member's chunk
if label == 'location': if label == 'location':
condensedGroupContent = mapFunc(label, groupContent, 'avg') # always average location condensedGroupContent = mapFunc(label, groupContent, 'avg') # always average location
if len(groupContent) > 1: # e,n,g nonsense if averaged over more than one entry... if 'elem' not in options.separation:
condensedGroupContent[:3] = ['n/a']*3 # ...so return 'n/a' condensedGroupContent[0] = 'n/a'
if 'node' not in options.separation:
condensedGroupContent[1] = 'n/a'
if 'grain' not in options.separation:
condensedGroupContent[2] = 'n/a'
elif len(groupContent) == 1: elif len(groupContent) == 1:
condensedGroupContent = map(str,groupContent[0]) condensedGroupContent = map(str,groupContent[0])
else: else:
condensedGroupContent = mapFunc(label, groupContent, options.func) # map function to groupContent to get condensed data of this group's chunk condensedGroupContent = mapFunc(label, groupContent, options.func) # map function to groupContent to get condensed data of this group's chunk
output[-1] += condensedGroupContent output[-1] += condensedGroupContent
sortProperties = options.separation sortProperties = []
for item in options.sort: for item in options.sort:
if item not in sortProperties: if item not in options.separation:
sortProperties.append(item) sortProperties.append(item)
for groupvalues in sortBySeparation(output, sortProperties, int(options.time)): # sort output according to separation criteria for groupvalues in sortBySeparation(output, options.separation+sortProperties, int(options.time)): # sort output according to separation criteria
file.write('\t'.join(map(str,groupvalues)) + '\n') file.write('\t'.join(map(str,groupvalues)) + '\n')
if fileOpen: if fileOpen: