Removed hard requirement of 3D dataset. Fills in necessary dimensions.

This commit is contained in:
Philip Eisenlohr 2016-04-13 17:48:17 -04:00
parent 284c2783e2
commit 6e2ca7d595
1 changed files with 14 additions and 6 deletions

View File

@ -38,9 +38,9 @@ parser.set_defaults(position ='ipinitialcoord',
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try: table = damask.ASCIItable(name = name,
table = damask.ASCIItable(name = name, buffered = False,
buffered = False, readonly = True) readonly = True)
except: continue except: continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
@ -48,10 +48,13 @@ for name in filenames:
table.head_read() table.head_read()
remarks = []
errors = [] errors = []
if table.label_dimension(options.position) != 3: coordDim = table.label_dimension(options.position)
errors.append('coordinates {} are not a vector.'.format(options.position)) if not 3 >= coordDim >= 1: errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.position))
elif coordDim < 3: remarks.append('appending {} dimensions to coordinates "{}"...'.format(3-coordDim,options.position))
if remarks != []: damask.util.croak(remarks)
if errors != []: if errors != []:
damask.util.croak(errors) damask.util.croak(errors)
table.close(dismiss=True) table.close(dismiss=True)
@ -60,6 +63,11 @@ for name in filenames:
# --------------- figure out size and grid --------------------------------------------------------- # --------------- figure out size and grid ---------------------------------------------------------
table.data_readArray(options.position) table.data_readArray(options.position)
if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape
if table.data.shape[1] < 3:
table.data = np.hstack((table.data,
np.zeros((table.data.shape[0],
3-table.data.shape[1]),dtype='f'))) # fill coords up to 3D with zeros
coords = [np.unique(table.data[:,i]) for i in xrange(3)] coords = [np.unique(table.data[:,i]) for i in xrange(3)]
if options.mode == 'cell': if options.mode == 'cell':