not needed anymore
This commit is contained in:
parent
17aa3c00dc
commit
39505507f1
|
@ -1,68 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Add RGB color value corresponding to TSL-OIM scheme for inverse pole figures.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-p',
|
||||
'--pole',
|
||||
dest = 'pole',
|
||||
type = 'float', nargs = 3, metavar = 'float float float',
|
||||
help = 'lab frame direction for inverse pole figure [%default]')
|
||||
parser.add_option('-s',
|
||||
'--symmetry',
|
||||
dest = 'symmetry',
|
||||
type = 'choice', choices = damask.Symmetry.lattices[1:], metavar='string',
|
||||
help = 'crystal symmetry [%default] {{{}}} '.format(', '.join(damask.Symmetry.lattices[1:])))
|
||||
parser.add_option('-o',
|
||||
'--orientation',
|
||||
dest = 'quaternion',
|
||||
metavar = 'string',
|
||||
help = 'label of crystal orientation given as unit quaternion [%default]')
|
||||
|
||||
parser.set_defaults(pole = (0.0,0.0,1.0),
|
||||
quaternion = 'orientation',
|
||||
symmetry = damask.Symmetry.lattices[-1],
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
# damask.Orientation requires Bravais lattice, but we are only interested in symmetry
|
||||
symmetry2lattice={'cubic':'fcc','hexagonal':'hex','tetragonal':'bct'}
|
||||
lattice = symmetry2lattice[options.symmetry]
|
||||
|
||||
pole = np.array(options.pole)
|
||||
pole /= np.linalg.norm(pole)
|
||||
|
||||
for name in filenames:
|
||||
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)
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Add column(s) containing Second Piola--Kirchhoff stress based on given column(s) of deformation
|
||||
gradient and first Piola--Kirchhoff stress.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-f','--defgrad',
|
||||
dest = 'defgrad',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'heading of columns containing deformation gradient [%default]')
|
||||
parser.add_option('-p','--stress',
|
||||
dest = 'stress',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'heading of columns containing first Piola--Kirchhoff stress [%default]')
|
||||
|
||||
parser.set_defaults(defgrad = 'f',
|
||||
stress = 'p',
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
table.add('S',
|
||||
damask.mechanics.PK2(table.get(options.stress ).reshape(-1,3,3),
|
||||
table.get(options.defgrad).reshape(-1,3,3)).reshape(-1,9),
|
||||
scriptID+' '+' '.join(sys.argv[1:]))
|
||||
|
||||
table.to_ASCII(sys.stdout if name is None else name)
|
|
@ -1,65 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Add coordinates of stereographic projection of given direction (pole) in crystal frame.
|
||||
|
||||
""", 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]')
|
||||
parser.add_option('--polar',
|
||||
dest = 'polar',
|
||||
action = 'store_true',
|
||||
help = 'output polar coordinates (r,φ) instead of Cartesian coordinates (x,y)')
|
||||
parser.add_option('-o',
|
||||
'--orientation',
|
||||
dest = 'quaternion',
|
||||
metavar = 'string',
|
||||
help = 'label of crystal orientation given as unit quaternion [%default]')
|
||||
|
||||
parser.set_defaults(pole = (1.0,0.0,0.0),
|
||||
quaternion = 'orientation',
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
pole = np.array(options.pole)
|
||||
pole /= np.linalg.norm(pole)
|
||||
|
||||
for name in filenames:
|
||||
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)
|
||||
poles = np.empty((orientation.shape[0],2))
|
||||
for i,o in enumerate(orientation):
|
||||
rotatedPole = damask.Rotation(o)*pole # rotate pole according to crystal orientation
|
||||
(x,y) = rotatedPole[0:2]/(1.+abs(pole[2])) # stereographic projection
|
||||
poles[i] = [np.sqrt(x*x+y*y),np.arctan2(y,x)] if options.polar else [x,y] # cartesian coordinates
|
||||
|
||||
table.add('pole_{}{}{}'.format(*options.pole),
|
||||
poles,
|
||||
scriptID+' '+' '.join(sys.argv[1:]))
|
||||
table.to_ASCII(sys.stdout if name is None else name)
|
|
@ -1,98 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
def parameters(stretch,strain):
|
||||
"""Albrecht Bertram: Elasticity and Plasticity of Large Deformations An Introduction (3rd Edition, 2012), p. 102."""
|
||||
return {
|
||||
'V#ln': ('V',0.0),
|
||||
'U#ln': ('U',0.0),
|
||||
'V#Biot': ('V',-.5),
|
||||
'U#Biot': ('U',+.5),
|
||||
'V#Green': ('V',-1.),
|
||||
'U#Green': ('U',+1.),
|
||||
}[stretch+'#'+strain]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Add column(s) containing given strains based on given stretches of requested deformation gradient column(s).
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-u','--right',
|
||||
dest = 'right',
|
||||
action = 'store_true',
|
||||
help = 'material strains based on right Cauchy--Green deformation, i.e., C and U')
|
||||
parser.add_option('-v','--left',
|
||||
dest = 'left',
|
||||
action = 'store_true',
|
||||
help = 'spatial strains based on left Cauchy--Green deformation, i.e., B and V')
|
||||
parser.add_option('-0','--logarithmic',
|
||||
dest = 'logarithmic',
|
||||
action = 'store_true',
|
||||
help = 'calculate logarithmic strain tensor')
|
||||
parser.add_option('-1','--biot',
|
||||
dest = 'biot',
|
||||
action = 'store_true',
|
||||
help = 'calculate biot strain tensor')
|
||||
parser.add_option('-2','--green',
|
||||
dest = 'green',
|
||||
action = 'store_true',
|
||||
help = 'calculate green strain tensor')
|
||||
parser.add_option('-f','--defgrad',
|
||||
dest = 'defgrad',
|
||||
action = 'extend',
|
||||
metavar = '<string LIST>',
|
||||
help = 'heading(s) of columns containing deformation tensor values [%default]')
|
||||
|
||||
parser.set_defaults(
|
||||
defgrad = ['f'],
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
if len(options.defgrad) > 1:
|
||||
options.defgrad = options.defgrad[1:]
|
||||
|
||||
stretches = []
|
||||
strains = []
|
||||
|
||||
if options.right: stretches.append('U')
|
||||
if options.left: stretches.append('V')
|
||||
if options.logarithmic: strains.append('ln')
|
||||
if options.biot: strains.append('Biot')
|
||||
if options.green: strains.append('Green')
|
||||
|
||||
if options.defgrad is None:
|
||||
parser.error('no data column specified.')
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
for defgrad in options.defgrad:
|
||||
F = table.get(defgrad).reshape(-1,3,3)
|
||||
for theStretch in stretches:
|
||||
for theStrain in strains:
|
||||
(t,m) = parameters(theStretch,theStrain)
|
||||
label = '{}({}){}'.format(theStrain,theStretch,defgrad if defgrad != 'f' else '')
|
||||
table.add(label,
|
||||
damask.mechanics.strain_tensor(F,t,m).reshape(-1,9),
|
||||
scriptID+' '+' '.join(sys.argv[1:]))
|
||||
|
||||
table.to_ASCII(sys.stdout if name is None else name)
|
|
@ -1,62 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
||||
Rotate vector and/or tensor column data by given angle around given axis.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-d', '--data',
|
||||
dest = 'data',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'vector/tensor value(s) label(s)')
|
||||
parser.add_option('-r', '--rotation',
|
||||
dest = 'rotation',
|
||||
type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
|
||||
help = 'axis and angle to rotate data [%default]')
|
||||
parser.add_option('--degrees',
|
||||
dest = 'degrees',
|
||||
action = 'store_true',
|
||||
help = 'angles are given in degrees')
|
||||
|
||||
parser.set_defaults(rotation = (1.,1.,1.,0), # no rotation about (1,1,1)
|
||||
degrees = False,
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
if options.data is None:
|
||||
parser.error('no data column specified.')
|
||||
|
||||
r = damask.Rotation.from_axis_angle(options.rotation,options.degrees,normalise=True)
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
for data in options.data:
|
||||
d = table.get(data)
|
||||
if table.shapes[data] == (9,): d=d.reshape(-1,3,3)
|
||||
d = r.broadcast_to(d.shape[0:1]) @ d
|
||||
if table.shapes[data] == (9,): d=d.reshape(-1,9)
|
||||
|
||||
table.set(data,d,scriptID+' '+' '.join(sys.argv[1:]))
|
||||
|
||||
table.to_ASCII(sys.stdout if name is None else name)
|
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(usage='%prog options [ASCIItable(s)]', description = """
|
||||
Show components of given ASCIItable(s).
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
|
||||
parser.add_option('-a','--head',
|
||||
dest = 'head',
|
||||
action = 'store_true',
|
||||
help = 'output complete header (info + labels)')
|
||||
parser.add_option('-i','--info',
|
||||
dest = 'info',
|
||||
action = 'store_true',
|
||||
help = 'output info lines')
|
||||
parser.add_option('-l','--labels',
|
||||
dest = 'labels',
|
||||
action = 'store_true',
|
||||
help = 'output labels')
|
||||
parser.add_option('-d','--data',
|
||||
dest = 'data',
|
||||
action = 'store_true',
|
||||
help = 'output data')
|
||||
parser.add_option('-t','--table',
|
||||
dest = 'table',
|
||||
action = 'store_true',
|
||||
help = 'output heading line for proper ASCIItable format')
|
||||
parser.add_option('--nolabels',
|
||||
dest = 'labeled',
|
||||
action = 'store_false',
|
||||
help = 'table has no labels')
|
||||
parser.set_defaults(table = False,
|
||||
head = False,
|
||||
info = False,
|
||||
labels = False,
|
||||
data = False,
|
||||
labeled = True,
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
try:
|
||||
table = damask.ASCIItable(name = name, labeled = options.labeled, readonly = True)
|
||||
except IOError:
|
||||
continue
|
||||
details = ', '.join(
|
||||
(['header'] if options.table else []) +
|
||||
(['info'] if options.head or options.info else []) +
|
||||
(['labels'] if options.head or options.labels else []) +
|
||||
(['data'] if options.data else []) +
|
||||
[]
|
||||
)
|
||||
damask.util.report(scriptName,(name if name is not None else '') + ('' if details == '' else ' -- '+details))
|
||||
|
||||
# ------------------------------------------ output head ---------------------------------------
|
||||
|
||||
table.head_read()
|
||||
if not (options.head or options.info): table.info_clear()
|
||||
if not (options.head or (options.labels and options.labeled)): table.labels_clear()
|
||||
|
||||
table.head_write(header = options.table)
|
||||
|
||||
# ------------------------------------------ output data ---------------------------------------
|
||||
|
||||
outputAlive = options.data
|
||||
while outputAlive and table.data_read(): # read next data line of ASCII table
|
||||
outputAlive = table.data_write() # output line
|
||||
|
||||
table.close()
|
|
@ -1,61 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
||||
Increases or decreases the (three-dimensional) canvas.
|
||||
Grid can be given as absolute or relative values, e.g. 16 16 16 or 2x 0.5x 32.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-g','--grid',
|
||||
dest = 'grid',
|
||||
type = 'string', nargs = 3, metavar = ' '.join(['string']*3),
|
||||
help = 'a,b,c grid of hexahedral box')
|
||||
parser.add_option('-o','--offset',
|
||||
dest = 'offset',
|
||||
type = 'int', nargs = 3, metavar = ' '.join(['int']*3),
|
||||
help = 'a,b,c offset from old to new origin of grid [%default]')
|
||||
parser.add_option('-f','--fill',
|
||||
dest = 'fill',
|
||||
type = 'float', metavar = 'int',
|
||||
help = 'background microstructure index, defaults to max microstructure index + 1')
|
||||
|
||||
parser.set_defaults(offset = (0,0,0))
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
offset = np.asarray(options.offset)
|
||||
|
||||
if options.grid is not None:
|
||||
grid = np.maximum(1,
|
||||
np.array([int(o*float(n.lower().replace('x',''))) if n.lower().endswith('x') \
|
||||
else int(n) for o,n in zip(geom.grid,options.grid)],dtype=int))
|
||||
else:
|
||||
grid = np.array(options.grid,dtype=int)
|
||||
|
||||
damask.util.croak(geom.canvas(grid,np.asarray(options.offset),options.fill))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
geom.to_file(sys.stdout if name is None else name,pack=False)
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile(s)]', description = """
|
||||
Writes vtk file for visualization.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
|
||||
damask.util.croak(geom)
|
||||
|
||||
if name:
|
||||
geom.to_vtk(os.path.splitext(name)[0])
|
||||
else:
|
||||
sys.stdout.write(geom.to_vtk())
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile(s)]', description = """
|
||||
Renumber sorted microstructure indices to 1,...,N.
|
||||
|
||||
""", version=scriptID)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
damask.util.croak(geom.renumber())
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
geom.to_file(sys.stdout if name is None else name,pack=False)
|
|
@ -1,78 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
from scipy import ndimage
|
||||
import numpy as np
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
||||
Rotates original microstructure and embeddeds it into buffer material.
|
||||
|
||||
""", version=scriptID)
|
||||
|
||||
parser.add_option('-r', '--rotation',
|
||||
dest='rotation',
|
||||
type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
|
||||
help = 'rotation given as axis and angle')
|
||||
parser.add_option('-e', '--eulers',
|
||||
dest = 'eulers',
|
||||
type = 'float', nargs = 3, metavar = ' '.join(['float']*3),
|
||||
help = 'rotation given as Euler angles')
|
||||
parser.add_option('-d', '--degrees',
|
||||
dest = 'degrees',
|
||||
action = 'store_true',
|
||||
help = 'Euler angles/axis angle are given in degrees')
|
||||
parser.add_option('-m', '--matrix',
|
||||
dest = 'matrix',
|
||||
type = 'float', nargs = 9, metavar = ' '.join(['float']*9),
|
||||
help = 'rotation given as matrix')
|
||||
parser.add_option('-q', '--quaternion',
|
||||
dest = 'quaternion',
|
||||
type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
|
||||
help = 'rotation given as quaternion')
|
||||
parser.add_option('-f', '--fill',
|
||||
dest = 'fill',
|
||||
type = 'float', metavar = 'int',
|
||||
help = 'background microstructure index, defaults to max microstructure index + 1')
|
||||
|
||||
parser.set_defaults(degrees = False)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
if [options.rotation,options.eulers,options.matrix,options.quaternion].count(None) < 3:
|
||||
parser.error('more than one rotation specified.')
|
||||
if [options.rotation,options.eulers,options.matrix,options.quaternion].count(None) > 3:
|
||||
parser.error('no rotation specified.')
|
||||
|
||||
if options.quaternion is not None:
|
||||
rot = damask.Rotation.from_quaternion(np.array(options.quaternion)) # we might need P=+1 here, too...
|
||||
if options.rotation is not None:
|
||||
rot = damask.Rotation.from_axis_angle(np.array(options.rotation),degrees=options.degrees,normalise=True,P=+1)
|
||||
if options.matrix is not None:
|
||||
rot = damask.Rotation.from_matrix(np.array(options.Matrix))
|
||||
if options.eulers is not None:
|
||||
rot = damask.Rotation.from_Eulers(np.array(options.eulers),degrees=options.degrees)
|
||||
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
damask.util.croak(geom.rotate(rot,options.fill))
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
geom.to_file(sys.stdout if name is None else name,pack=False)
|
|
@ -1,55 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
from io import StringIO
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
||||
Translate microstructure indices (shift or substitute) and/or geometry origin.
|
||||
|
||||
""", version=scriptID)
|
||||
|
||||
parser.add_option('-o', '--origin',
|
||||
dest = 'origin',
|
||||
type = 'float', nargs = 3, metavar = ' '.join(['float']*3),
|
||||
help = 'offset from old to new origin of grid')
|
||||
parser.add_option('-m', '--microstructure',
|
||||
dest = 'microstructure',
|
||||
type = 'int', metavar = 'int',
|
||||
help = 'offset from old to new microstructure indices (after substitution)')
|
||||
parser.add_option('-s', '--substitute',
|
||||
dest = 'substitute',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'substitutions of microstructure indices from,to,from,to,...')
|
||||
|
||||
parser.set_defaults(origin = (0.0,0.0,0.0),
|
||||
microstructure = 0,
|
||||
substitute = []
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
sub = list(map(int,options.substitute))
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
geom.renumber(sub[0::2],sub[1::2],origin=geom.origin+options.origin)
|
||||
geom.microstructure+= option.microstructure
|
||||
damask.util.croak(geom)
|
||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||
geom.to_file(sys.stdout if name is None else name,pack=False)
|
|
@ -1197,20 +1197,3 @@ class Result:
|
|||
inc[3:].zfill(N_digits))
|
||||
|
||||
v.write(file_out)
|
||||
|
||||
###################################################################################################
|
||||
# BEGIN DEPRECATED
|
||||
|
||||
def set_by_time(self,start,end):
|
||||
"""
|
||||
Set active increments based on start and end time.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start : float
|
||||
start time (included)
|
||||
end : float
|
||||
end time (included)
|
||||
|
||||
"""
|
||||
self._manage_selection('set','times',self.times_in_range(start,end))
|
||||
|
|
Loading…
Reference in New Issue