fixed buggy version

This commit is contained in:
Philip Eisenlohr 2019-06-03 13:39:45 -04:00
parent 89e4bc800c
commit 2870fdb25b
1 changed files with 18 additions and 19 deletions

View File

@ -48,30 +48,29 @@ 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()
origin = geom.get_origin()
size = geom.get_size()
grid = canvasgrid = geom.get_grid()
offset = np.asarray(options.offset)
if options.grid is not None:
grid = np.array([int(o*float(n.lower().replace('x',''))) if n.lower().endswith('x') \
else int(n) for o,n in zip(grid,options.grid)],dtype=int)
grid = np.maximum(grid,1)
new = np.full(grid,options.fill if options.fill is not None
if options.grid is not None:
canvasgrid = np.maximum(1,
np.array([int(o*float(n.lower().replace('x',''))) if n.lower().endswith('x') \
else int(n) for o,n in zip(grid,options.grid)],dtype=int))
canvas = np.full(canvasgrid,options.fill if options.fill is not None
else np.nanmax(geom.microstructure)+1,geom.microstructure.dtype)
n = np.asarray(new.shape)
o = np.asarray(geom.microstructure.shape)
l = np.clip( offset, 0,np.minimum(o +offset,n))
r = np.clip( offset+o,0,np.minimum(o*2+offset,n))
l = np.maximum( 0, offset)
r = np.minimum(grid,canvasgrid+offset)
L = l - offset
R = r - offset
L = np.clip(-offset, 0,np.minimum(n -offset,o))
R = np.clip(-offset+n,0,np.minimum(n*2-offset,o))
canvas [L[0]:R[0],L[1]:R[1],L[2]:R[2]] \
= geom.microstructure[l[0]:r[0],l[1]:r[1],l[2]:r[2]]
new[l[0]:r[0],l[1]:r[1],l[2]:r[2]] = geom.microstructure[L[0]:R[0],L[1]:R[1],L[2]:R[2]]
damask.util.croak(geom.update(new,origin=(0,0,0),rescale=True))
damask.util.croak(geom.update(canvas,origin=origin+offset*size/grid,rescale=True))
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
if name is None: