From f982f428398a67b85b4484d75074f0ee955860b9 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 12 Aug 2015 22:14:19 +0000 Subject: [PATCH] convert TSL/EDAX ang file format to proper ASCIItable. --- processing/misc/ang_toTable.py | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 processing/misc/ang_toTable.py diff --git a/processing/misc/ang_toTable.py b/processing/misc/ang_toTable.py new file mode 100755 index 000000000..4b1c475c0 --- /dev/null +++ b/processing/misc/ang_toTable.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 no BOM -*- + +import os,sys,string,vtk +import numpy as np +from optparse import OptionParser +import damask + +scriptID = string.replace('$Id$','\n','\\n') +scriptName = os.path.splitext(scriptID.split()[1])[0] + + +#-------------------------------------------------------------------------------------------------- +# MAIN +#-------------------------------------------------------------------------------------------------- + +parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile[s]]', description = """ +Convert TSL/EDAX *.ang file to ASCIItable + +""", version = scriptID) + +(options, filenames) = parser.parse_args() + +# --- loop over input files ------------------------------------------------------------------------- + +if filenames == []: filenames = [None] + +for name in filenames: + try: + table = damask.ASCIItable(name = name, + outname = os.path.splitext(name)[0]+'.txt' if name else name, + buffered = False, labeled = False) + except: continue + table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else '')) + +# --- interpret header ----------------------------------------------------------------------------- + + table.head_read() + +# --- read comments -------------------------------------------------------------------------------- + + table.info_clear() + while table.data_read(advance = False) and table.line.startswith('#'): # cautiously (non-progressing) read header + table.info_append(table.line) # add comment to info part + table.data_read() # wind forward + + table.labels_clear() + table.labels_append(['1_Euler','2_Euler','3_Euler', + '1_pos','2_pos', + 'IQ','CI','PhaseID','Intensity','Fit', + ], # labels according to OIM Analysis 7.2 Manual, p 403 (of 517) + reset = True) + +# ------------------------------------------ assemble header --------------------------------------- + + table.head_write() + +#--- write remainder of data file ------------------------------------------------------------------ + + outputAlive = True + while outputAlive and table.data_read(): + outputAlive = table.data_write() + +# ------------------------------------------ finalize output --------------------------------------- + + table.close()