2019-02-24 17:27:57 +05:30
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2019-05-30 17:00:38 +05:30
|
|
|
import os
|
2019-02-24 17:27:57 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-30 17:00:38 +05:30
|
|
|
|
2019-02-24 17:27:57 +05:30
|
|
|
import damask
|
|
|
|
|
2019-05-30 17:00:38 +05:30
|
|
|
|
2019-02-24 17:27:57 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
2019-05-30 17:00:38 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [DREAM.3Dfile(s)]', description = """
|
|
|
|
Converts DREAM.3D file. Input can be cell data (direct pointwise takeover) or grain data (individual
|
|
|
|
grains are segmented). Requires orientation data as quaternion.
|
2019-02-24 17:27:57 +05:30
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
|
|
|
parser.add_option('-b','--basegroup',
|
2019-05-30 17:00:38 +05:30
|
|
|
dest = 'basegroup',
|
|
|
|
metavar = 'string',
|
2019-03-05 15:28:57 +05:30
|
|
|
help = 'name of the group in "DataContainers" containing the pointwise (and, if applicable grain average) data')
|
2019-02-24 17:27:57 +05:30
|
|
|
parser.add_option('-p','--pointwise',
|
2019-05-30 17:00:38 +05:30
|
|
|
dest = 'pointwise',
|
|
|
|
metavar = 'string',
|
2019-03-05 15:28:57 +05:30
|
|
|
help = 'name of the group in "DataContainers/<basegroup>" containing pointwise data [%default]')
|
2019-02-24 17:27:57 +05:30
|
|
|
parser.add_option('-a','--average',
|
2019-05-30 17:00:38 +05:30
|
|
|
dest = 'average',
|
|
|
|
metavar = 'string',
|
2019-03-05 15:28:57 +05:30
|
|
|
help = 'name of the group in "DataContainers</basegroup>" containing grain average data. '\
|
2019-02-24 17:27:57 +05:30
|
|
|
+ 'Leave empty for pointwise data')
|
|
|
|
parser.add_option('--phase',
|
|
|
|
dest = 'phase',
|
2019-05-30 17:00:38 +05:30
|
|
|
type = 'string',
|
|
|
|
metavar = 'string',
|
2019-02-24 17:27:57 +05:30
|
|
|
help = 'name of the dataset containing pointwise/average phase IDs [%default]')
|
|
|
|
parser.add_option('--microstructure',
|
|
|
|
dest = 'microstructure',
|
2019-05-30 17:00:38 +05:30
|
|
|
type = 'string',
|
|
|
|
metavar = 'string',
|
2019-02-24 17:27:57 +05:30
|
|
|
help = 'name of the dataset connecting pointwise and average data [%default]')
|
|
|
|
parser.add_option('-q', '--quaternion',
|
|
|
|
dest = 'quaternion',
|
2019-05-30 17:00:38 +05:30
|
|
|
type = 'string',
|
|
|
|
metavar='string',
|
2019-02-24 17:27:57 +05:30
|
|
|
help = 'name of the dataset containing pointwise/average orientation as quaternion [%default]')
|
|
|
|
|
|
|
|
parser.set_defaults(pointwise = 'CellData',
|
|
|
|
quaternion = 'Quats',
|
|
|
|
phase = 'Phases',
|
|
|
|
microstructure = 'FeatureIds',
|
|
|
|
)
|
|
|
|
|
|
|
|
(options, filenames) = parser.parse_args()
|
|
|
|
|
|
|
|
if options.basegroup is None:
|
|
|
|
parser.error('No base group selected')
|
|
|
|
|
|
|
|
if filenames == []: parser.error('no input file specified.')
|
|
|
|
|
|
|
|
for name in filenames:
|
2020-10-08 22:03:40 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
geom = damask.Geom.load_DREAM3D(name,options.basegroup,options.pointwise)
|
|
|
|
damask.util.croak(geom)
|
|
|
|
|
|
|
|
geom.save_ASCII(os.path.splitext(name)[0]+'.geom',compress=False)
|