DAMASK_EICMD/processing/post/growTable.py

45 lines
1.2 KiB
Python
Raw Normal View History

2019-06-14 02:44:40 +05:30
#!/usr/bin/env python3
import os
import sys
from optparse import OptionParser
import numpy as np
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 [ASCIItable(s)]', description = """
Append data of ASCIItable(s) row-wise.
""", version = scriptID)
parser.add_option('-a', '--add','--table',
dest = 'table',
action = 'extend', metavar = '<string LIST>',
help = 'tables to add')
(options,filenames) = parser.parse_args()
2019-12-23 02:53:48 +05:30
if filenames == []: filenames = [None]
2019-06-14 02:44:40 +05:30
if options.table is None:
2019-12-23 02:53:48 +05:30
parser.error('no table specified.')
2019-06-14 02:44:40 +05:30
for name in filenames:
2019-12-23 02:53:48 +05:30
damask.util.report(scriptName,name)
2019-06-14 02:44:40 +05:30
2019-12-23 02:53:48 +05:30
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
2019-06-14 02:44:40 +05:30
2019-12-23 02:53:48 +05:30
for growTable in options.table:
table2 = damask.Table.from_ASCII(growTable)
table.append(table2)
2019-06-14 02:44:40 +05:30
2019-12-23 02:53:48 +05:30
table.to_ASCII(sys.stdout if name is None else name)