changed header in seeds file from 'x,y,z' to '1..3_coords'.

scripts now use the header information and do not rely on coordinates being in the first three columns
This commit is contained in:
Martin Diehl 2015-04-22 18:44:54 +00:00
parent 1f809f9d73
commit 2e6bbe887e
6 changed files with 47 additions and 52 deletions

View File

@ -1,8 +1,8 @@
4 header 4 header
resolution a 16 b 16 c 16 grid a 16 b 16 c 16
grains 20 microstructures 20
random seed 0 random seed 0
x y z phi1 Phi phi2 1_coords 2_coords 3_coords phi1 Phi phi2
0.375488 0.161813 0.891040 197.572861 16.816409 129.422844 0.375488 0.161813 0.891040 197.572861 16.816409 129.422844
0.187988 0.849313 0.953540 257.468172 53.250534 157.331503 0.187988 0.849313 0.953540 257.468172 53.250534 157.331503
0.750488 0.349313 0.953540 216.994815 94.418518 251.147231 0.750488 0.349313 0.953540 216.994815 94.418518 251.147231

View File

@ -105,26 +105,20 @@ for file in files:
table = damask.ASCIItable(file['input'],file['output'],buffered = False) table = damask.ASCIItable(file['input'],file['output'],buffered = False)
table.head_read() table.head_read()
labels = ['x','y','z'] coordsCol = table.labels_index('1_coords')
index = 0 if coordsCol < 0:
coordsCol = table.labels_index('x') # try if file is in legacy format
if coordsCol < 0:
file['croak'].write('column 1_coords/x not found...\n')
continue
eulerCol = table.labels_index('phi1') eulerCol = table.labels_index('phi1')
hasEulers = np.all(table.labels_index(['phi1','Phi','phi2'])) != -1 hasEulers = np.all(table.labels_index(['phi1','Phi','phi2'])) != -1
grainCol = table.labels_index('microstructure') grainCol = table.labels_index('microstructure')
hasGrains = grainCol != -1 hasGrains = grainCol != -1
if hasEulers: table.data_readArray()
labels += ['phi1','Phi','phi2'] coords = table.data[:,coordsCol:coordsCol+3]
index += 3
if hasGrains:
labels += ['microstructure']
index += 1
table.data_readArray(labels)
coords = table.data[:,0:3]
eulers = table.data[:,eulerCol:eulerCol+3] if hasEulers else np.zeros(3*len(coords)) eulers = table.data[:,eulerCol:eulerCol+3] if hasEulers else np.zeros(3*len(coords))
grain = table.data[:,grainCol] if hasGrains else 1+np.arange(len(eulers)) grain = table.data[:,grainCol] if hasGrains else 1+np.arange(len(eulers))
grainIDs = np.unique(grain).astype('i') grainIDs = np.unique(grain).astype('i')
@ -185,8 +179,8 @@ for file in files:
continue continue
#--- prepare data --------------------------------------------------------------------------------- #--- prepare data ---------------------------------------------------------------------------------
coords = (coords*info['size']).transpose() coords = (coords*info['size']).T
eulers = eulers.transpose() eulers = eulers.T
#--- switch according to task --------------------------------------------------------------------- #--- switch according to task ---------------------------------------------------------------------
if options.config: # write config file if options.config: # write config file

View File

@ -61,17 +61,18 @@ for file in files:
table = damask.ASCIItable(file['input'],file['output']) table = damask.ASCIItable(file['input'],file['output'])
table.head_read() table.head_read()
labels = ['x','y','z'] coordsCol = table.labels_index('1_coords')
if coordsCol < 0:
coordsCol = table.labels_index('x') # try if file is in legacy format
if coordsCol < 0:
file['croak'].write('column 1_coords/x not found...\n')
continue
grainCol = table.labels_index('microstructure') grainCol = table.labels_index('microstructure')
hasGrains = grainCol != -1 hasGrains = grainCol != -1
if hasGrains: table.data_readArray()
labels += ['microstructure'] coords = table.data[:,coordsCol:coordsCol+3]
table.data_readArray(labels)
coords = table.data[:,0:3]
grain = table.data[:,grainCol] if hasGrains else 1+np.arange(len(coords)) grain = table.data[:,grainCol] if hasGrains else 1+np.arange(len(coords))
grainIDs = np.unique(grain).astype('i') grainIDs = np.unique(grain).astype('i')

View File

@ -136,7 +136,7 @@ for file in files:
"origin\tx %i\ty %i\tz %i"%(info['origin'][0],info['origin'][1],info['origin'][2],), "origin\tx %i\ty %i\tz %i"%(info['origin'][0],info['origin'][1],info['origin'][2],),
] ]
table.labels_clear() table.labels_clear()
table.labels_append(['x','y','z','microstructure']) # implicitly switching label processing/writing on table.labels_append(['1_coords','2_coords','3_coords','microstructure']) # implicitly switching label processing/writing on
table.head_write() table.head_write()
#--- filtering of grain voxels ------------------------------------------------------------------------------------ #--- filtering of grain voxels ------------------------------------------------------------------------------------

View File

@ -81,7 +81,7 @@ header = ["5\theader",
"grid\ta {}\tb {}\tc {}".format(options.grid[0],options.grid[1],options.grid[2]), "grid\ta {}\tb {}\tc {}".format(options.grid[0],options.grid[1],options.grid[2]),
"microstructures\t{}".format(options.N), "microstructures\t{}".format(options.N),
"randomSeed\t{}".format(options.randomSeed), "randomSeed\t{}".format(options.randomSeed),
"x\ty\tz\tphi1\tPhi\tphi2", "1_coords\t2_coords\t3_coords\tphi1\tPhi\tphi2",
] ]
for line in header: for line in header:

View File

@ -144,7 +144,7 @@ for file in files:
map(str,boundingBox[1,:]-boundingBox[0,:])))))), map(str,boundingBox[1,:]-boundingBox[0,:])))))),
] ]
table.labels_clear() table.labels_clear()
table.labels_append(['x','y','z','microstructure']) # implicitly switching label processing/writing on table.labels_append(['1_coords','2_coords','3_coords','microstructure']) # implicitly switching label processing/writing on
table.head_write() table.head_write()
table.data_writeArray() table.data_writeArray()