2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2019-12-21 22:49:54 +05:30
|
|
|
from io import StringIO
|
2014-07-22 19:51:49 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2014-07-22 19:51:49 +05:30
|
|
|
import damask
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2014-07-22 19:51:49 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-16 22:11:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
2013-11-26 00:41:02 +05:30
|
|
|
Add RGB color value corresponding to TSL-OIM scheme for inverse pole figures.
|
2014-07-22 19:51:49 +05:30
|
|
|
|
2014-08-06 18:57:09 +05:30
|
|
|
""", version = scriptID)
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-p',
|
|
|
|
'--pole',
|
2015-08-08 00:33:26 +05:30
|
|
|
dest = 'pole',
|
|
|
|
type = 'float', nargs = 3, metavar = 'float float float',
|
2015-05-09 18:31:31 +05:30
|
|
|
help = 'lab frame direction for inverse pole figure [%default]')
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-s',
|
|
|
|
'--symmetry',
|
2015-08-08 00:33:26 +05:30
|
|
|
dest = 'symmetry',
|
|
|
|
type = 'choice', choices = damask.Symmetry.lattices[1:], metavar='string',
|
|
|
|
help = 'crystal symmetry [%default] {{{}}} '.format(', '.join(damask.Symmetry.lattices[1:])))
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-o',
|
|
|
|
'--orientation',
|
2015-08-08 00:33:26 +05:30
|
|
|
dest = 'quaternion',
|
2018-12-10 13:57:39 +05:30
|
|
|
metavar = 'string',
|
|
|
|
help = 'label of crystal orientation given as unit quaternion [%default]')
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2015-06-16 22:51:24 +05:30
|
|
|
parser.set_defaults(pole = (0.0,0.0,1.0),
|
2018-12-09 11:40:31 +05:30
|
|
|
quaternion = 'orientation',
|
2015-08-08 00:33:26 +05:30
|
|
|
symmetry = damask.Symmetry.lattices[-1],
|
2015-06-16 22:51:24 +05:30
|
|
|
)
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2015-06-16 22:51:24 +05:30
|
|
|
(options, filenames) = parser.parse_args()
|
2019-12-21 19:42:01 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2014-08-04 23:23:41 +05:30
|
|
|
|
2019-02-24 12:38:14 +05:30
|
|
|
# damask.Orientation requires Bravais lattice, but we are only interested in symmetry
|
2019-12-21 19:42:01 +05:30
|
|
|
symmetry2lattice={'cubic':'fcc','hexagonal':'hex','tetragonal':'bct'}
|
2019-02-24 12:38:14 +05:30
|
|
|
lattice = symmetry2lattice[options.symmetry]
|
|
|
|
|
2014-07-22 19:51:49 +05:30
|
|
|
pole = np.array(options.pole)
|
|
|
|
pole /= np.linalg.norm(pole)
|
2013-11-26 00:41:02 +05:30
|
|
|
|
2015-06-16 22:51:24 +05:30
|
|
|
for name in filenames:
|
2019-12-21 19:42:01 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
|
|
|
orientation = table.get(options.quaternion)
|
|
|
|
color = np.empty((orientation.shape[0],3))
|
|
|
|
for i,o in enumerate(orientation):
|
|
|
|
color[i] = damask.Orientation(o,lattice = lattice).IPFcolor(pole)
|
|
|
|
|
|
|
|
table.add('IPF_{:g}{:g}{:g}_{sym}'.format(*options.pole,sym = options.symmetry.lower()),
|
|
|
|
color,
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|