improved help for automatic documentation and simplified some scripts
This commit is contained in:
parent
213d096932
commit
18831e0e80
|
@ -21,10 +21,10 @@ Orientation is given by quaternion, Euler angles, rotation matrix, or crystal fr
|
|||
|
||||
outputChoices = ['quaternion','eulers']
|
||||
parser.add_option('-o', '--output', dest='output', action='extend', metavar='<string LIST>',
|
||||
help = 'output orientation formats (%s)'%(','.join(outputChoices)))
|
||||
help = 'output orientation formats {%s}'%(','.join(outputChoices)))
|
||||
parser.add_option('-s', '--symmetry', dest='symmetry', type='choice',
|
||||
choices=damask.Symmetry.lattices[1:], metavar='string',
|
||||
help = 'crystal symmetry (%s) [cubic]'%(', '.join(damask.Symmetry.lattices[1:])))
|
||||
help = 'crystal symmetry [cubic] {%s}'%(', '.join(damask.Symmetry.lattices[1:])))
|
||||
parser.add_option('-r', '--rotation', dest='rotation', type='float', nargs=4, metavar='float float float float',
|
||||
help = 'angle and axis to (pre)rotate orientation')
|
||||
parser.add_option('-e', '--eulers', dest='eulers', metavar='string',
|
||||
|
@ -41,9 +41,8 @@ parser.add_option('-c', dest='c', metavar='string',
|
|||
help = 'crystal frame c vector label')
|
||||
parser.add_option('-q', '--quaternion', dest='quaternion', metavar='string',
|
||||
help = 'quaternion label')
|
||||
parser.set_defaults(output = [])
|
||||
parser.set_defaults(symmetry = 'cubic')
|
||||
parser.set_defaults(rotation = [0.,1.,1.,1.]) # no rotation about 1,1,1
|
||||
parser.set_defaults(rotation = (0.,1.,1.,1.)) # no rotation about 1,1,1
|
||||
parser.set_defaults(degrees = False)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
@ -75,10 +74,8 @@ if options.quaternion != None:
|
|||
datainfo['quaternion']['label'] += [options.quaternion]
|
||||
input = 'quaternion'
|
||||
|
||||
inputGiven = 0
|
||||
for datatype,info in datainfo.items():
|
||||
inputGiven += len(info['label'])
|
||||
if inputGiven != 1: parser.error('select exactly one input format...')
|
||||
if len(input) != 1: parser.error('needs exactly one input format...')
|
||||
input = input[0]
|
||||
|
||||
toRadians = math.pi/180.0 if options.degrees else 1.0 # rescale degrees to radians
|
||||
options.output = map(lambda x: x.lower(), options.output)
|
||||
|
|
|
@ -28,16 +28,6 @@ parser.set_defaults(stress = 'p')
|
|||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
datainfo = { # list of requested labels per datatype
|
||||
'defgrad': {'len':9,
|
||||
'label':[]},
|
||||
'stress': {'len':9,
|
||||
'label':[]},
|
||||
}
|
||||
|
||||
datainfo['defgrad']['label'].append(options.defgrad)
|
||||
datainfo['stress']['label'].append(options.stress)
|
||||
|
||||
# ------------------------------------------ setup file handles ------------------------------------
|
||||
files = []
|
||||
if filenames == []:
|
||||
|
@ -56,23 +46,19 @@ for file in files:
|
|||
table.head_read() # read ASCII header info
|
||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||
|
||||
# --------------- figure out columns to process ---------------------------------------------------
|
||||
missingColumns = False
|
||||
column={ 'defgrad': table.labels.index('1_'+options.defgrad),
|
||||
'stress': table.labels.index('1_'+options.stress)}
|
||||
for key in column:
|
||||
if column[key]<1:
|
||||
file['croak'].write('column %s not found...\n'%key)
|
||||
missingColumns=True
|
||||
if missingColumns: continue
|
||||
active = defaultdict(list)
|
||||
column = defaultdict(dict)
|
||||
missingColumns = False
|
||||
|
||||
for datatype,info in datainfo.items():
|
||||
for label in info['label']:
|
||||
key = '1_%s'%label
|
||||
if key not in table.labels:
|
||||
file['croak'].write('column %s not found...\n'%key)
|
||||
missingColumns = True # break if label not found
|
||||
else:
|
||||
active[datatype].append(label)
|
||||
column[datatype][label] = table.labels.index(key) # remember columns of requested data
|
||||
|
||||
if missingColumns:
|
||||
continue
|
||||
|
||||
# ------------------------------------------ assemble header --------------------------------------
|
||||
table.labels_append(['%i_S'%(i+1) for i in xrange(datainfo['stress']['len'])]) # extend ASCII header with new labels
|
||||
table.head_write()
|
||||
|
@ -80,13 +66,8 @@ for file in files:
|
|||
# ------------------------------------------ process data ------------------------------------------
|
||||
outputAlive = True
|
||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||
F = np.array(map(float,table.data[column['defgrad'][active['defgrad'][0]]:
|
||||
column['defgrad'][active['defgrad'][0]]+
|
||||
datainfo['defgrad']['len']]),'d').reshape(3,3)
|
||||
P = np.array(map(float,table.data[column['stress'][active['stress'][0]]:
|
||||
column['stress'][active['stress'][0]]+
|
||||
datainfo['stress']['len']]),'d').reshape(3,3)
|
||||
|
||||
F = np.array(map(float,table.data[column['defgrad']:column['defgrad']+9]),'d').reshape(3,3)
|
||||
P = np.array(map(float,table.data[column['stress'] :column['stress']+9]),'d').reshape(3,3)
|
||||
table.data_append(list(np.dot(np.linalg.inv(F),P).reshape(9))) # [S] =[P].[F-1]
|
||||
outputAlive = table.data_write() # output processed line
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ Add x,y coordinates of stereographic projection of given direction (pole) in cry
|
|||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-p', '--pole', dest='pole', 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', dest='polar', action='store_true',
|
||||
help = 'output polar coordinates r,phi [%default]')
|
||||
parser.add_option('-e', '--eulers', dest='eulers', metavar='string',
|
||||
|
@ -36,7 +36,7 @@ parser.add_option('-c', dest='c', metavar='string',
|
|||
help = 'crystal frame c vector label')
|
||||
parser.add_option('-q', '--quaternion', dest='quaternion', metavar='string',
|
||||
help = 'quaternion label')
|
||||
parser.set_defaults(pole = [1.0,0.0,0.0])
|
||||
parser.set_defaults(pole = (1.0,0.0,0.0))
|
||||
parser.set_defaults(degrees = False)
|
||||
parser.set_defaults(polar = False)
|
||||
|
||||
|
|
|
@ -247,9 +247,8 @@ Add columns listing Schmid factors (and optional trace vector of selected system
|
|||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-l','--lattice', dest='lattice', type='choice',
|
||||
choices=('fcc','bcc','hex'), metavar='string',
|
||||
help="type of lattice structure {'fcc','bcc','hex'} [%default]")
|
||||
parser.add_option('-l','--lattice', dest='lattice', type='choice', choices=('fcc','bcc','hex'), metavar='string',
|
||||
help="type of lattice structure [%default] {fcc,bcc',hex}")
|
||||
parser.add_option('--direction', dest='forcedirection', type='int', nargs=3, metavar='int int int',
|
||||
help='force direction in lab coordinates %default')
|
||||
parser.add_option('-n','--normal', dest='stressnormal', type='int', nargs=3, metavar='int int int',
|
||||
|
@ -265,15 +264,17 @@ parser.add_option('-e', '--eulers', dest='eulers', metavar='string',
|
|||
parser.add_option('-d', '--degrees', dest='degrees', action='store_true',
|
||||
help='Euler angles are given in degrees [%default]')
|
||||
parser.set_defaults(lattice = 'fcc')
|
||||
parser.set_defaults(forcedirection = [0, 0, 1])
|
||||
parser.set_defaults(forcedirection = (0, 0, 1))
|
||||
parser.set_defaults(stressnormal = None)
|
||||
parser.set_defaults(traceplane = None)
|
||||
parser.set_defaults(rank = 0)
|
||||
parser.set_defaults(CoverA = 1.587)
|
||||
parser.set_defaults(eulers = 'eulerangles')
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
if options.lattice=='hex' and options.CoverA == None:
|
||||
parser.error('hex lattice needs c over a ration...')
|
||||
|
||||
options.forcedirection = normalize(options.forcedirection)
|
||||
if options.stressnormal:
|
||||
if abs(sum([options.forcedirection[i] * options.stressnormal[i] for i in range(3)])) < 1e-3:
|
||||
|
|
|
@ -21,11 +21,10 @@ Add column(s) containing eigenvalues and eigenvectors of requested tensor column
|
|||
|
||||
parser.add_option('-t','--tensor', dest='tensor', action='extend', metavar='<string LIST>',
|
||||
help='heading of columns containing tensor field values')
|
||||
parser.set_defaults(tensor = [])
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
if len(options.tensor) == 0:
|
||||
if options.tensor == None:
|
||||
parser.error('no data column specified...')
|
||||
|
||||
datainfo = { # list of requested labels per datatype
|
||||
|
|
Loading…
Reference in New Issue