update to changes in Result class

This commit is contained in:
Martin Diehl 2020-03-17 01:49:47 +01:00
parent 1e1fb35e14
commit 17e7b32b31
2 changed files with 104 additions and 115 deletions

View File

@ -36,19 +36,14 @@ if options.con is None: options.con=[]
# --- loop over input files ------------------------------------------------------------------------ # --- loop over input files ------------------------------------------------------------------------
for filename in options.filenames: for filename in options.filenames:
results = damask.DADF5(filename) results = damask.Result(filename)
if not results.structured: continue if not results.structured: continue
if results.version_major == 0 and results.version_minor >= 5:
coords = damask.grid_filters.cell_coord0(results.grid,results.size,results.origin) coords = damask.grid_filters.cell_coord0(results.grid,results.size,results.origin)
else:
coords = damask.grid_filters.cell_coord0(results.grid,results.size)
N_digits = int(np.floor(np.log10(int(results.increments[-1][3:]))))+1 N_digits = int(np.floor(np.log10(int(results.increments[-1][3:]))))+1
N_digits = 5 # hack to keep test intact N_digits = 5 # hack to keep test intact
for i,inc in enumerate(results.iter_visible('increments')): for inc in damask.util.show_progress(results.iter_visible('increments'),len(results.increments)):
print('Output step {}/{}'.format(i+1,len(results.increments)))
table = damask.Table(np.ones(np.product(results.grid),dtype=int)*int(inc[3:]),{'inc':(1,)}) table = damask.Table(np.ones(np.product(results.grid),dtype=int)*int(inc[3:]),{'inc':(1,)})
table.add('pos',coords.reshape((-1,3))) table.add('pos',coords.reshape((-1,3)))

View File

@ -55,15 +55,10 @@ parser.add_argument('-d','--dir', dest='dir',default='postProc',metavar='string'
options = parser.parse_args() options = parser.parse_args()
# --------------------------------------------------------------------
# loop over input files
for filename in options.filenames: for filename in options.filenames:
f = damask.DADF5(filename) #DAMASK output file f = damask.Result(filename)
for increment in options.inc: f.pick('increments',options.inc)
f.set_by_increment(increment,increment) for increment in damask.util.show_progress(f.iter_selection('increments'),len(f.selection['increments'])):
if len(f.visible['increments']) == 0:
continue
#-------output file creation------------------------------------- #-------output file creation-------------------------------------
dirname = os.path.abspath(os.path.join(os.path.dirname(filename),options.dir)) dirname = os.path.abspath(os.path.join(os.path.dirname(filename),options.dir))
try: try:
@ -77,7 +72,6 @@ for filename in options.filenames:
o.attrs['FileVersion'] = '7.0' o.attrs['FileVersion'] = '7.0'
#----------------------------------------------------------------- #-----------------------------------------------------------------
for g in ['DataContainerBundles','Pipeline']: # empty groups (needed) for g in ['DataContainerBundles','Pipeline']: # empty groups (needed)
o.create_group(g) o.create_group(g)