more general option + improved descriptions

hopefully more user friendly
This commit is contained in:
Martin Diehl 2018-12-10 09:27:39 +01:00
parent d219842ad8
commit 767650e002
6 changed files with 51 additions and 37 deletions

@ -1 +1 @@
Subproject commit d15faafa81e7133977dcc6a160ed73a58de69ccb Subproject commit e3dac27b709d7fb3630bbd75271b220827221492

View File

@ -31,11 +31,11 @@ parser.add_option('-s',
dest = 'symmetry', dest = 'symmetry',
metavar = 'string', metavar = 'string',
help = 'crystal symmetry [%default]') help = 'crystal symmetry [%default]')
parser.add_option('-q', parser.add_option('-o',
'--quaternion', '--orientation',
dest = 'quaternion', dest = 'quaternion',
metavar = 'string', metavar = 'string',
help = 'label of quaternion') help = 'label of crystal orientation given as unit quaternion [%default]')
parser.add_option('-p', parser.add_option('-p',
'--pos', '--position', '--pos', '--position',
dest = 'pos', dest = 'pos',

View File

@ -18,18 +18,21 @@ Add RGB color value corresponding to TSL-OIM scheme for inverse pole figures.
""", version = scriptID) """, version = scriptID)
parser.add_option('-p', '--pole', parser.add_option('-p',
'--pole',
dest = 'pole', dest = 'pole',
type = 'float', nargs = 3, metavar = 'float float float', type = 'float', nargs = 3, metavar = 'float float float',
help = 'lab frame direction for inverse pole figure [%default]') help = 'lab frame direction for inverse pole figure [%default]')
parser.add_option('-s', '--symmetry', parser.add_option('-s',
'--symmetry',
dest = 'symmetry', dest = 'symmetry',
type = 'choice', choices = damask.Symmetry.lattices[1:], metavar='string', type = 'choice', choices = damask.Symmetry.lattices[1:], metavar='string',
help = 'crystal symmetry [%default] {{{}}} '.format(', '.join(damask.Symmetry.lattices[1:]))) help = 'crystal symmetry [%default] {{{}}} '.format(', '.join(damask.Symmetry.lattices[1:])))
parser.add_option('-q', '--quaternion', parser.add_option('-o',
'--orientation',
dest = 'quaternion', dest = 'quaternion',
type = 'string', metavar = 'string', metavar = 'string',
help = 'quaternion label') help = 'label of crystal orientation given as unit quaternion [%default]')
parser.set_defaults(pole = (0.0,0.0,1.0), parser.set_defaults(pole = (0.0,0.0,1.0),
quaternion = 'orientation', quaternion = 'orientation',

View File

@ -54,49 +54,53 @@ outputChoices = {
'angleaxis': ['aaxs',4], 'angleaxis': ['aaxs',4],
} }
parser.add_option('-o', '--output', parser.add_option('-o',
'--output',
dest = 'output', dest = 'output',
action = 'extend', metavar = '<string LIST>', action = 'extend', metavar = '<string LIST>',
help = 'output orientation formats {{{}}}'.format(', '.join(outputChoices))) help = 'output orientation formats {{{}}}'.format(', '.join(outputChoices)))
parser.add_option('-d', '--degrees', parser.add_option('-d',
'--degrees',
dest = 'degrees', dest = 'degrees',
action = 'store_true', action = 'store_true',
help = 'all angles in degrees') help = 'all angles in degrees')
parser.add_option('-R', '--labrotation', parser.add_option('-R',
'--labrotation',
dest='labrotation', dest='labrotation',
type = 'float', nargs = 4, metavar = ' '.join(['float']*4), type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
help = 'angle and axis of additional lab frame rotation') help = 'angle and axis of additional lab frame rotation')
parser.add_option('-r', '--crystalrotation', parser.add_option('-r',
'--crystalrotation',
dest='crystalrotation', dest='crystalrotation',
type = 'float', nargs = 4, metavar = ' '.join(['float']*4), type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
help = 'angle and axis of additional crystal frame rotation') help = 'angle and axis of additional crystal frame rotation')
parser.add_option( '--eulers', parser.add_option('--eulers',
dest = 'eulers', dest = 'eulers',
type = 'string', metavar = 'string', metavar = 'string',
help = 'Euler angles label') help = 'Euler angles label')
parser.add_option( '--rodrigues', parser.add_option('--rodrigues',
dest = 'rodrigues', dest = 'rodrigues',
type = 'string', metavar = 'string', metavar = 'string',
help = 'Rodrigues vector label') help = 'Rodrigues vector label')
parser.add_option( '--matrix', parser.add_option('--matrix',
dest = 'matrix', dest = 'matrix',
type = 'string', metavar = 'string', metavar = 'string',
help = 'orientation matrix label') help = 'orientation matrix label')
parser.add_option( '--quaternion', parser.add_option('--quaternion',
dest = 'quaternion', dest = 'quaternion',
type = 'string', metavar = 'string', metavar = 'string',
help = 'quaternion label') help = 'quaternion label')
parser.add_option('-x', parser.add_option('-x',
dest = 'x', dest = 'x',
type = 'string', metavar = 'string', metavar = 'string',
help = 'label of lab x vector (expressed in crystal coords)') help = 'label of lab x vector (expressed in crystal coords)')
parser.add_option('-y', parser.add_option('-y',
dest = 'y', dest = 'y',
type = 'string', metavar = 'string', metavar = 'string',
help = 'label of lab y vector (expressed in crystal coords)') help = 'label of lab y vector (expressed in crystal coords)')
parser.add_option('-z', parser.add_option('-z',
dest = 'z', dest = 'z',
type = 'string', metavar = 'string', metavar = 'string',
help = 'label of lab z vector (expressed in crystal coords)') help = 'label of lab z vector (expressed in crystal coords)')
parser.set_defaults(output = [], parser.set_defaults(output = [],

View File

@ -14,22 +14,24 @@ scriptID = ' '.join([scriptName,damask.version])
# -------------------------------------------------------------------- # --------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
Add x,y coordinates of stereographic projection of given direction (pole) in crystal frame. Add coordinates of stereographic projection of given direction (pole) in crystal frame.
""", version = scriptID) """, version = scriptID)
parser.add_option('-p', '--pole', parser.add_option('-p',
'--pole',
dest = 'pole', dest = 'pole',
type = 'float', nargs = 3, metavar = 'float float float', type = 'float', nargs = 3, metavar = 'float float float',
help = 'crystal frame direction for pole figure [%default]') help = 'crystal frame direction for pole figure [%default]')
parser.add_option('--polar', parser.add_option('--polar',
dest = 'polar', dest = 'polar',
action = 'store_true', action = 'store_true',
help = 'output polar coordinates r,phi [%default]') help = 'output polar coordinates (r,φ) instead of Cartesian coordinates (x,y)')
parser.add_option('-q', '--quaternion', parser.add_option('-o',
'--orientation',
dest = 'quaternion', dest = 'quaternion',
type = 'string', metavar = 'string', metavar = 'string',
help = 'quaternion label') help = 'label of crystal orientation given as unit quaternion [%default]')
parser.set_defaults(pole = (1.0,0.0,0.0), parser.set_defaults(pole = (1.0,0.0,0.0),
quaternion = 'orientation', quaternion = 'orientation',

View File

@ -109,26 +109,31 @@ Add columns listing Schmid factors (and optional trace vector of selected system
""", version = scriptID) """, version = scriptID)
latticeChoices = ('fcc','bcc','hex') latticeChoices = ('fcc','bcc','hex')
parser.add_option('-l','--lattice', parser.add_option('-l',
'--lattice',
dest = 'lattice', type = 'choice', choices = latticeChoices, metavar='string', dest = 'lattice', type = 'choice', choices = latticeChoices, metavar='string',
help = 'type of lattice structure [%default] {}'.format(latticeChoices)) help = 'type of lattice structure [%default] {}'.format(latticeChoices))
parser.add_option('--covera', parser.add_option('--covera',
dest = 'CoverA', type = 'float', metavar = 'float', dest = 'CoverA', type = 'float', metavar = 'float',
help = 'C over A ratio for hexagonal systems') help = 'C over A ratio for hexagonal systems')
parser.add_option('-f', '--force', parser.add_option('-f',
'--force',
dest = 'force', dest = 'force',
type = 'float', nargs = 3, metavar = 'float float float', type = 'float', nargs = 3, metavar = 'float float float',
help = 'force direction in lab frame [%default]') help = 'force direction in lab frame [%default]')
parser.add_option('-n', '--normal', parser.add_option('-n',
'--normal',
dest = 'normal', dest = 'normal',
type = 'float', nargs = 3, metavar = 'float float float', type = 'float', nargs = 3, metavar = 'float float float',
help = 'stress plane normal in lab frame [%default]') help = 'stress plane normal in lab frame, per default perpendicular to the force')
parser.add_option('-q', '--quaternion', parser.add_option('-o',
'--orientation',
dest = 'quaternion', dest = 'quaternion',
metavar = 'string', metavar = 'string',
help = 'quaternion label') help = 'label of crystal orientation given as unit quaternion [%default]')
parser.set_defaults(force = (0.0,0.0,1.0), parser.set_defaults(force = (0.0,0.0,1.0),
quaternion='orientation',
normal = None, normal = None,
lattice = latticeChoices[0], lattice = latticeChoices[0],
CoverA = math.sqrt(8./3.), CoverA = math.sqrt(8./3.),
@ -139,7 +144,7 @@ parser.set_defaults(force = (0.0,0.0,1.0),
force = np.array(options.force) force = np.array(options.force)
force /= np.linalg.norm(force) force /= np.linalg.norm(force)
if options.normal: if options.normal is not None:
normal = np.array(options.normal) normal = np.array(options.normal)
normal /= np.linalg.norm(normal) normal /= np.linalg.norm(normal)
if abs(np.dot(force,normal)) > 1e-3: if abs(np.dot(force,normal)) > 1e-3: