From 04d2148e61f624f96a3b7ef49ab2518c3e34c47a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 24 Mar 2016 17:55:15 +0100 Subject: [PATCH] will replace geom_fromAng (in combination with geom_fromTable) --- processing/pre/table_fromOIMgrainFile.py | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 processing/pre/table_fromOIMgrainFile.py diff --git a/processing/pre/table_fromOIMgrainFile.py b/processing/pre/table_fromOIMgrainFile.py new file mode 100755 index 000000000..c730c8892 --- /dev/null +++ b/processing/pre/table_fromOIMgrainFile.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 no BOM -*- + +import os,sys +from optparse import OptionParser +import damask + +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 = """ +Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line). + +""", version = scriptID) + +parser.add_option('-l', '--labels', + dest = 'labels', + help = 'output geom file with one-dimensional data arrangement') + +parser.set_defaults(labels = ['1_eulerangles','1_eulerangles','1_eulerangles', + '1_pos','2_pos', 'IQ', 'CI', 'Fit', 'GrainID',], + ) + +(options, filenames) = parser.parse_args() + +# --- loop over input files ------------------------------------------------------------------------- + +if filenames == []: filenames = [None] + +for name in filenames: + try: + table = damask.ASCIItable(name = name, + buffered = False, + labeled = False) + except: continue + damask.util.report(scriptName,name) + table.head_read() + data = [] + while table.data_read(): + data.append(table.data[0:len(options.labels)]) + + table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) + table.labels_append(options.labels) + table.head_write() + for i in data: + table.data = i + table.data_write()