cleaning
This commit is contained in:
parent
d43dfa569b
commit
130fac21c6
|
@ -151,11 +151,10 @@ def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_lengt
|
|||
filled_length = int(round(bar_length * iteration / float(total)))
|
||||
bar = '█' * filled_length + '-' * (bar_length - filled_length)
|
||||
|
||||
sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)),
|
||||
sys.stderr.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)),
|
||||
|
||||
if iteration == total:
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
if iteration == total: sys.stderr.write('\n\n')
|
||||
sys.stderr.flush()
|
||||
|
||||
# -----------------------------
|
||||
class backgroundMessage(threading.Thread):
|
||||
|
|
|
@ -29,20 +29,25 @@ parser.add_option('-d',
|
|||
parser.add_option('-s',
|
||||
'--symmetry',
|
||||
dest = 'symmetry',
|
||||
type = 'string', metavar = 'string',
|
||||
metavar = 'string',
|
||||
help = 'crystal symmetry [%default]')
|
||||
parser.add_option('-q',
|
||||
'--quaternion',
|
||||
dest = 'quaternion',
|
||||
type = 'string', metavar = 'string',
|
||||
metavar = 'string',
|
||||
help = 'label of quaternion')
|
||||
parser.add_option('-p',
|
||||
'--pos', '--position',
|
||||
dest = 'pos',
|
||||
type = 'string', metavar = 'string',
|
||||
metavar = 'string',
|
||||
help = 'label of coordinates [%default]')
|
||||
parser.add_option('--quiet',
|
||||
dest='verbose',
|
||||
action = 'store_false',
|
||||
help = 'hide status bar (useful when piping to file)')
|
||||
|
||||
parser.set_defaults(disorientation = 5,
|
||||
verbose = True,
|
||||
quaternion = 'orientation',
|
||||
symmetry = 'cubic',
|
||||
pos = 'pos',
|
||||
|
@ -111,7 +116,7 @@ for name in filenames:
|
|||
table.data_rewind()
|
||||
while table.data_read(): # read next data line of ASCII table
|
||||
|
||||
if Npoints > 100 and p%(Npoints//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
if options.verbose and Npoints > 100 and p%(Npoints//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.print_progress(iteration=p,total=Npoints)
|
||||
|
||||
o = damask.Orientation(quaternion = np.array(list(map(float,table.data[column:column+4]))),
|
||||
|
@ -160,6 +165,7 @@ for name in filenames:
|
|||
|
||||
outputAlive = True
|
||||
p = 0
|
||||
damask.util.print_progress(iteration=1,total=1)
|
||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||
table.data_append(1+packingMap[grainID[p]]) # add (condensed) grain ID
|
||||
outputAlive = table.data_write() # output processed line
|
||||
|
|
|
@ -636,7 +636,7 @@ parser.add_option('-p','--type', dest='filetype',
|
|||
help = 'type of result file [auto]')
|
||||
parser.add_option('-q','--quiet', dest='verbose',
|
||||
action = 'store_false',
|
||||
help = 'legacy switch, no effect')
|
||||
help = 'hide status bar (useful when piping to file)')
|
||||
|
||||
group_material = OptionGroup(parser,'Material identifier')
|
||||
|
||||
|
@ -679,6 +679,7 @@ parser.add_option_group(group_special)
|
|||
|
||||
parser.set_defaults(info = False,
|
||||
nodal = False,
|
||||
verbose = True,
|
||||
prefix = '',
|
||||
suffix = '',
|
||||
dir = 'postProc',
|
||||
|
@ -705,6 +706,8 @@ if files == []:
|
|||
parser.print_help()
|
||||
parser.error('no file specified...')
|
||||
|
||||
damask.util.report(scriptName,files[0])
|
||||
|
||||
if not os.path.exists(files[0]):
|
||||
parser.print_help()
|
||||
parser.error('invalid file "%s" specified...'%files[0])
|
||||
|
@ -828,7 +831,7 @@ if options.info:
|
|||
elementsOfNode = {}
|
||||
Nelems = stat['NumberOfElements']
|
||||
for e in range(Nelems):
|
||||
if Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
if options.verbose and Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.print_progress(iteration=e,total=Nelems,prefix='1/3: connecting elements')
|
||||
for n in map(p.node_sequence,p.element(e).items):
|
||||
if n not in elementsOfNode:
|
||||
|
@ -848,11 +851,12 @@ index = {}
|
|||
groups = []
|
||||
groupCount = 0
|
||||
memberCount = 0
|
||||
print('\n')
|
||||
damask.util.print_progress(iteration=1,total=1,prefix='1/3: connecting elements')
|
||||
|
||||
if options.nodalScalar:
|
||||
Npoints = stat['NumberOfNodes']
|
||||
for n in range(Npoints):
|
||||
if Npoints > 100 and e%(Npoints//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
if options.verbose and Npoints > 100 and e%(Npoints//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.print_progress(iteration=n,total=Npoints,prefix='2/3: scanning nodes ')
|
||||
myNodeID = p.node_id(n)
|
||||
myNodeCoordinates = [p.node(n).x, p.node(n).y, p.node(n).z]
|
||||
|
@ -884,12 +888,12 @@ if options.nodalScalar:
|
|||
myNodeCoordinates) # incrementally update average location
|
||||
groups[index[grp]].append([myElemID,myNodeID,myIpID,myGrainID,0]) # append a new list defining each group member
|
||||
memberCount += 1
|
||||
print('\n')
|
||||
damask.util.print_progress(iteration=1,total=1,prefix='2/3: scanning nodes ')
|
||||
|
||||
else:
|
||||
Nelems = stat['NumberOfElements']
|
||||
for e in range(Nelems):
|
||||
if Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
if options.verbose and Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.print_progress(iteration=e,total=Nelems,prefix='2/3: scanning elements ')
|
||||
myElemID = p.element_id(e)
|
||||
myIpCoordinates = ipCoords(p.element(e).type, list(map(lambda node: [node.x, node.y, node.z],
|
||||
|
@ -930,7 +934,7 @@ else:
|
|||
myIpCoordinates[n]) # incrementally update average location
|
||||
groups[index[grp]].append([myElemID,myNodeID,myIpID,myGrainID,n]) # append a new list defining each group member
|
||||
memberCount += 1
|
||||
print('\n')
|
||||
damask.util.print_progress(iteration=1,total=1,prefix='2/3: scanning elements ')
|
||||
|
||||
|
||||
# --------------------------- sort groups --------------------------------
|
||||
|
@ -1030,7 +1034,7 @@ for incCount,position in enumerate(locations): # walk through locations
|
|||
Ngroups = len(groups)
|
||||
for j,group in enumerate(groups):
|
||||
f = incCount*Ngroups + j
|
||||
if (Ngroups*Nincs) > 100 and f%((Ngroups*Nincs)//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
if options.verbose and (Ngroups*Nincs) > 100 and f%((Ngroups*Nincs)//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.print_progress(iteration=f,total=Ngroups*Nincs,prefix='3/3: processing points ')
|
||||
N = 0 # group member counter
|
||||
for (e,n,i,g,n_local) in group[1:]: # loop over group members
|
||||
|
@ -1122,7 +1126,7 @@ for incCount,position in enumerate(locations): # walk through locations
|
|||
group[0] + \
|
||||
mappedResult)
|
||||
)) + '\n')
|
||||
print('')
|
||||
damask.util.print_progress(iteration=1,total=1,prefix='3/3: processing points ')
|
||||
|
||||
if fileOpen:
|
||||
file.close()
|
||||
|
|
Loading…
Reference in New Issue