From 868fccc4959652baff7f400a5b095a336e47d90f Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 8 Oct 2017 22:19:47 +0200 Subject: [PATCH 1/5] [skip ci] updated version information after successful test of v2.0.1-948-g14bf4d5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 20ae414e7..0b5b13deb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-941-g05bb3c1 +v2.0.1-948-g14bf4d5 From 26b8788c065fee3650fdb618ac238ad55f63f298 Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 20 Oct 2017 09:36:57 +0200 Subject: [PATCH 2/5] =?UTF-8?q?script=20to=20colocate=202D=20ang=20files?= =?UTF-8?q?=20into=20one=20=C2=A7D=20file=20and=20optionally=20creat=20geo?= =?UTF-8?q?metry=20and=20Paraview=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- processing/pre/3DRVEfrom2Dang.py | 119 +++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 processing/pre/3DRVEfrom2Dang.py diff --git a/processing/pre/3DRVEfrom2Dang.py b/processing/pre/3DRVEfrom2Dang.py new file mode 100644 index 000000000..93507afdc --- /dev/null +++ b/processing/pre/3DRVEfrom2Dang.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python2.7 +# -*- coding: UTF-8 no BOM -*- + +import os,sys,math +import numpy as np +from optparse import OptionParser +import damask +import pipes + +scriptName = os.path.splitext(os.path.basename(__file__))[0] +scriptID = ' '.join([scriptName,damask.version]) + +# -------------------------------------------------------------------- +# MAIN +# -------------------------------------------------------------------- + +parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', + description ='generate 3D RVE from .ang files of EBSD slices .', + version = scriptID) + +parser.add_option('--offset', + dest='offset', + type='float', + help='offset of EBSD slices [%default]', + metavar='float') +parser.add_option('--outname', + dest='outName', + type='string', + help='output file name [%default]', metavar='string') +parser.add_option('--vtr', + action="store_true", + dest='vtr') +parser.add_option('--geom', + action="store_true", + dest='geom') +parser.set_defaults(offset = 1.0, + outName = 'RVE3D') + +(options,filenames) = parser.parse_args() + +numFiles = len(filenames) +formatwidth = 1+int(math.log10(numFiles)) + +# copy original files to tmp files to not alter originals +for i in range(numFiles): + sliceID = 'slice' + str(i).zfill(formatwidth) + '.tmp' + strCommand = 'cp ' + pipes.quote(filenames[i]) + ' ' + sliceID + os.system(strCommand) + +# modify tmp files +print('Add z-coordinates') +for i in range(numFiles): + sliceID = 'slice' + str(i).zfill(formatwidth) + '.tmp' + strCommand = 'OIMgrainFile_toTable ' + sliceID + os.system(strCommand) + strCommand = 'addCalculation --label 3Dpos --formula "np.array(#pos#.tolist()+[' + str(i*options.offset) + '])" ' + sliceID + os.system(strCommand) + +# join temp files into one + +print('\n Colocate files') +fileOut = open(options.outName + '.ang','w') + +# take header information from 1st file +sliceID = 'slice' + str(0).zfill(formatwidth) + '.tmp' +fileRead = open(sliceID) +data = fileRead.readlines() +fileRead.close() +headerLines = int(data[0].split()[0]) +fileOut.write(str(headerLines+1) + '\t header\n') +for line in data[1:headerLines]: + fileOut.write(line) +fileOut.write(scriptID + '\t' + ' '.join(sys.argv[1:]) + '\n') +for line in data[headerLines:]: + fileOut.write(line) + +# append other files content without header +for i in range(numFiles-1): + sliceID = 'slice' + str(i+1).zfill(formatwidth) + '.tmp' + fileRead = open(sliceID) + data = fileRead.readlines() + fileRead.close() + headerLines = int(data[0].split()[0]) + for line in data[headerLines+1:]: + fileOut.write(line) +fileOut.close() + +# tidy up and add phase column +print('\n Remove temp data and add phase info') +strCommand = 'filterTable --black pos ' + options.outName + '.ang' +os.system(strCommand) +strCommand = 'reLabel --label 3Dpos --substitute pos ' + options.outName + '.ang' +os.system(strCommand) +strCommand = 'addCalculation -l phase -f 1 ' + options.outName + '.ang' +os.system(strCommand) + + +# create geom file when asked for +if options.geom: + print('\n Build geometry file') + strCommand = 'geom_fromTable --phase phase --eulers euler --coordinates pos ' + pipes.quote(options.outName) + '.ang' + os.system(strCommand) + +# create paraview file when asked for + +if options.vtr: + print('\n Build Paraview file') + strCommand = 'addIPFcolor --eulers euler --pole 0.0 0.0 1.0 ' + options.outName + '.ang' + os.system(strCommand) + strCommand = 'vtk_rectilinearGrid ' + pipes.quote(options.outName) + '.ang' + os.system(strCommand) + os.rename(pipes.quote(options.outName) + '_pos(cell)'+'.vtr', pipes.quote(options.outName) + '.vtr') + strCommand = 'vtk_addRectilinearGridData --vtk '+ pipes.quote(options.outName) + '.vtr --color IPF_001_cubic ' + pipes.quote(options.outName) + '.ang' + os.system(strCommand) + +# delete tmp files +for i in range(numFiles): + sliceID = 'slice' + str(i).zfill(formatwidth) + '.tmp' + os.remove(sliceID) \ No newline at end of file From 0c24f113c1910f41a133e649cdf98d38a541fc33 Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 20 Oct 2017 10:14:15 +0200 Subject: [PATCH 3/5] split overlong line --- processing/pre/3DRVEfrom2Dang.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/processing/pre/3DRVEfrom2Dang.py b/processing/pre/3DRVEfrom2Dang.py index 93507afdc..c618c948b 100644 --- a/processing/pre/3DRVEfrom2Dang.py +++ b/processing/pre/3DRVEfrom2Dang.py @@ -110,7 +110,8 @@ if options.vtr: strCommand = 'vtk_rectilinearGrid ' + pipes.quote(options.outName) + '.ang' os.system(strCommand) os.rename(pipes.quote(options.outName) + '_pos(cell)'+'.vtr', pipes.quote(options.outName) + '.vtr') - strCommand = 'vtk_addRectilinearGridData --vtk '+ pipes.quote(options.outName) + '.vtr --color IPF_001_cubic ' + pipes.quote(options.outName) + '.ang' + strCommand = 'vtk_addRectilinearGridData --vtk '+ pipes.quote(options.outName) + '.vtr --color IPF_001_cubic '\ + + pipes.quote(options.outName) + '.ang' os.system(strCommand) # delete tmp files From eddc2a6acfccee282288872f666e0b137133651e Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 20 Oct 2017 10:17:08 +0200 Subject: [PATCH 4/5] numpy actually not needed --- processing/pre/3DRVEfrom2Dang.py | 1 - 1 file changed, 1 deletion(-) diff --git a/processing/pre/3DRVEfrom2Dang.py b/processing/pre/3DRVEfrom2Dang.py index c618c948b..58607c4be 100644 --- a/processing/pre/3DRVEfrom2Dang.py +++ b/processing/pre/3DRVEfrom2Dang.py @@ -2,7 +2,6 @@ # -*- coding: UTF-8 no BOM -*- import os,sys,math -import numpy as np from optparse import OptionParser import damask import pipes From 40bbb9ddb2cf98e12dc39a27502b8ea3801fd7f5 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 20 Oct 2017 19:38:55 +0200 Subject: [PATCH 5/5] [skip ci] updated version information after successful test of v2.0.1-960-geddc2a6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e661caf3b..6a81d6c78 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-946-g5011e20 +v2.0.1-960-geddc2a6