added option '--renumber' to geom_rescale and geom_grainGrowth to renumber microstructures from 1 to N (without gaps), off by default.
added metavar information to some scripts
This commit is contained in:
parent
368de2f565
commit
371a027de9
|
@ -34,7 +34,7 @@ Converts ang files (EBSD Data) from hexagonal grid to a pixel grid
|
|||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
parser.add_option('-x', dest='columnX', action='store', type='int', \
|
||||
parser.add_option('-x', dest='columnX', action='store', type='int', metavar='int', \
|
||||
help='column containing x coordinates [%default]')
|
||||
|
||||
parser.set_defaults(columnX = 3)
|
||||
|
|
|
@ -61,9 +61,12 @@ parser.add_option('-d', '--distance', dest='d', type='int', metavar='int', \
|
|||
help='diffusion distance in voxels [%default]')
|
||||
parser.add_option('-N', '--smooth', dest='N', type='int', metavar='int', \
|
||||
help='N for curvature flow [%default]')
|
||||
parser.add_option('-r', '--renumber', dest='renumber', action='store_true', \
|
||||
help='renumber microstructure indices from 1...N [%default]')
|
||||
|
||||
parser.set_defaults(d = 1)
|
||||
parser.set_defaults(N = 1)
|
||||
parser.set_defaults(renumber = False)
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
|
||||
|
@ -192,7 +195,15 @@ for file in files:
|
|||
index = ndimage.morphology.distance_transform_edt(boundary >= 0.5,return_distances=False,return_indices=True)
|
||||
microstructure = microstructure[index[0].flatten(),index[1].flatten(),index[2].flatten()].reshape(microstructure.shape)
|
||||
|
||||
# --- assemble header -----------------------------------------------------------------------------
|
||||
# --- renumber to sequence 1...Ngrains if requested ------------------------------------------------
|
||||
# http://stackoverflow.com/questions/10741346/numpy-frequency-counts-for-unique-values-in-an-array
|
||||
if options.renumber:
|
||||
newID=0
|
||||
for microstructureID,count in enumerate(numpy.bincount(microstructure.reshape(info['grid'].prod()))):
|
||||
if count != 0:
|
||||
newID+=1
|
||||
microstructure=numpy.where(microstructure==microstructureID,newID,microstructure).reshape(microstructure.shape)
|
||||
# --- assemble header -----------------------------------------------------------------------------
|
||||
newInfo['microstructures'] = microstructure[0:info['grid'][0],0:info['grid'][1],0:info['grid'][2]].max()
|
||||
|
||||
#--- report ---------------------------------------------------------------------------------------
|
||||
|
|
|
@ -57,7 +57,10 @@ parser.add_option('-g', '--grid', dest='grid', type='string', nargs = 3, metavar
|
|||
help='a,b,c grid of hexahedral box [unchanged]')
|
||||
parser.add_option('-s', '--size', dest='size', type='string', nargs = 3, metavar = 'string string string', \
|
||||
help='x,y,z size of hexahedral box [unchanged]')
|
||||
parser.add_option('-r', '--renumber', dest='renumber', action='store_true', \
|
||||
help='renumber microstructure indices from 1...N [%default]')
|
||||
|
||||
parser.set_defaults(renumber = False)
|
||||
parser.set_defaults(grid = ['0','0','0'])
|
||||
parser.set_defaults(size = ['0.0','0.0','0.0'])
|
||||
|
||||
|
@ -169,6 +172,14 @@ for file in files:
|
|||
numpy.repeat(microstructure,multiplicity[0], axis=0),
|
||||
multiplicity[1], axis=1),
|
||||
multiplicity[2], axis=2)
|
||||
# --- renumber to sequence 1...Ngrains if requested ------------------------------------------------
|
||||
# http://stackoverflow.com/questions/10741346/numpy-frequency-counts-for-unique-values-in-an-array
|
||||
if options.renumber:
|
||||
newID=0
|
||||
for microstructureID,count in enumerate(numpy.bincount(microstructure.reshape(info['grid'].prod()))):
|
||||
if count != 0:
|
||||
newID+=1
|
||||
microstructure=numpy.where(microstructure==microstructureID,newID,microstructure).reshape(microstructure.shape)
|
||||
|
||||
newInfo['microstructures'] = microstructure.max()
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ Produce VTK point mesh from seeds file
|
|||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
parser.add_option('-g', '--grid', dest='grid', type='int', nargs = 3, \
|
||||
parser.add_option('-g', '--grid', dest='grid', type='int', nargs = 3, metavar='int int int', \
|
||||
help='a,b,c grid of hexahedral box [from seeds file]')
|
||||
parser.add_option('-s', '--size', dest='size', type='float', nargs = 3, \
|
||||
parser.add_option('-s', '--size', dest='size', type='float', nargs = 3, metavar='float float float',\
|
||||
help='x,y,z size of hexahedral box [1.0 along largest grid point number]')
|
||||
|
||||
parser.set_defaults(grid = [0,0,0])
|
||||
|
|
|
@ -43,11 +43,11 @@ Reports positions with random crystal orientations in seeds file format to STDOU
|
|||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
parser.add_option('-N', dest='N', type='int', \
|
||||
parser.add_option('-N', dest='N', type='int', metavar='int', \
|
||||
help='number of seed points to distribute [%default]')
|
||||
parser.add_option('-g','--grid', dest='grid', type='int', nargs=3, \
|
||||
parser.add_option('-g','--grid', dest='grid', type='int', nargs=3, metavar='int int int', \
|
||||
help='min a,b,c grid of hexahedral box %default')
|
||||
parser.add_option('-r', '--rnd', dest='randomSeed', type='int', \
|
||||
parser.add_option('-r', '--rnd', dest='randomSeed', type='int', metavar='int', \
|
||||
help='seed of random number generator [%default]')
|
||||
|
||||
parser.set_defaults(randomSeed = 0)
|
||||
|
|
Loading…
Reference in New Issue