using util function where possible, ensuring python3 compatibility
This commit is contained in:
parent
f928bd5e5b
commit
0438b7113a
|
@ -120,15 +120,15 @@ for name in filenames:
|
|||
outputAlive = True
|
||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||
if inputtype == 'eulers':
|
||||
o = damask.Orientation(Eulers = np.array(map(float,table.data[column:column+3]))*toRadians)
|
||||
o = damask.Orientation(Eulers = np.array(list(map(float,table.data[column:column+3])))*toRadians)
|
||||
elif inputtype == 'matrix':
|
||||
o = damask.Orientation(matrix = np.array(map(float,table.data[column:column+9])).reshape(3,3).transpose())
|
||||
o = damask.Orientation(matrix = np.array(list(map(float,table.data[column:column+9]))).reshape(3,3).transpose())
|
||||
elif inputtype == 'frame':
|
||||
o = damask.Orientation(matrix = np.array(map(float,table.data[column[0]:column[0]+3] + \
|
||||
o = damask.Orientation(matrix = np.array(list(map(float,table.data[column[0]:column[0]+3] + \
|
||||
table.data[column[1]:column[1]+3] + \
|
||||
table.data[column[2]:column[2]+3])).reshape(3,3))
|
||||
table.data[column[2]:column[2]+3]))).reshape(3,3))
|
||||
elif inputtype == 'quaternion':
|
||||
o = damask.Orientation(quaternion = np.array(map(float,table.data[column:column+4])))
|
||||
o = damask.Orientation(quaternion = np.array(list(map(float,table.data[column:column+4]))))
|
||||
|
||||
rotatedPole = o.quaternion*pole # rotate pole according to crystal orientation
|
||||
(x,y) = rotatedPole[0:2]/(1.+abs(pole[2])) # stereographic projection
|
||||
|
|
|
@ -76,7 +76,6 @@ for name in filenames:
|
|||
remarks = []
|
||||
|
||||
if table.label_dimension(options.pos) != 3: errors.append('coordinates {} are not a vector.'.format(options.pos))
|
||||
else: colCoord = table.label_index(options.pos)
|
||||
|
||||
if remarks != []: damask.util.croak(remarks)
|
||||
if errors != []:
|
||||
|
@ -94,14 +93,7 @@ for name in filenames:
|
|||
table.data_readArray()
|
||||
|
||||
if (any(options.grid) == 0 or any(options.size) == 0.0):
|
||||
coords = [np.unique(table.data[:,colCoord+i]) for i in range(3)]
|
||||
mincorner = np.array(map(min,coords))
|
||||
maxcorner = np.array(map(max,coords))
|
||||
grid = np.array(map(len,coords),'i')
|
||||
size = grid/np.maximum(np.ones(3,'d'), grid-1.0) * (maxcorner-mincorner) # size from edge to edge = dim * n/(n-1)
|
||||
size = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 set to smallest among other spacings
|
||||
delta = size/np.maximum(np.ones(3,'d'), grid)
|
||||
origin = mincorner - 0.5*delta # shift from cell center to corner
|
||||
grid,size = damask.util.coordGridAndSize(table.data[:,table.label_indexrange(options.pos)])
|
||||
|
||||
else:
|
||||
grid = np.array(options.grid,'i')
|
||||
|
@ -129,7 +121,6 @@ for name in filenames:
|
|||
|
||||
#--- generate grid --------------------------------------------------------------------------------
|
||||
|
||||
if colCoord:
|
||||
x = (0.5 + shift[0] + np.arange(packedGrid[0],dtype=float))/packedGrid[0]*size[0] + origin[0]
|
||||
y = (0.5 + shift[1] + np.arange(packedGrid[1],dtype=float))/packedGrid[1]*size[1] + origin[1]
|
||||
z = (0.5 + shift[2] + np.arange(packedGrid[2],dtype=float))/packedGrid[2]*size[2] + origin[2]
|
||||
|
@ -138,7 +129,7 @@ for name in filenames:
|
|||
yy = np.tile(np.repeat(y,packedGrid[0] ),packedGrid[2])
|
||||
zz = np.repeat(z,packedGrid[0]*packedGrid[1])
|
||||
|
||||
table.data[:,colCoord:colCoord+3] = np.squeeze(np.dstack((xx,yy,zz)))
|
||||
table.data[:,table.label_indexragen(options.pos)] = np.squeeze(np.dstack((xx,yy,zz)))
|
||||
|
||||
# ------------------------------------------ output result -----------------------------------------
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ for name in filenames:
|
|||
remarks = []
|
||||
|
||||
if table.label_dimension(options.pos) != 3: errors.append('coordinates "{}" are not a vector.'.format(options.pos))
|
||||
else: colCoord = table.label_index(options.pos)
|
||||
|
||||
colElem = table.label_index('elem')
|
||||
|
||||
|
@ -79,12 +78,7 @@ for name in filenames:
|
|||
table.data_readArray(options.pos)
|
||||
table.data_rewind()
|
||||
|
||||
coords = [np.unique(table.data[:,i]) for i in range(3)]
|
||||
mincorner = np.array(map(min,coords))
|
||||
maxcorner = np.array(map(max,coords))
|
||||
grid = np.array(map(len,coords),'i')
|
||||
size = grid/np.maximum(np.ones(3,'d'), grid-1.0) * (maxcorner-mincorner) # size from edge to edge = dim * n/(n-1)
|
||||
size = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 set to smallest among other spacings
|
||||
grid,size = damask.util.coordGridAndSize(table.data)
|
||||
|
||||
packing = np.array(options.packing,'i')
|
||||
outSize = grid*packing
|
||||
|
@ -113,7 +107,7 @@ for name in filenames:
|
|||
for c in range(outSize[2]):
|
||||
for b in range(outSize[1]):
|
||||
for a in range(outSize[0]):
|
||||
data[a,b,c,colCoord:colCoord+3] = [a+0.5,b+0.5,c+0.5]*elementSize
|
||||
data[a,b,c,table.label_indexrange(options.pos)] = [a+0.5,b+0.5,c+0.5]*elementSize
|
||||
if colElem != -1: data[a,b,c,colElem] = elem
|
||||
table.data = data[a,b,c,:].tolist()
|
||||
outputAlive = table.data_write() # output processed line
|
||||
|
|
Loading…
Reference in New Issue