diff --git a/processing/pre/geom_clean.py b/processing/pre/geom_clean.py index 18caf68b9..2bef9dc08 100755 --- a/processing/pre/geom_clean.py +++ b/processing/pre/geom_clean.py @@ -6,15 +6,12 @@ import numpy as np import damask from scipy import ndimage from optparse import OptionParser -from collections import defaultdict scriptName = os.path.splitext(os.path.basename(__file__))[0] scriptID = ' '.join([scriptName,damask.version]) def mostFrequent(arr): - d = defaultdict(int) - for i in arr: d[i] += 1 - return sorted(d.iteritems(), key=lambda x: x[1], reverse=True)[0][0] # return value of most frequent microstructure + return np.argmax(np.bincount(arr)) #-------------------------------------------------------------------------------------------------- @@ -43,10 +40,9 @@ parser.set_defaults(stencil = 3, if filenames == []: filenames = [None] for name in filenames: - try: - table = damask.ASCIItable(name = name, - buffered = False, - labeled = False) + try: table = damask.ASCIItable(name = name, + buffered = False, + labeled = False) except: continue damask.util.report(scriptName,name) @@ -72,7 +68,7 @@ for name in filenames: # --- read data ------------------------------------------------------------------------------------ - microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure + microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure # --- do work ------------------------------------------------------------------------------------