restored Martin's logic, not clear why seemed to be broken with PE's former tests...

This commit is contained in:
Philip Eisenlohr 2019-06-03 14:42:35 -04:00
parent 962883d0dc
commit bffeaa980d
1 changed files with 13 additions and 15 deletions

View File

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