now working with python 3
This commit is contained in:
parent
1f637a0c49
commit
784ae28dbb
|
@ -55,9 +55,9 @@ parser.set_defaults(canal = 25e-6,
|
||||||
|
|
||||||
(options,filename) = parser.parse_args()
|
(options,filename) = parser.parse_args()
|
||||||
|
|
||||||
if np.any(options.grid < 2):
|
if np.any(np.array(options.grid) < 2):
|
||||||
parser('invalid grid a b c.')
|
parser('invalid grid a b c.')
|
||||||
if np.any(options.size <= 0.0):
|
if np.any(np.array(options.size) <= 0.0):
|
||||||
parser('invalid size x y z.')
|
parser('invalid size x y z.')
|
||||||
|
|
||||||
# --- open input files ----------------------------------------------------------------------------
|
# --- open input files ----------------------------------------------------------------------------
|
||||||
|
@ -114,12 +114,8 @@ for y in range(info['grid'][1]):
|
||||||
info['microstructures'] += 1
|
info['microstructures'] += 1
|
||||||
|
|
||||||
#--- report ---------------------------------------------------------------------------------------
|
#--- report ---------------------------------------------------------------------------------------
|
||||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.report_geom(info,['grid','size','origin','homogenization','microstructures'])
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
|
||||||
'homogenization: %i'%info['homogenization'],
|
|
||||||
'microstructures: %i'%info['microstructures']])
|
|
||||||
# -------------------------------------- switch according to task ----------------------------------
|
|
||||||
formatwidth = 1+int(math.floor(math.log10(info['microstructures']-1)))
|
formatwidth = 1+int(math.floor(math.log10(info['microstructures']-1)))
|
||||||
header = [scriptID + ' ' + ' '.join(sys.argv[1:])]
|
header = [scriptID + ' ' + ' '.join(sys.argv[1:])]
|
||||||
header.append('<microstructure>')
|
header.append('<microstructure>')
|
||||||
|
|
|
@ -152,7 +152,7 @@ for name in filenames:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
table.data_readArray([options.pos] \
|
table.data_readArray([options.pos] \
|
||||||
+ ([label] if isinstance(label, types.StringTypes) else label) \
|
+ (label if isinstance(label, list) else [label]) \
|
||||||
+ ([options.phase] if options.phase else []))
|
+ ([options.phase] if options.phase else []))
|
||||||
|
|
||||||
if coordDim == 2:
|
if coordDim == 2:
|
||||||
|
@ -165,9 +165,9 @@ for name in filenames:
|
||||||
# --------------- figure out size and grid ---------------------------------------------------------
|
# --------------- figure out size and grid ---------------------------------------------------------
|
||||||
|
|
||||||
coords = [np.unique(table.data[:,i]) for i in range(3)]
|
coords = [np.unique(table.data[:,i]) for i in range(3)]
|
||||||
mincorner = np.array(map(min,coords))
|
mincorner = np.array(list(map(min,coords)))
|
||||||
maxcorner = np.array(map(max,coords))
|
maxcorner = np.array(list(map(max,coords)))
|
||||||
grid = np.array(map(len,coords),'i')
|
grid = np.array(list(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 = 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
|
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)
|
delta = size/np.maximum(np.ones(3,'d'), grid)
|
||||||
|
|
|
@ -15,8 +15,7 @@ scriptID = ' '.join([scriptName,damask.version])
|
||||||
def meshgrid2(*arrs):
|
def meshgrid2(*arrs):
|
||||||
"""Code inspired by http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d"""
|
"""Code inspired by http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d"""
|
||||||
arrs = tuple(reversed(arrs))
|
arrs = tuple(reversed(arrs))
|
||||||
arrs = tuple(arrs)
|
lens = np.array(list(map(len, arrs)))
|
||||||
lens = np.array(map(len, arrs))
|
|
||||||
dim = len(arrs)
|
dim = len(arrs)
|
||||||
ans = []
|
ans = []
|
||||||
for i, arr in enumerate(arrs):
|
for i, arr in enumerate(arrs):
|
||||||
|
|
Loading…
Reference in New Issue