cleaning
This commit is contained in:
parent
d0c7f8b934
commit
bf60cffab5
|
@ -24,7 +24,7 @@ These objects can be boxes, cylinders, or ellipsoids.
|
|||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-c', '--center',
|
||||
dest='center',
|
||||
dest='center',
|
||||
type='float', nargs = 3, metavar=' '.join(['float']*3),
|
||||
help='a,b,c origin of primitive %default')
|
||||
parser.add_option('-d', '--dimension',
|
||||
|
@ -78,7 +78,7 @@ parser.set_defaults(center = (.0,.0,.0),
|
|||
(options, filenames) = parser.parse_args()
|
||||
|
||||
if options.dimension is None:
|
||||
parser.error('no dimension specified.')
|
||||
parser.error('no dimension specified.')
|
||||
if [options.angleaxis,options.quaternion].count(None) == 0:
|
||||
parser.error('more than one rotation specified.')
|
||||
|
||||
|
@ -94,7 +94,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
grid = geom.get_grid()
|
||||
size = geom.get_size()
|
||||
|
@ -106,7 +106,7 @@ for name in filenames:
|
|||
else:
|
||||
center = (np.array(options.center) + 0.5)/grid
|
||||
r = np.array(options.dimension)/grid/2.0
|
||||
|
||||
|
||||
if np.any(center<0.0) or np.any(center>=1.0): print('error')
|
||||
|
||||
offset = np.ones(3)*0.5 if options.periodic else center
|
||||
|
@ -120,17 +120,17 @@ for name in filenames:
|
|||
for z in range(grid[2]):
|
||||
coords = np.array([x+0.5,y+0.5,z+0.5])/grid
|
||||
mask[x,y,z] = np.sum(np.abs((rotation*(coords-offset))/r)**e) < 1
|
||||
|
||||
|
||||
if options.periodic:
|
||||
shift = ((offset-center)*grid).astype(int)
|
||||
mask = np.roll(mask,shift,(0,1,2))
|
||||
|
||||
|
||||
if options.inside: mask = np.logical_not(mask)
|
||||
fill = np.nanmax(geom.microstructure)+1 if options.fill is None else options.fill
|
||||
|
||||
damask.util.croak(geom.update(np.where(mask,geom.microstructure,fill)))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -45,7 +45,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
grid = geom.get_grid()
|
||||
|
@ -56,13 +56,13 @@ for name in filenames:
|
|||
|
||||
new = np.full(grid,options.fill if options.fill is not None
|
||||
else np.nanmax(geom.microstructure)+1,geom.microstructure.dtype)
|
||||
|
||||
|
||||
for x in range(geom.microstructure.shape[0]):
|
||||
X = x + options.offset[0]
|
||||
if not 0 <= X < new.shape[0]: continue
|
||||
if not 0 <= X < new.shape[0]: continue
|
||||
for y in range(geom.microstructure.shape[1]):
|
||||
Y = y + options.offset[1]
|
||||
if not 0 <= Y < new.shape[1]: continue
|
||||
if not 0 <= Y < new.shape[1]: continue
|
||||
for z in range(geom.microstructure.shape[2]):
|
||||
Z = z + options.offset[2]
|
||||
if not 0 <= Z < new.shape[2]: continue
|
||||
|
|
|
@ -5,7 +5,7 @@ if [[ "$1" == "-f" || "$1" == "--float" ]]; then
|
|||
arg='--float'
|
||||
else
|
||||
arg=''
|
||||
fi
|
||||
fi
|
||||
|
||||
for geom in "$@"
|
||||
do
|
||||
|
|
|
@ -43,7 +43,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
damask.util.croak(geom.update(ndimage.filters.generic_filter(
|
||||
|
|
|
@ -78,7 +78,7 @@ for name in filenames:
|
|||
damask.util.report(scriptName,name)
|
||||
|
||||
errors = []
|
||||
|
||||
|
||||
inFile = h5py.File(name, 'r')
|
||||
group_geom = os.path.join(rootDir,options.basegroup,'_SIMPL_GEOMETRY')
|
||||
try:
|
||||
|
@ -88,8 +88,8 @@ for name in filenames:
|
|||
origin = inFile[os.path.join(group_geom,'ORIGIN')][...]
|
||||
except:
|
||||
errors.append('Geometry data ({}) not found'.format(group_geom))
|
||||
|
||||
|
||||
|
||||
|
||||
group_pointwise = os.path.join(rootDir,options.basegroup,options.pointwise)
|
||||
if options.average is None:
|
||||
label = 'Point'
|
||||
|
@ -100,33 +100,33 @@ for name in filenames:
|
|||
rot = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in quats]
|
||||
except:
|
||||
errors.append('Pointwise orientation (quaternion) data ({}) not readable'.format(dataset))
|
||||
|
||||
|
||||
dataset = os.path.join(group_pointwise,options.phase)
|
||||
try:
|
||||
phase = np.reshape(inFile[dataset][...],(np.product(grid)))
|
||||
except:
|
||||
errors.append('Pointwise phase data ({}) not readable'.format(dataset))
|
||||
|
||||
|
||||
microstructure = np.arange(1,np.product(grid)+1,dtype=int).reshape(grid,order='F')
|
||||
|
||||
|
||||
|
||||
else:
|
||||
label = 'Grain'
|
||||
|
||||
|
||||
dataset = os.path.join(group_pointwise,options.microstructure)
|
||||
try:
|
||||
microstructure = np.transpose(inFile[dataset][...].reshape(grid[::-1]),(2,1,0)) # convert from C ordering
|
||||
except:
|
||||
errors.append('Link between pointwise and grain average data ({}) not readable'.format(dataset))
|
||||
|
||||
|
||||
group_average = os.path.join(rootDir,options.basegroup,options.average)
|
||||
|
||||
|
||||
dataset = os.path.join(group_average,options.quaternion)
|
||||
try:
|
||||
rot = [damask.Rotation.fromQuaternion(q,True,P=+1) for q in inFile[dataset][...][1:]] # skip first entry (unindexed)
|
||||
except:
|
||||
errors.append('Average orientation data ({}) not readable'.format(dataset))
|
||||
|
||||
|
||||
dataset = os.path.join(group_average,options.phase)
|
||||
try:
|
||||
phase = [i[0] for i in inFile[dataset][...]][1:] # skip first entry (unindexed)
|
||||
|
@ -148,7 +148,7 @@ for name in filenames:
|
|||
'crystallite 1',
|
||||
'(constituent)\tphase {}\ttexture {}\tfraction 1.0'.format(phase[i],i+1),
|
||||
]
|
||||
|
||||
|
||||
header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
|
||||
+ config_header
|
||||
geom = damask.Geom(microstructure,size,origin,
|
||||
|
|
|
@ -85,7 +85,7 @@ for x in range(options.grid[0]):
|
|||
for y in range(options.grid[1]):
|
||||
for z in range(options.grid[2]):
|
||||
microstructure[x,y,z]=options.microstructure[int(options.threshold < surface[options.type](X[x],Y[y],Z[z]))]
|
||||
|
||||
|
||||
geom=damask.Geom(microstructure,options.size,
|
||||
homogenization=options.homogenization,
|
||||
comments=[scriptID + ' ' + ' '.join(sys.argv[1:])])
|
||||
|
|
|
@ -52,7 +52,7 @@ parser.add_option( '--aspect',
|
|||
dest='aspect',
|
||||
type='float', metavar = 'float',
|
||||
help='vertical/horizontal osteon aspect ratio [%default]')
|
||||
parser.add_option('-w', '--omega',
|
||||
parser.add_option('-w', '--omega',
|
||||
dest='omega',
|
||||
type='float', metavar = 'float',
|
||||
help='rotation angle around normal of osteon [%default]')
|
||||
|
@ -112,7 +112,7 @@ for y in range(grid[1]):
|
|||
microstructure[x,y] = i
|
||||
Alpha[i] = alpha[x,y]
|
||||
Beta [i] = beta [x,y]
|
||||
i+=1
|
||||
i+=1
|
||||
|
||||
config_header = ['<texture>',
|
||||
'[canal]',
|
||||
|
@ -122,7 +122,7 @@ for i in range(3,np.max(microstructure)):
|
|||
config_header += ['[Point{}]'.format(i-2),
|
||||
'(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 0'.format(Alpha[i],Beta[i])
|
||||
]
|
||||
|
||||
|
||||
config_header = ['<microstructure>',
|
||||
'[canal]',
|
||||
'crystallite 1',
|
||||
|
@ -143,7 +143,7 @@ geom = damask.Geom(microstructure.reshape(grid),
|
|||
size,-size/2,
|
||||
homogenization=options.homogenization,comments=header)
|
||||
damask.util.croak(geom)
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -63,7 +63,7 @@ geom = damask.Geom(microstructure=np.full(options.grid,options.fill,dtype=dtype)
|
|||
homogenization=options.homogenization,
|
||||
comments=scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
damask.util.croak(geom)
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -18,7 +18,7 @@ scriptID = ' '.join([scriptName,damask.version])
|
|||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Converts ASCII table. Input can be microstructure or orientation (as quaternion). For the latter,
|
||||
Converts ASCII table. Input can be microstructure or orientation (as quaternion). For the latter,
|
||||
phase information can be given additionally.
|
||||
|
||||
""", version = scriptID)
|
||||
|
@ -78,7 +78,7 @@ for name in filenames:
|
|||
table = damask.ASCIItable(name = name,readonly=True)
|
||||
table.head_read() # read ASCII header info
|
||||
|
||||
# ------------------------------------------ sanity checks ---------------------------------------
|
||||
# ------------------------------------------ sanity checks ---------------------------------------
|
||||
|
||||
coordDim = table.label_dimension(options.pos)
|
||||
|
||||
|
@ -89,7 +89,7 @@ for name in filenames:
|
|||
errors.append('input "{}" needs to have dimension {}.'.format(label,dim))
|
||||
if options.phase and table.label_dimension(options.phase) != 1:
|
||||
errors.append('phase column "{}" is not scalar.'.format(options.phase))
|
||||
|
||||
|
||||
if errors != []:
|
||||
damask.util.croak(errors)
|
||||
continue
|
||||
|
@ -97,7 +97,7 @@ for name in filenames:
|
|||
table.data_readArray([options.pos] \
|
||||
+ (label if isinstance(label, list) else [label]) \
|
||||
+ ([options.phase] if options.phase else []))
|
||||
|
||||
|
||||
if coordDim == 2:
|
||||
table.data = np.insert(table.data,2,np.zeros(len(table.data)),axis=1) # add zero z coordinate for two-dimensional input
|
||||
if options.phase is None:
|
||||
|
@ -112,7 +112,7 @@ for name in filenames:
|
|||
indices = np.lexsort((table.data[:,0],table.data[:,1],table.data[:,2])) # indices of position when sorting x fast, z slow
|
||||
microstructure = np.empty(grid,dtype = int) # initialize empty microstructure
|
||||
i = 0
|
||||
|
||||
|
||||
if inputtype == 'microstructure':
|
||||
for z in range(grid[2]):
|
||||
for y in range(grid[1]):
|
||||
|
@ -124,21 +124,21 @@ for name in filenames:
|
|||
|
||||
elif inputtype == 'quaternion':
|
||||
unique,unique_inverse = np.unique(table.data[:,3:8],return_inverse=True,axis=0)
|
||||
|
||||
|
||||
for z in range(grid[2]):
|
||||
for y in range(grid[1]):
|
||||
for x in range(grid[0]):
|
||||
microstructure[x,y,z] = unique_inverse[indices[i]]+1
|
||||
i+=1
|
||||
|
||||
|
||||
config_header = ['<texture>']
|
||||
for i,data in enumerate(unique):
|
||||
ori = damask.Rotation(data[0:4])
|
||||
config_header += ['[Grain{}]'.format(i+1),
|
||||
'(gauss)\tphi1 {:g}\tPhi {:g}\tphi2 {:g}'.format(*ori.asEulers(degrees = True)),
|
||||
]
|
||||
if options.axes is not None: config_header += ['axes\t{} {} {}'.format(*options.axes)]
|
||||
|
||||
if options.axes is not None: config_header += ['axes\t{} {} {}'.format(*options.axes)]
|
||||
|
||||
config_header += ['<microstructure>']
|
||||
for i,data in enumerate(unique):
|
||||
config_header += ['[Grain{}]'.format(i+1),
|
||||
|
@ -151,7 +151,7 @@ for name in filenames:
|
|||
geom = damask.Geom(microstructure,size,origin,
|
||||
homogenization=options.homogenization,comments=header)
|
||||
damask.util.croak(geom)
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import sys
|
||||
import multiprocessing
|
||||
from optparse import OptionParser,OptionGroup
|
||||
|
||||
|
@ -22,7 +22,7 @@ def laguerreTessellation(undeformed, coords, weights, grains, periodic = True, c
|
|||
tmp = np.repeat(point.reshape(3,1), len(seeds), axis=1).T
|
||||
dist = np.sum((tmp - seeds)**2,axis=1) -myWeights
|
||||
return np.argmin(dist) # seed point closest to point
|
||||
|
||||
|
||||
copies = \
|
||||
np.array([
|
||||
[ -1,-1,-1 ],
|
||||
|
@ -60,7 +60,7 @@ def laguerreTessellation(undeformed, coords, weights, grains, periodic = True, c
|
|||
repeatweights = np.tile(weights,len(copies)).flatten(order='F') # Laguerre weights (1,2,3,1,2,3,...,1,2,3)
|
||||
for i,vec in enumerate(copies): # periodic copies of seed points ...
|
||||
try: seeds = np.append(seeds, coords+vec, axis=0) # ... (1+a,2+a,3+a,...,1+z,2+z,3+z)
|
||||
except NameError: seeds = coords+vec
|
||||
except NameError: seeds = coords+vec
|
||||
|
||||
if (repeatweights == 0.0).all(): # standard Voronoi (no weights, KD tree)
|
||||
myKDTree = spatial.cKDTree(seeds)
|
||||
|
@ -81,7 +81,7 @@ def laguerreTessellation(undeformed, coords, weights, grains, periodic = True, c
|
|||
closestSeeds[i] = findClosestSeed(arg)
|
||||
|
||||
# closestSeed is modulo number of original seed points (i.e. excluding periodic copies)
|
||||
return grains[closestSeeds%coords.shape[0]]
|
||||
return grains[closestSeeds%coords.shape[0]]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
@ -202,7 +202,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
table = damask.ASCIItable(name = name, readonly = True)
|
||||
|
||||
|
||||
|
@ -210,17 +210,17 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
|
||||
if options.grid is not None: info['grid'] = options.grid
|
||||
if options.size is not None: info['size'] = options.size
|
||||
if options.origin is not None: info['origin'] = options.origin
|
||||
|
||||
# ------------------------------------------ sanity checks ---------------------------------------
|
||||
|
||||
# ------------------------------------------ sanity checks ---------------------------------------
|
||||
|
||||
remarks = []
|
||||
errors = []
|
||||
labels = []
|
||||
|
||||
|
||||
hasGrains = table.label_dimension(options.microstructure) == 1
|
||||
hasEulers = table.label_dimension(options.eulers) == 3
|
||||
hasWeights = table.label_dimension(options.weight) == 1 and options.laguerre
|
||||
|
@ -250,8 +250,8 @@ for name in filenames:
|
|||
table.close(dismiss=True)
|
||||
continue
|
||||
|
||||
# ------------------------------------------ read seeds ---------------------------------------
|
||||
|
||||
# ------------------------------------------ read seeds ---------------------------------------
|
||||
|
||||
table.data_readArray(labels)
|
||||
coords = table.data[:,table.label_indexrange(options.pos)] * info['size'] if options.normalized \
|
||||
else table.data[:,table.label_indexrange(options.pos)] - info['origin']
|
||||
|
@ -271,13 +271,13 @@ for name in filenames:
|
|||
z = (np.arange(info['grid'][2])+0.5)*info['size'][2]/info['grid'][2]
|
||||
X,Y,Z = np.meshgrid(x, y, z,indexing='ij')
|
||||
grid = np.stack((X,Y,Z),axis=-1).reshape((info['grid'].prod(),3),order='F')
|
||||
|
||||
|
||||
damask.util.croak('tessellating...')
|
||||
indices = laguerreTessellation(grid, coords, weights, grains, options.periodic, options.cpus)
|
||||
|
||||
|
||||
config_header = []
|
||||
if options.config:
|
||||
|
||||
|
||||
if hasEulers:
|
||||
config_header += ['<texture>']
|
||||
for ID in grainIDs:
|
||||
|
@ -286,7 +286,7 @@ for name in filenames:
|
|||
'(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 {:.2f}'.format(*eulers[eulerID])
|
||||
]
|
||||
if options.axes is not None: config_header += ['axes\t{} {} {}'.format(*options.axes)]
|
||||
|
||||
|
||||
config_header += ['<microstructure>']
|
||||
for ID in grainIDs:
|
||||
config_header += ['[Grain{}]'.format(ID),
|
||||
|
@ -295,13 +295,13 @@ for name in filenames:
|
|||
]
|
||||
|
||||
config_header += ['<!skip>']
|
||||
|
||||
|
||||
header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
|
||||
+ config_header
|
||||
geom = damask.Geom(indices.reshape(info['grid'],order='F'),info['size'],info['origin'],
|
||||
homogenization=options.homogenization,comments=header)
|
||||
damask.util.croak(geom)
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -60,9 +60,9 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
grid_original = geom.get_grid()
|
||||
damask.util.croak(geom)
|
||||
microstructure = np.tile(geom.microstructure,np.where(grid_original == 1, 2,1)) # make one copy along dimensions with grid == 1
|
||||
|
@ -71,15 +71,15 @@ for name in filenames:
|
|||
# --- initialize support data ---------------------------------------------------------------------
|
||||
|
||||
# store a copy the initial microstructure to find locations of immutable indices
|
||||
microstructure_original = np.copy(microstructure)
|
||||
microstructure_original = np.copy(microstructure)
|
||||
|
||||
if not options.ndimage:
|
||||
X,Y,Z = np.mgrid[0:grid[0],0:grid[1],0:grid[2]]
|
||||
|
||||
|
||||
# Calculates gaussian weights for simulating 3d diffusion
|
||||
gauss = np.exp(-(X*X + Y*Y + Z*Z)/(2.0*options.d*options.d),dtype=np.float32) \
|
||||
/np.power(2.0*np.pi*options.d*options.d,(3.0 - np.count_nonzero(grid_original == 1))/2.,dtype=np.float32)
|
||||
|
||||
|
||||
gauss[:,:,:grid[2]//2:-1] = gauss[:,:,1:(grid[2]+1)//2] # trying to cope with uneven (odd) grid size
|
||||
gauss[:,:grid[1]//2:-1,:] = gauss[:,1:(grid[1]+1)//2,:]
|
||||
gauss[:grid[0]//2:-1,:,:] = gauss[1:(grid[0]+1)//2,:,:]
|
||||
|
@ -102,7 +102,7 @@ for name in filenames:
|
|||
grid[2]//2:-grid[2]//2]
|
||||
|
||||
# transform bulk volume (i.e. where interfacial energy remained zero), store index of closest boundary voxel
|
||||
index = ndimage.morphology.distance_transform_edt(periodic_interfaceEnergy == 0.,
|
||||
index = ndimage.morphology.distance_transform_edt(periodic_interfaceEnergy == 0.,
|
||||
return_distances = False,
|
||||
return_indices = True)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ parser.add_option('-d','--direction',
|
|||
parser.add_option( '--periodic',
|
||||
dest = 'periodic',
|
||||
action = 'store_true',
|
||||
help = 'omit periodic copies of outermost layers in mirror direction')
|
||||
help = 'omit periodic copies of outermost layers in mirror direction')
|
||||
|
||||
parser.set_defaults(periodic = False)
|
||||
|
||||
|
@ -52,9 +52,9 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
microstructure = geom.get_microstructure()
|
||||
if 'z' in options.directions:
|
||||
microstructure = np.concatenate([microstructure,microstructure[:,:,limits[0]:limits[1]:-1]],2)
|
||||
|
@ -62,10 +62,10 @@ for name in filenames:
|
|||
microstructure = np.concatenate([microstructure,microstructure[:,limits[0]:limits[1]:-1,:]],1)
|
||||
if 'x' in options.directions:
|
||||
microstructure = np.concatenate([microstructure,microstructure[limits[0]:limits[1]:-1,:,:]],0)
|
||||
|
||||
|
||||
damask.util.croak(geom.update(microstructure,rescale=True))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -33,7 +33,7 @@ for name in filenames:
|
|||
|
||||
damask.util.croak(geom)
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
compressType = None
|
||||
former = start = -1
|
||||
reps = 0
|
||||
|
@ -65,7 +65,7 @@ for name in filenames:
|
|||
reps = 1
|
||||
|
||||
former = current
|
||||
|
||||
|
||||
if compressType == '.':
|
||||
f.write('{}\n'.format(former))
|
||||
elif compressType == 'to':
|
||||
|
|
|
@ -30,16 +30,16 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
renumbered = np.empty(geom.get_grid(),dtype=geom.microstructure.dtype)
|
||||
for i, oldID in enumerate(np.unique(geom.microstructure)):
|
||||
renumbered = np.where(geom.microstructure == oldID, i+1, renumbered)
|
||||
|
||||
damask.util.croak(geom.update(renumbered))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -41,7 +41,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
grid = geom.get_grid()
|
||||
|
@ -55,7 +55,7 @@ for name in filenames:
|
|||
np.array([o*float(n.lower().replace('x','')) if n.lower().endswith('x') \
|
||||
else float(n) for o,n in zip(size,options.size)],dtype=float)
|
||||
|
||||
damask.util.croak(geom.update(microstructure =
|
||||
damask.util.croak(geom.update(microstructure =
|
||||
ndimage.interpolation.zoom(
|
||||
geom.microstructure,
|
||||
new_grid/grid,output=geom.microstructure.dtype,
|
||||
|
|
|
@ -76,7 +76,7 @@ for name in filenames:
|
|||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
microstructure = geom.get_microstructure()
|
||||
fill = np.nanmax(microstructure)+1 if options.fill is None else options.fill
|
||||
dtype = float if np.isnan(fill) or int(fill) != fill or microstructure.dtype==np.float else int
|
||||
|
@ -89,10 +89,10 @@ for name in filenames:
|
|||
prefilter=False,output=dtype,cval=fill) # rotation around x
|
||||
microstructure = ndimage.rotate(microstructure,eulers[0],(0,1),order=0,
|
||||
prefilter=False,output=dtype,cval=fill) # rotation around z
|
||||
|
||||
|
||||
damask.util.croak(geom.update(microstructure,rescale=True))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -30,17 +30,17 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
damask.util.croak(geom)
|
||||
|
||||
|
||||
# --- generate grid --------------------------------------------------------------------------------
|
||||
|
||||
grid = geom.get_grid()
|
||||
size = geom.get_size()
|
||||
origin = geom.get_origin()
|
||||
|
||||
|
||||
x = (0.5 + np.arange(grid[0],dtype=float))/grid[0]*size[0]+origin[0]
|
||||
y = (0.5 + np.arange(grid[1],dtype=float))/grid[1]*size[1]+origin[1]
|
||||
z = (0.5 + np.arange(grid[2],dtype=float))/grid[2]*size[2]+origin[2]
|
||||
|
|
|
@ -48,13 +48,13 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
substituted = geom.get_microstructure()
|
||||
for old,new in zip(sub[0::2],sub[1::2]): substituted[substituted==old] = new # substitute microstructure indices
|
||||
substituted += options.microstructure # constant shift
|
||||
|
||||
|
||||
damask.util.croak(geom.update(substituted,origin=geom.get_origin()+options.origin))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ for name in filenames:
|
|||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
|
||||
damask.util.croak(geom)
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
|
@ -68,7 +68,7 @@ if filenames == []: filenames = [None]
|
|||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
offset = np.nanmax(geom.microstructure) if options.offset is None else options.offset
|
||||
|
@ -81,7 +81,7 @@ for name in filenames:
|
|||
extra_keywords={"trigger":options.trigger,"size":1+2*options.vicinity}),
|
||||
geom.microstructure + offset,geom.microstructure)))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
|
||||
|
||||
if name is None:
|
||||
sys.stdout.write(str(geom.show()))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue