2016-07-18 23:05:35 +05:30
|
|
|
#!/usr/bin/env python2.7
|
2016-03-24 22:25:15 +05:30
|
|
|
# -*- 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
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
2016-08-11 17:18:15 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [file[s]]', description = """
|
2016-03-27 00:29:05 +05:30
|
|
|
Adds header to OIM grain file to make it accesible as ASCII table
|
2016-03-24 22:25:15 +05:30
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
|
|
|
parser.add_option('-l', '--labels',
|
|
|
|
dest = 'labels',
|
2016-05-13 12:58:54 +05:30
|
|
|
action = 'extend', metavar = '<string LIST>',
|
2016-04-25 16:27:38 +05:30
|
|
|
help = 'lables of requested columns')
|
2016-03-24 22:25:15 +05:30
|
|
|
|
2016-04-25 16:27:38 +05:30
|
|
|
parser.set_defaults(labels = ['1_euler','2_euler','3_euler',
|
2016-03-24 22:25:15 +05:30
|
|
|
'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)])
|
2016-04-11 23:25:55 +05:30
|
|
|
|
2016-03-24 22:25:15 +05:30
|
|
|
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()
|
2016-03-27 00:29:05 +05:30
|
|
|
|
|
|
|
# --- output finalization --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
table.close() # close ASCII table
|