From 6e2ca7d59579d7e3ddfd166615db22cab461ed2d Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 13 Apr 2016 17:48:17 -0400 Subject: [PATCH] Removed hard requirement of 3D dataset. Fills in necessary dimensions. --- processing/post/vtk_rectilinearGrid.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/processing/post/vtk_rectilinearGrid.py b/processing/post/vtk_rectilinearGrid.py index a00d60185..38deabf3a 100755 --- a/processing/post/vtk_rectilinearGrid.py +++ b/processing/post/vtk_rectilinearGrid.py @@ -38,9 +38,9 @@ parser.set_defaults(position ='ipinitialcoord', if filenames == []: filenames = [None] for name in filenames: - try: - table = damask.ASCIItable(name = name, - buffered = False, readonly = True) + try: table = damask.ASCIItable(name = name, + buffered = False, + readonly = True) except: continue damask.util.report(scriptName,name) @@ -48,10 +48,13 @@ for name in filenames: table.head_read() - errors = [] - if table.label_dimension(options.position) != 3: - errors.append('coordinates {} are not a vector.'.format(options.position)) + remarks = [] + errors = [] + coordDim = table.label_dimension(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 != []: damask.util.croak(errors) table.close(dismiss=True) @@ -60,6 +63,11 @@ for name in filenames: # --------------- figure out size and grid --------------------------------------------------------- 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)] if options.mode == 'cell':