DAMASK_EICMD/processing/pre/geom_fromTable.py

58 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
2019-05-27 12:08:02 +05:30
import os
import sys
from optparse import OptionParser
2019-05-27 12:08:02 +05:30
import damask
2019-05-27 12:08:02 +05:30
scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
# --------------------------------------------------------------------
# MAIN
# --------------------------------------------------------------------
2019-05-27 12:08:02 +05:30
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
2019-05-30 17:37:49 +05:30
Converts ASCII table. Input can be microstructure or orientation (as quaternion). For the latter,
2019-05-30 17:00:18 +05:30
phase information can be given additionally.
""", version = scriptID)
parser.add_option('--coordinates',
dest = 'pos',
type = 'string', metavar = 'string',
2017-05-29 14:02:22 +05:30
help = 'coordinates label (%default)')
parser.add_option('--phase',
dest = 'phase',
type = 'string', metavar = 'string',
help = 'phase label')
parser.add_option('--microstructure',
dest = 'microstructure',
type = 'string', metavar = 'string',
help = 'microstructure label')
parser.add_option('-q', '--quaternion',
dest = 'quaternion',
type = 'string', metavar='string',
help = 'quaternion label')
parser.set_defaults(pos= 'pos')
(options,filenames) = parser.parse_args()
2020-01-15 18:39:26 +05:30
if filenames == []: filenames = [None]
for name in filenames:
2020-01-15 18:39:26 +05:30
damask.util.report(scriptName,name)
labels = []
for l in [options.quaternion,options.phase,options.microstructure]:
if l is not None: labels.append(l)
2020-01-15 18:39:26 +05:30
t = damask.Table.load(name)
geom = damask.Geom.from_table(t,options.pos,labels)
2020-01-15 18:39:26 +05:30
damask.util.croak(geom)
geom.save_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.geom')