From 264afe00f9f2f23370aad41c63ce5704c5c9a9ac Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 23 Dec 2019 17:52:35 +0100 Subject: [PATCH] using central functionality --- processing/post/averageDown.py | 18 ++++------------- processing/post/blowUp.py | 36 ++++++++++------------------------ 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/processing/post/averageDown.py b/processing/post/averageDown.py index d4e2a3529..c7586ed94 100755 --- a/processing/post/averageDown.py +++ b/processing/post/averageDown.py @@ -122,20 +122,10 @@ for name in filenames: #--- generate grid -------------------------------------------------------------------------------- - x = (0.5 + shift[0] + np.arange(packedGrid[0],dtype=float))/packedGrid[0]*size[0] - y = (0.5 + shift[1] + np.arange(packedGrid[1],dtype=float))/packedGrid[1]*size[1] - z = (0.5 + shift[2] + np.arange(packedGrid[2],dtype=float))/packedGrid[2]*size[2] + coords = damask.grid_filters.cell_coord0(packedGrid,size,shift/packedGrid*size+origin) + table.data[:,table.label_indexrange(options.pos)] = coords.reshape((-1,3)) - xx = np.tile( x, packedGrid[1]* packedGrid[2]) - yy = np.tile(np.repeat(y,packedGrid[0] ),packedGrid[2]) - zz = np.repeat(z,packedGrid[0]*packedGrid[1]) - table.data[:,table.label_indexrange(options.pos)] = np.squeeze(np.dstack((xx,yy,zz))) - -# ------------------------------------------ output result ----------------------------------------- - - table.data_writeArray() - # ------------------------------------------ output finalization ----------------------------------- - - table.close() # close ASCII tables + table.data_writeArray() + table.close() diff --git a/processing/post/blowUp.py b/processing/post/blowUp.py index 32cc1909d..47abc187a 100755 --- a/processing/post/blowUp.py +++ b/processing/post/blowUp.py @@ -4,6 +4,7 @@ import os import sys from optparse import OptionParser +from scipy import ndimage import numpy as np import damask @@ -94,30 +95,13 @@ for name in filenames: table.head_write() # ------------------------------------------ process data ------------------------------------------- + table.data_readArray() + data = table.data.reshape(tuple(grid)+(-1,)) + table.data = ndimage.interpolation.zoom(data,tuple(packing)+(1,),order=0,mode='nearest').reshape((outSize.prod(),-1)) + coords = damask.grid_filters.cell_coord0(outSize,size,origin) + table.data[:,table.label_indexrange(options.pos)] = coords.reshape((-1,3)) + table.data[:,table.label_index('elem')] = np.arange(1,outSize.prod()+1) - data = np.zeros(outSize.tolist()+[len(table.labels(raw = True))]) - p = np.zeros(3,'i') - - for p[2] in range(grid[2]): - for p[1] in range(grid[1]): - for p[0] in range(grid[0]): - d = p*packing - table.data_read() - data[d[0]:d[0]+packing[0], - d[1]:d[1]+packing[1], - d[2]:d[2]+packing[2], - : ] = np.tile(np.array(table.data_asFloat(),'d'),packing.tolist()+[1]) # tile to match blowUp voxel size - elementSize = size/grid/packing - elem = 1 - for c in range(outSize[2]): - for b in range(outSize[1]): - for a in range(outSize[0]): - 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 - elem += 1 - -# ------------------------------------------ output finalization ----------------------------------- - - table.close() # close input ASCII table (works for stdin) +# ------------------------------------------ output finalization ----------------------------------- + table.data_writeArray() + table.close()