using central functionality
This commit is contained in:
parent
644967329f
commit
db14baec41
|
@ -25,56 +25,19 @@ parser.add_option('-a', '--add','--table',
|
||||||
help = 'tables to add')
|
help = 'tables to add')
|
||||||
|
|
||||||
(options,filenames) = parser.parse_args()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
||||||
if options.table is None:
|
|
||||||
parser.error('no table specified.')
|
|
||||||
|
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
|
if options.table is None:
|
||||||
|
parser.error('no table specified.')
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
try: table = damask.ASCIItable(name = name,
|
damask.util.report(scriptName,name)
|
||||||
buffered = False)
|
|
||||||
except: continue
|
|
||||||
|
|
||||||
damask.util.report(scriptName,name)
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||||
|
|
||||||
tables = []
|
for addTable in options.table:
|
||||||
for addTable in options.table:
|
table2 = damask.Table.from_ASCII(addTable)
|
||||||
try: tables.append(damask.ASCIItable(name = addTable,
|
table2.data = table2.data[:table.data.shape[0]]
|
||||||
buffered = False,
|
table.join(table2)
|
||||||
readonly = True)
|
|
||||||
)
|
|
||||||
except: continue
|
|
||||||
|
|
||||||
# ------------------------------------------ read headers ------------------------------------------
|
table.to_ASCII(sys.stdout if name is None else name)
|
||||||
|
|
||||||
table.head_read()
|
|
||||||
for addTable in tables: addTable.head_read()
|
|
||||||
|
|
||||||
# ------------------------------------------ assemble header --------------------------------------
|
|
||||||
|
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
|
||||||
|
|
||||||
for addTable in tables: table.labels_append(addTable.labels(raw = True)) # extend ASCII header with new labels
|
|
||||||
|
|
||||||
table.head_write()
|
|
||||||
|
|
||||||
# ------------------------------------------ process data ------------------------------------------
|
|
||||||
|
|
||||||
outputAlive = True
|
|
||||||
while outputAlive and table.data_read():
|
|
||||||
for addTable in tables:
|
|
||||||
outputAlive = addTable.data_read() # read next table's data
|
|
||||||
if not outputAlive: break
|
|
||||||
table.data_append(addTable.data) # append to master table
|
|
||||||
if outputAlive:
|
|
||||||
outputAlive = table.data_write() # output processed line
|
|
||||||
|
|
||||||
# ------------------------------------------ output finalization -----------------------------------
|
|
||||||
|
|
||||||
table.close() # close ASCII tables
|
|
||||||
for addTable in tables:
|
|
||||||
addTable.close()
|
|
||||||
|
|
|
@ -27,53 +27,18 @@ parser.add_option('-a', '--add','--table',
|
||||||
help = 'tables to add')
|
help = 'tables to add')
|
||||||
|
|
||||||
(options,filenames) = parser.parse_args()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
||||||
if options.table is None:
|
|
||||||
parser.error('no table specified.')
|
|
||||||
|
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
|
if options.table is None:
|
||||||
|
parser.error('no table specified.')
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
try: table = damask.ASCIItable(name = name,
|
damask.util.report(scriptName,name)
|
||||||
buffered = False)
|
|
||||||
except: continue
|
|
||||||
|
|
||||||
damask.util.report(scriptName,name)
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||||
|
|
||||||
tables = []
|
for growTable in options.table:
|
||||||
for addTable in options.table:
|
table2 = damask.Table.from_ASCII(growTable)
|
||||||
try: tables.append(damask.ASCIItable(name = addTable,
|
table.append(table2)
|
||||||
buffered = False,
|
|
||||||
readonly = True)
|
|
||||||
)
|
|
||||||
except: continue
|
|
||||||
|
|
||||||
# ------------------------------------------ read headers ------------------------------------------
|
table.to_ASCII(sys.stdout if name is None else name)
|
||||||
|
|
||||||
table.head_read()
|
|
||||||
for addTable in tables: addTable.head_read()
|
|
||||||
|
|
||||||
# ------------------------------------------ assemble header --------------------------------------
|
|
||||||
|
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
|
||||||
|
|
||||||
table.head_write()
|
|
||||||
|
|
||||||
# ------------------------------------------ process data ------------------------------------------
|
|
||||||
|
|
||||||
table.data_readArray()
|
|
||||||
data = table.data
|
|
||||||
for addTable in tables:
|
|
||||||
addTable.data_readArray(table.labels(raw = True))
|
|
||||||
data = np.vstack((data,addTable.data))
|
|
||||||
table.data = data
|
|
||||||
table.data_writeArray()
|
|
||||||
|
|
||||||
# ------------------------------------------ output finalization -----------------------------------
|
|
||||||
|
|
||||||
table.close() # close ASCII tables
|
|
||||||
for addTable in tables:
|
|
||||||
addTable.close()
|
|
||||||
|
|
Loading…
Reference in New Issue