2016-07-18 23:05:35 +05:30
|
|
|
#!/usr/bin/env python2.7
|
2015-08-13 03:44:19 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
|
|
|
|
2016-03-03 19:23:55 +05:30
|
|
|
import os
|
2015-08-13 03:44:19 +05:30
|
|
|
from optparse import OptionParser
|
|
|
|
import damask
|
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2015-08-13 03:44:19 +05:30
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
2016-08-11 17:18:15 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [angfile[s]]', description = """
|
2015-08-13 03:44:19 +05:30
|
|
|
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
|
2016-08-11 17:18:15 +05:30
|
|
|
damask.util.report(scriptName,name)
|
2015-08-13 03:44:19 +05:30
|
|
|
|
|
|
|
# --- 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',
|
2016-03-03 19:23:55 +05:30
|
|
|
], # OIM Analysis 7.2 Manual, p 403 (of 517)
|
2015-08-13 03:44:19 +05:30
|
|
|
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()
|