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)
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))
new = np.full(grid,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.clip(-offset, 0,np.minimum(n -offset,o))
R = np.clip(-offset+n,0,np.minimum(n*2-offset,o))
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]]
canvas = np.full(canvasgrid,options.fill if options.fill is not None
else np.nanmax(geom.microstructure)+1,geom.microstructure.dtype)
damask.util.croak(geom.update(new,origin=(0,0,0),rescale=True))
l = np.maximum( 0, offset)
r = np.minimum(grid,canvasgrid+offset)
L = l - offset
R = r - offset
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]]
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: