2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2015-06-21 17:26:05 +05:30
|
|
|
|
2019-05-27 12:08:02 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2015-06-21 17:26:05 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-27 12:08:02 +05:30
|
|
|
|
2015-06-21 17:26:05 +05:30
|
|
|
import damask
|
|
|
|
|
2019-05-27 12:08:02 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2015-06-21 17:26:05 +05:30
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# 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.
|
2015-06-21 17:26:05 +05:30
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('--coordinates',
|
2016-04-27 02:19:58 +05:30
|
|
|
dest = 'pos',
|
2015-08-08 00:33:26 +05:30
|
|
|
type = 'string', metavar = 'string',
|
2017-05-29 14:02:22 +05:30
|
|
|
help = 'coordinates label (%default)')
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('--phase',
|
|
|
|
dest = 'phase',
|
|
|
|
type = 'string', metavar = 'string',
|
|
|
|
help = 'phase label')
|
2015-08-13 00:26:40 +05:30
|
|
|
parser.add_option('--microstructure',
|
|
|
|
dest = 'microstructure',
|
|
|
|
type = 'string', metavar = 'string',
|
|
|
|
help = 'microstructure label')
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('-q', '--quaternion',
|
|
|
|
dest = 'quaternion',
|
|
|
|
type = 'string', metavar='string',
|
2015-06-21 17:26:05 +05:30
|
|
|
help = 'quaternion label')
|
|
|
|
|
2020-10-08 22:03:40 +05:30
|
|
|
parser.set_defaults(pos= 'pos')
|
2015-06-21 17:26:05 +05:30
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2020-01-15 18:39:26 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2015-06-21 17:26:05 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2020-01-15 18:39:26 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
2020-10-08 22:03:40 +05:30
|
|
|
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
|
|
|
|
2020-10-09 22:49:05 +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)
|
|
|
|
|
2020-10-10 13:11:11 +05:30
|
|
|
geom.save_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.geom')
|