polishing
This commit is contained in:
parent
e4cb387571
commit
6604d0f8e8
|
@ -8,7 +8,7 @@ from vtk.util import numpy_support
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
class backgroundMessage(threading.Thread):
|
class backgroundMessage(threading.Thread):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def unravel(item):
|
def unravel(item):
|
||||||
if hasattr(item,'__contains__'): return ' '.join(map(unravel,item))
|
if hasattr(item,'__contains__'): return ' '.join(map(unravel,item))
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def determinant(m):
|
def determinant(m):
|
||||||
return +m[0]*m[4]*m[8] \
|
return +m[0]*m[4]*m[8] \
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
oneThird = 1.0/3.0
|
oneThird = 1.0/3.0
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def normalize(vec):
|
def normalize(vec):
|
||||||
return vec/np.sqrt(np.inner(vec,vec))
|
return vec/np.sqrt(np.inner(vec,vec))
|
||||||
|
|
|
@ -8,7 +8,7 @@ from scipy import ndimage
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def periodic_3Dpad(array, rimdim=(1,1,1)):
|
def periodic_3Dpad(array, rimdim=(1,1,1)):
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def Mises(what,tensor):
|
def Mises(what,tensor):
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# definition of element-wise p-norms for matrices
|
# definition of element-wise p-norms for matrices
|
||||||
def normAbs(object): # p = 1
|
def normAbs(object): # p = 1
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
slipnormal_temp = [
|
slipnormal_temp = [
|
||||||
[0,0,0,1],
|
[0,0,0,1],
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
def operator(stretch,strain,eigenvalues):
|
def operator(stretch,strain,eigenvalues):
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -6,7 +6,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -6,7 +6,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -6,7 +6,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = '$Id$'
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -5,7 +5,8 @@ import os, sys, math, string, numpy, shutil
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
scriptID = '$Id$'
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# MAIN FUNCTION STARTS HERE
|
# MAIN FUNCTION STARTS HERE
|
||||||
|
@ -15,8 +16,8 @@ from optparse import OptionParser
|
||||||
|
|
||||||
parser = OptionParser(usage='%prog [options] resultfile', description = """
|
parser = OptionParser(usage='%prog [options] resultfile', description = """
|
||||||
Create vtk files for the (deformed) geometry that belongs to a .t16 (MSC.Marc) results file.
|
Create vtk files for the (deformed) geometry that belongs to a .t16 (MSC.Marc) results file.
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-d','--dir', dest='dir', \
|
parser.add_option('-d','--dir', dest='dir', \
|
||||||
help='name of subdirectory to hold output [%default]')
|
help='name of subdirectory to hold output [%default]')
|
||||||
|
|
|
@ -2,30 +2,11 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os, sys, math, string, re, time
|
import os, sys, math, string, re, time
|
||||||
|
from optparse import OptionParser, OptionGroup
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup, Option
|
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
# -----------------------------
|
|
||||||
class MyOption(Option):
|
|
||||||
# -----------------------------
|
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def ParseOutputFormat(filename,homogID,crystID,phaseID):
|
def ParseOutputFormat(filename,homogID,crystID,phaseID):
|
||||||
|
@ -278,17 +259,14 @@ def writeHeader(myfile,stat,geomtype):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
# -----------------------------
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
# MAIN FUNCTION STARTS HERE
|
|
||||||
# -----------------------------
|
|
||||||
|
|
||||||
# --- input parsing
|
|
||||||
|
|
||||||
parser = OptionParser(option_class=MyOption, usage='%prog [options] resultfile', description = """
|
|
||||||
Extract data from a .t16 (MSC.Marc) results file.
|
Extract data from a .t16 (MSC.Marc) results file.
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-i','--info', action='store_true', dest='info', \
|
parser.add_option('-i','--info', action='store_true', dest='info', \
|
||||||
help='list contents of resultfile [%default]')
|
help='list contents of resultfile [%default]')
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import sys, string
|
import os, sys, string
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def outMentat(cmd,locals):
|
def outMentat(cmd,locals):
|
||||||
|
@ -57,13 +59,12 @@ def colorMap(colors,baseIdx=32):
|
||||||
# MAIN FUNCTION STARTS HERE
|
# MAIN FUNCTION STARTS HERE
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
|
||||||
parser = OptionParser(usage="%prog [options] predefinedScheme | (lower_h,s,l upper_h,s,l)", description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage="%prog [options] predefinedScheme | (lower_h,s,l upper_h,s,l)", description = """
|
||||||
Changes the color map in MSC.Mentat.
|
Changes the color map in MSC.Mentat.
|
||||||
|
|
||||||
Interpolates colors between "lower_hsl" and "upper_hsl".
|
Interpolates colors between "lower_hsl" and "upper_hsl".
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
|
||||||
)
|
|
||||||
|
|
||||||
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option("-i","--inverse", action = "store_true",
|
parser.add_option("-i","--inverse", action = "store_true",
|
||||||
dest = "inverse", \
|
dest = "inverse", \
|
||||||
|
|
|
@ -2,38 +2,20 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import math, string, sys, os
|
import math, string, sys, os
|
||||||
from damask import Color,Colormap
|
import damask
|
||||||
from optparse import OptionParser, Option
|
from optparse import OptionParser
|
||||||
|
|
||||||
# -----------------------------
|
|
||||||
class extendableOption(Option):
|
|
||||||
# -----------------------------
|
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
Produces perceptually linear diverging and sequential colormaps in formats suitable for visualization software or simply as a list of interpolated colors.
|
Produces perceptually linear diverging and sequential colormaps in formats suitable for visualization software or simply as a list of interpolated colors.
|
||||||
|
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
""", version = scriptID)
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_option('-l','--left', dest='left', type='float', nargs=3, \
|
parser.add_option('-l','--left', dest='left', type='float', nargs=3, \
|
||||||
help='left color %default')
|
help='left color %default')
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -5,6 +5,9 @@ import pdb, os, sys, gc, math, re, threading, time, struct, string
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
|
|
||||||
fileExtensions = { \
|
fileExtensions = { \
|
||||||
'marc': ['.t16',],
|
'marc': ['.t16',],
|
||||||
|
@ -623,7 +626,7 @@ def SummarizePostfile(stat,where=sys.stdout,format='marc'):
|
||||||
|
|
||||||
# --- input parsing
|
# --- input parsing
|
||||||
|
|
||||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] resultfile', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
Extract data from a .t16 (MSC.Marc) or .spectralOut results file.
|
Extract data from a .t16 (MSC.Marc) or .spectralOut results file.
|
||||||
|
|
||||||
List of output variables is given by options '--ns','--es','--et','--ho','--cr','--co'.
|
List of output variables is given by options '--ns','--es','--et','--ho','--cr','--co'.
|
||||||
|
@ -640,8 +643,7 @@ User mappings need to be formulated in an incremental fashion for each new data
|
||||||
and may use the current (incremental) result, b(ase), as well as the number, n(umber),
|
and may use the current (incremental) result, b(ase), as well as the number, n(umber),
|
||||||
of already processed data points for evaluation.
|
of already processed data points for evaluation.
|
||||||
|
|
||||||
""", version = string.replace('$Id$','\n','\\n')
|
""", version = scriptID)
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_option('-i','--info', action='store_true', dest='info', \
|
parser.add_option('-i','--info', action='store_true', dest='info', \
|
||||||
help='list contents of resultfile [%default]')
|
help='list contents of resultfile [%default]')
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = '$Id$'
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -8,7 +8,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -6,7 +6,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = '$Id$'
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -7,7 +7,7 @@ from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1][:-3]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
|
@ -1,52 +1,23 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,re,sys,math,string,numpy,damask,time
|
import os,re,sys,math,string,time
|
||||||
from optparse import OptionParser, Option
|
import numpy as np
|
||||||
|
import damask
|
||||||
# -----------------------------
|
from optparse import OptionParser
|
||||||
class extendableOption(Option):
|
|
||||||
# -----------------------------
|
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def location(idx,res):
|
|
||||||
|
|
||||||
return numpy.array([ idx % res[0], \
|
|
||||||
(idx // res[0]) % res[1], \
|
|
||||||
(idx // res[0] // res[1]) % res[2] ])
|
|
||||||
|
|
||||||
def index(location,res):
|
|
||||||
|
|
||||||
return ( location[0] % res[0] + \
|
|
||||||
(location[1] % res[1]) * res[0] + \
|
|
||||||
(location[2] % res[2]) * res[0] * res[1] )
|
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendableOption, usage='%prog [options] [file[s]]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] datafile[s]', description = """
|
||||||
Calculates the standard deviation of data in blocks of size 'packing' thus reducing the former resolution
|
Calculates the standard deviation of data in blocks of size 'packing' thus reducing the former resolution
|
||||||
to resolution/packing. (Requires numpy.)
|
to resolution/packing. (Requires np.)
|
||||||
|
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
""", version = scriptID)
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_option('-c','--coordinates', dest='coords', type='string',\
|
parser.add_option('-c','--coordinates', dest='coords', type='string',\
|
||||||
help='column heading for coordinates [%default]')
|
help='column heading for coordinates [%default]')
|
||||||
|
@ -71,11 +42,11 @@ if len(options.packing) < 3:
|
||||||
if len(options.shift) < 3:
|
if len(options.shift) < 3:
|
||||||
parser.error('shift needs three parameters...')
|
parser.error('shift needs three parameters...')
|
||||||
|
|
||||||
options.packing = numpy.array(options.packing)
|
options.packing = np.array(options.packing)
|
||||||
options.shift = numpy.array(options.shift)
|
options.shift = np.array(options.shift)
|
||||||
|
|
||||||
prefix = 'stddevDown%ix%ix%i_'%(options.packing[0],options.packing[1],options.packing[2])
|
prefix = 'stddevDown%ix%ix%i_'%(options.packing[0],options.packing[1],options.packing[2])
|
||||||
if numpy.any(options.shift != 0):
|
if np.any(options.shift != 0):
|
||||||
prefix += 'shift%+i%+i%+i_'%(options.shift[0],options.shift[1],options.shift[2])
|
prefix += 'shift%+i%+i%+i_'%(options.shift[0],options.shift[1],options.shift[2])
|
||||||
|
|
||||||
# ------------------------------------------ setup file handles ---------------------------------------
|
# ------------------------------------------ setup file handles ---------------------------------------
|
||||||
|
@ -114,27 +85,27 @@ for file in files:
|
||||||
while table.data_read(): # read next data line of ASCII table
|
while table.data_read(): # read next data line of ASCII table
|
||||||
for j in xrange(3):
|
for j in xrange(3):
|
||||||
grid[j][str(table.data[locationCol+j])] = True # remember coordinate along x,y,z
|
grid[j][str(table.data[locationCol+j])] = True # remember coordinate along x,y,z
|
||||||
resolution = numpy.array([len(grid[0]),\
|
resolution = np.array([len(grid[0]),\
|
||||||
len(grid[1]),\
|
len(grid[1]),\
|
||||||
len(grid[2]),],'i') # resolution is number of distinct coordinates found
|
len(grid[2]),],'i') # resolution is number of distinct coordinates found
|
||||||
dimension = resolution/numpy.maximum(numpy.ones(3,'d'),resolution-1.0)* \
|
dimension = resolution/np.maximum(np.ones(3,'d'),resolution-1.0)* \
|
||||||
numpy.array([max(map(float,grid[0].keys()))-min(map(float,grid[0].keys())),\
|
np.array([max(map(float,grid[0].keys()))-min(map(float,grid[0].keys())),\
|
||||||
max(map(float,grid[1].keys()))-min(map(float,grid[1].keys())),\
|
max(map(float,grid[1].keys()))-min(map(float,grid[1].keys())),\
|
||||||
max(map(float,grid[2].keys()))-min(map(float,grid[2].keys())),\
|
max(map(float,grid[2].keys()))-min(map(float,grid[2].keys())),\
|
||||||
],'d') # dimension from bounding box, corrected for cell-centeredness
|
],'d') # dimension from bounding box, corrected for cell-centeredness
|
||||||
else:
|
else:
|
||||||
resolution = numpy.array(options.resolution,'i')
|
resolution = np.array(options.resolution,'i')
|
||||||
dimension = numpy.array(options.dimension,'d')
|
dimension = np.array(options.dimension,'d')
|
||||||
|
|
||||||
if resolution[2] == 1:
|
if resolution[2] == 1:
|
||||||
options.packing[2] = 1
|
options.packing[2] = 1
|
||||||
options.shift[2] = 0
|
options.shift[2] = 0
|
||||||
dimension[2] = min(dimension[:2]/resolution[:2]) # z spacing equal to smaller of x or y spacing
|
dimension[2] = min(dimension[:2]/resolution[:2]) # z spacing equal to smaller of x or y spacing
|
||||||
|
|
||||||
packing = numpy.array(options.packing,'i')
|
packing = np.array(options.packing,'i')
|
||||||
shift = numpy.array(options.shift,'i')
|
shift = np.array(options.shift,'i')
|
||||||
downSized = numpy.maximum(numpy.ones(3,'i'),resolution//packing)
|
downSized = np.maximum(np.ones(3,'i'),resolution//packing)
|
||||||
outSize = numpy.ceil(numpy.array(resolution,'d')/numpy.array(packing,'d'))
|
outSize = np.ceil(np.array(resolution,'d')/np.array(packing,'d'))
|
||||||
|
|
||||||
print '\t%s @ %s --> %s'%(dimension,resolution,downSized)
|
print '\t%s @ %s --> %s'%(dimension,resolution,downSized)
|
||||||
|
|
||||||
|
@ -144,9 +115,9 @@ for file in files:
|
||||||
|
|
||||||
# ------------------------------------------ process data ---------------------------------------
|
# ------------------------------------------ process data ---------------------------------------
|
||||||
|
|
||||||
dataavg = numpy.zeros(outSize.tolist()+[len(table.labels)])
|
dataavg = np.zeros(outSize.tolist()+[len(table.labels)])
|
||||||
datavar = numpy.zeros(outSize.tolist()+[len(table.labels)])
|
datavar = np.zeros(outSize.tolist()+[len(table.labels)])
|
||||||
p = numpy.zeros(3,'i')
|
p = np.zeros(3,'i')
|
||||||
|
|
||||||
table.data_rewind()
|
table.data_rewind()
|
||||||
for p[2] in xrange(resolution[2]):
|
for p[2] in xrange(resolution[2]):
|
||||||
|
@ -154,7 +125,7 @@ for file in files:
|
||||||
for p[0] in xrange(resolution[0]):
|
for p[0] in xrange(resolution[0]):
|
||||||
d = ((p-shift)%resolution)//packing
|
d = ((p-shift)%resolution)//packing
|
||||||
table.data_read()
|
table.data_read()
|
||||||
dataavg[d[0],d[1],d[2],:] += numpy.array(table.data_asFloat(),'d') # convert to numpy array
|
dataavg[d[0],d[1],d[2],:] += np.array(table.data_asFloat(),'d') # convert to np array
|
||||||
|
|
||||||
dataavg /= packing.prod()
|
dataavg /= packing.prod()
|
||||||
|
|
||||||
|
@ -164,9 +135,9 @@ for file in files:
|
||||||
for p[0] in xrange(resolution[0]):
|
for p[0] in xrange(resolution[0]):
|
||||||
d = ((p-shift)%resolution)//packing
|
d = ((p-shift)%resolution)//packing
|
||||||
table.data_read()
|
table.data_read()
|
||||||
datavar[d[0],d[1],d[2],:] += (numpy.array(table.data_asFloat(),'d') - dataavg[d[0],d[1],d[2],:])**2
|
datavar[d[0],d[1],d[2],:] += (np.array(table.data_asFloat(),'d') - dataavg[d[0],d[1],d[2],:])**2
|
||||||
|
|
||||||
datavar = numpy.sqrt(datavar/packing.prod())
|
datavar = np.sqrt(datavar/packing.prod())
|
||||||
|
|
||||||
posOffset = (shift+[0.5,0.5,0.5])*dimension/resolution
|
posOffset = (shift+[0.5,0.5,0.5])*dimension/resolution
|
||||||
elementSize = dimension/resolution*packing
|
elementSize = dimension/resolution*packing
|
||||||
|
|
|
@ -1,38 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,re,sys,math,string,damask
|
import os,re,sys,math,string
|
||||||
from optparse import OptionParser, Option
|
import damask
|
||||||
|
from optparse import OptionParser
|
||||||
# -----------------------------
|
|
||||||
class extendableOption(Option):
|
|
||||||
# -----------------------------
|
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] dfile[s]', description = """
|
||||||
Tag scalar, vectorial, and/or tensorial data header labels by specified suffix.
|
Tag scalar, vectorial, and/or tensorial data header labels by specified suffix.
|
||||||
|
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
""", version = scriptID)
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_option('-l','--tag', dest='tag', \
|
parser.add_option('-l','--tag', dest='tag', \
|
||||||
help='tag to use as suffix for labels')
|
help='tag to use as suffix for labels')
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
|
import os,string,math,sys
|
||||||
import os,numpy,string,math,sys
|
import numpy as np
|
||||||
from optparse import OptionParser, Option
|
from optparse import OptionParser
|
||||||
from vtk import *
|
from vtk import *
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def getHeader(filename,sizeFastIndex,sizeSlowIndex,stepsize):
|
def getHeader(filename,sizeFastIndex,sizeSlowIndex,stepsize):
|
||||||
|
@ -79,8 +81,7 @@ def getDataLine(angles,x,y,validData=True):
|
||||||
parser = OptionParser(usage='%prog options [file[s]]', description = """
|
parser = OptionParser(usage='%prog options [file[s]]', description = """
|
||||||
Builds a ang files from a vtk file.
|
Builds a ang files from a vtk file.
|
||||||
|
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
""", version = scriptID)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
parser.add_option('--disp','--displacement',dest='dispLabel', \
|
parser.add_option('--disp','--displacement',dest='dispLabel', \
|
||||||
|
@ -137,7 +138,7 @@ for filename in filenames:
|
||||||
|
|
||||||
# check for othogonality of normal and up vector
|
# check for othogonality of normal and up vector
|
||||||
|
|
||||||
if numpy.dot(numpy.array(options.normal),numpy.array(options.up)) > 1e-3:
|
if np.dot(np.array(options.normal),np.array(options.up)) > 1e-3:
|
||||||
parser.error('normal vector and up vector have to be orthogonal')
|
parser.error('normal vector and up vector have to be orthogonal')
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,12 +222,12 @@ for filename in filenames:
|
||||||
# "R" rotates coordinates from the mesh system into the TSL system
|
# "R" rotates coordinates from the mesh system into the TSL system
|
||||||
|
|
||||||
if options.verbose: sys.stdout.write("\nGETTING COORDINATE SYSTEM FOR ANG FILES\n")
|
if options.verbose: sys.stdout.write("\nGETTING COORDINATE SYSTEM FOR ANG FILES\n")
|
||||||
z = numpy.array(options.normal,dtype='float')
|
z = np.array(options.normal,dtype='float')
|
||||||
z = z / numpy.linalg.norm(z)
|
z = z / np.linalg.norm(z)
|
||||||
x = numpy.array(options.up,dtype='float')
|
x = np.array(options.up,dtype='float')
|
||||||
x = x / numpy.linalg.norm(x)
|
x = x / np.linalg.norm(x)
|
||||||
y = numpy.cross(z,x)
|
y = np.cross(z,x)
|
||||||
R = numpy.array([x,y,z])
|
R = np.array([x,y,z])
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
sys.stdout.write(" axis (x: up direction, z: slice normal)\n")
|
sys.stdout.write(" axis (x: up direction, z: slice normal)\n")
|
||||||
sys.stdout.write(" x (% .8f % .8f % .8f)\n"%tuple(x))
|
sys.stdout.write(" x (% .8f % .8f % .8f)\n"%tuple(x))
|
||||||
|
@ -237,12 +238,12 @@ for filename in filenames:
|
||||||
# Get bounding box in rotated system (x,y,z)
|
# Get bounding box in rotated system (x,y,z)
|
||||||
|
|
||||||
if options.verbose: sys.stdout.write("\nGETTING BOUNDING BOX IN ROTATED SYSTEM\n")
|
if options.verbose: sys.stdout.write("\nGETTING BOUNDING BOX IN ROTATED SYSTEM\n")
|
||||||
rotatedbox = [[numpy.inf,-numpy.inf] for i in range(3)] # bounding box in rotated TSL system
|
rotatedbox = [[np.inf,-np.inf] for i in range(3)] # bounding box in rotated TSL system
|
||||||
for n in range(8): # loop over eight vertices of mesh bounding box
|
for n in range(8): # loop over eight vertices of mesh bounding box
|
||||||
vert = numpy.array([box[0+(n/1)%2],
|
vert = np.array([box[0+(n/1)%2],
|
||||||
box[2+(n/2)%2],
|
box[2+(n/2)%2],
|
||||||
box[4+(n/4)%2]]) # vertex in mesh system
|
box[4+(n/4)%2]]) # vertex in mesh system
|
||||||
rotatedvert = numpy.dot(R,vert) # vertex in rotated system
|
rotatedvert = np.dot(R,vert) # vertex in rotated system
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
rotatedbox[i][0] = min(rotatedbox[i][0],rotatedvert[i])
|
rotatedbox[i][0] = min(rotatedbox[i][0],rotatedvert[i])
|
||||||
rotatedbox[i][1] = max(rotatedbox[i][1],rotatedvert[i])
|
rotatedbox[i][1] = max(rotatedbox[i][1],rotatedvert[i])
|
||||||
|
@ -292,10 +293,10 @@ for filename in filenames:
|
||||||
for k in xrange(Npoints[2]):
|
for k in xrange(Npoints[2]):
|
||||||
for j in xrange(Npoints[0]):
|
for j in xrange(Npoints[0]):
|
||||||
for i in xrange(Npoints[1]): # y is fastest index
|
for i in xrange(Npoints[1]): # y is fastest index
|
||||||
rotatedpoint = numpy.array([rotatedbox[0][0] + (float(j) + 0.5) * options.resolution,
|
rotatedpoint = np.array([rotatedbox[0][0] + (float(j) + 0.5) * options.resolution,
|
||||||
rotatedbox[1][0] + (float(i) + 0.5) * options.resolution,
|
rotatedbox[1][0] + (float(i) + 0.5) * options.resolution,
|
||||||
rotatedbox[2][0] + (float(k) + 0.5) * options.distance ]) # point in rotated system
|
rotatedbox[2][0] + (float(k) + 0.5) * options.distance ]) # point in rotated system
|
||||||
point = numpy.dot(R.T,rotatedpoint) # point in mesh system
|
point = np.dot(R.T,rotatedpoint) # point in mesh system
|
||||||
points.InsertNextPoint(list(point))
|
points.InsertNextPoint(list(point))
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
sys.stdout.write("\rGENERATING POINTS FOR POINT GRID %d%%" %(100*(Npoints[1]*(k*Npoints[0]+j)+i+1)/totalNpoints))
|
sys.stdout.write("\rGENERATING POINTS FOR POINT GRID %d%%" %(100*(Npoints[1]*(k*Npoints[0]+j)+i+1)/totalNpoints))
|
||||||
|
@ -363,7 +364,7 @@ for filename in filenames:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
sys.stdout.write("\nWRITING OUT ANG FILES\n")
|
sys.stdout.write("\nWRITING OUT ANG FILES\n")
|
||||||
sys.stdout.write(" scaling all length with %f\n"%options.scale)
|
sys.stdout.write(" scaling all length with %f\n"%options.scale)
|
||||||
x0,y0,z0 = numpy.dot(R,pointgrid.GetPoint(0)) # first point on slice defines origin
|
x0,y0,z0 = np.dot(R,pointgrid.GetPoint(0)) # first point on slice defines origin
|
||||||
for sliceN in range(Npoints[2]):
|
for sliceN in range(Npoints[2]):
|
||||||
|
|
||||||
# Open file and write header
|
# Open file and write header
|
||||||
|
@ -396,7 +397,7 @@ for filename in filenames:
|
||||||
|
|
||||||
# write data to ang file
|
# write data to ang file
|
||||||
|
|
||||||
x,y,z = numpy.dot(R,pointgrid.GetPoint(i)) # point in rotated TSL system
|
x,y,z = np.dot(R,pointgrid.GetPoint(i)) # point in rotated TSL system
|
||||||
x -= x0 # first point on slice defines origin
|
x -= x0 # first point on slice defines origin
|
||||||
y -= y0 # first point on slice defines origin
|
y -= y0 # first point on slice defines origin
|
||||||
x *= options.scale
|
x *= options.scale
|
||||||
|
@ -423,7 +424,7 @@ for filename in filenames:
|
||||||
P = [rotatedbox[0][(n/1)%2],
|
P = [rotatedbox[0][(n/1)%2],
|
||||||
rotatedbox[1][(n/2)%2],
|
rotatedbox[1][(n/2)%2],
|
||||||
rotatedbox[2][(n/4)%2]]
|
rotatedbox[2][(n/4)%2]]
|
||||||
boxpoints.InsertNextPoint(list(numpy.dot(R.T,numpy.array(P))))
|
boxpoints.InsertNextPoint(list(np.dot(R.T,np.array(P))))
|
||||||
box = vtkHexahedron()
|
box = vtkHexahedron()
|
||||||
for n,i in enumerate([0,1,3,2,4,5,7,6]):
|
for n,i in enumerate([0,1,3,2,4,5,7,6]):
|
||||||
box.GetPointIds().SetId(n,i)
|
box.GetPointIds().SetId(n,i)
|
||||||
|
|
|
@ -5,7 +5,8 @@ import os, sys, string, glob, re
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def findTag(filename,tag):
|
def findTag(filename,tag):
|
||||||
|
@ -27,8 +28,8 @@ def findTag(filename,tag):
|
||||||
|
|
||||||
parser = OptionParser(usage='%prog [options] directory', description = """
|
parser = OptionParser(usage='%prog [options] directory', description = """
|
||||||
Add data from an ASCII table to a VTK geometry file.
|
Add data from an ASCII table to a VTK geometry file.
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-s','--sub', action='store_true', dest='subdir', \
|
parser.add_option('-s','--sub', action='store_true', dest='subdir', \
|
||||||
help='include files in subdirectories [%default]')
|
help='include files in subdirectories [%default]')
|
||||||
|
|
|
@ -1,36 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,numpy,vtk
|
import os,sys,string,re,vtk
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
from optparse import OptionParser
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
class extendedOption(Option):
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
|
||||||
Add scalar and RGB tuples from ASCIItable to existing VTK point cloud (.vtp).
|
Add scalar and RGB tuples from ASCIItable to existing VTK point cloud (.vtp).
|
||||||
""" + string.replace(scriptID,'\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-v', '--vtk', dest='vtk', \
|
parser.add_option('-v', '--vtk', dest='vtk', \
|
||||||
help = 'VTK file name')
|
help = 'VTK file name')
|
||||||
|
|
|
@ -1,36 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,numpy,vtk
|
import os,sys,string,re,vtk
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
from optparse import OptionParser
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
class extendedOption(Option):
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
|
||||||
Add scalar and RGB tuples from ASCIItable to existing VTK voxel cloud (.vtu).
|
Add scalar and RGB tuples from ASCIItable to existing VTK voxel cloud (.vtu).
|
||||||
""" + string.replace(scriptID,'\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-v', '--vtk', dest='vtk', \
|
parser.add_option('-v', '--vtk', dest='vtk', \
|
||||||
help = 'VTK file name')
|
help = 'VTK file name')
|
||||||
|
|
|
@ -1,37 +1,22 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,numpy,vtk
|
import os,sys,string,re,vtk
|
||||||
import damask
|
import damask
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
from optparse import OptionParser
|
||||||
|
|
||||||
scriptID = '$Id: vtk_addVoxelgridData.py 3064 2014-04-03 01:00:00Z p.eisenlohr $'
|
scriptID = string.replace('$Id: addCalculation.py 3465 2014-09-12 14:14:55Z MPIE\m.diehl $','\n','\\n')
|
||||||
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
class extendedOption(Option):
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
|
||||||
Add scalar and RGB tuples from ASCIItable to existing VTK voxel grid (.vtr).
|
Add scalar and RGB tuples from ASCIItable to existing VTK voxel grid (.vtr).
|
||||||
""" + string.replace(scriptID,'\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-v', '--vtk', dest='vtk', type='string',
|
parser.add_option('-v', '--vtk', dest='vtk', type='string',
|
||||||
help = 'VTK file name')
|
help = 'VTK file name')
|
||||||
|
|
|
@ -1,36 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,numpy,vtk
|
import os,sys,string,re,vtk
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
from optparse import OptionParser
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
scriptName = scriptID.split()[1]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
class extendedOption(Option):
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
|
||||||
Add grain index based on similitude of crystal lattice orientation.
|
Add grain index based on similitude of crystal lattice orientation.
|
||||||
""" + string.replace(scriptID,'\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-p', '--positions', dest='pos', \
|
parser.add_option('-p', '--positions', dest='pos', \
|
||||||
help = 'coordinate label')
|
help = 'coordinate label')
|
||||||
|
|
|
@ -2,19 +2,20 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os, sys, string, re, shutil
|
import os, sys, string, re, shutil
|
||||||
|
import damask
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from vtk import *
|
from vtk import *
|
||||||
|
|
||||||
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
# -----------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN FUNCTION STARTS HERE
|
# MAIN
|
||||||
# -----------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
# --- input parsing
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
|
|
||||||
parser = OptionParser(usage='%prog [options] vtkfile', description = """
|
""", version = scriptID)
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_option('-v','--vector', nargs=3, dest='vector', \
|
parser.add_option('-v','--vector', nargs=3, dest='vector', \
|
||||||
help='suffices indicating vector components [%default]')
|
help='suffices indicating vector components [%default]')
|
||||||
|
|
|
@ -1,35 +1,14 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,numpy,vtk
|
import os,sys,string,re,vtk
|
||||||
|
import numpy as np
|
||||||
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = '$Id$'
|
||||||
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
|
||||||
class extendedOption(Option):
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
|
||||||
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
||||||
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
|
||||||
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
||||||
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
||||||
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
||||||
|
|
||||||
def take_action(self, action, dest, opt, value, values, parser):
|
|
||||||
if action == "extend":
|
|
||||||
lvalue = value.split(",")
|
|
||||||
values.ensure_value(dest, []).extend(lvalue)
|
|
||||||
else:
|
|
||||||
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
|
||||||
# MAIN
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
|
||||||
synonyms = {
|
synonyms = {
|
||||||
'grid': ['resolution'],
|
'grid': ['resolution'],
|
||||||
'size': ['dimension'],
|
'size': ['dimension'],
|
||||||
|
@ -46,11 +25,14 @@ mappings = {
|
||||||
'microstructures': lambda x: int(x),
|
'microstructures': lambda x: int(x),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
Create hexahedral voxels around points in an ASCIItable.
|
Create hexahedral voxels around points in an ASCIItable.
|
||||||
""" + string.replace(scriptID,'\n','\\n')
|
|
||||||
)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-p', '--positions', dest='pos', type='string',
|
parser.add_option('-p', '--positions', dest='pos', type='string',
|
||||||
help = 'coordinate label')
|
help = 'coordinate label')
|
||||||
|
@ -91,12 +73,11 @@ for file in files:
|
||||||
|
|
||||||
table = damask.ASCIItable(file['input'],file['croak'],False) # make unbuffered ASCII_table
|
table = damask.ASCIItable(file['input'],file['croak'],False) # make unbuffered ASCII_table
|
||||||
table.head_read() # read ASCII header info
|
table.head_read() # read ASCII header info
|
||||||
|
|
||||||
#--- interpret header ----------------------------------------------------------------------------
|
#--- interpret header ----------------------------------------------------------------------------
|
||||||
info = {
|
info = {
|
||||||
'grid': numpy.zeros(3,'i'),
|
'grid': np.zeros(3,'i'),
|
||||||
'size': numpy.zeros(3,'d'),
|
'size': np.zeros(3,'d'),
|
||||||
'origin': numpy.zeros(3,'d'),
|
'origin': np.zeros(3,'d'),
|
||||||
'homogenization': 0,
|
'homogenization': 0,
|
||||||
'microstructures': 0,
|
'microstructures': 0,
|
||||||
}
|
}
|
||||||
|
@ -121,18 +102,17 @@ for file in files:
|
||||||
'homogenization: %i\n'%info['homogenization'] + \
|
'homogenization: %i\n'%info['homogenization'] + \
|
||||||
'microstructures: %i\n'%info['microstructures'])
|
'microstructures: %i\n'%info['microstructures'])
|
||||||
|
|
||||||
if numpy.any(info['grid'] < 1):
|
if np.any(info['grid'] < 1):
|
||||||
file['croak'].write('invalid grid a b c.\n')
|
file['croak'].write('invalid grid a b c.\n')
|
||||||
continue
|
continue
|
||||||
if numpy.any(info['size'] <= 0.0):
|
if np.any(info['size'] <= 0.0):
|
||||||
file['croak'].write('invalid size x y z.\n')
|
file['croak'].write('invalid size x y z.\n')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
info['size'] = numpy.ones(3)
|
info['size'] = np.ones(3)
|
||||||
info['grid'] = info['size'] / options.size
|
info['grid'] = info['size'] / options.size
|
||||||
info['origin'] = options.origin
|
info['origin'] = options.origin
|
||||||
|
|
||||||
|
|
||||||
# --------------- figure out columns to process
|
# --------------- figure out columns to process
|
||||||
active = {}
|
active = {}
|
||||||
|
@ -156,7 +136,7 @@ for file in files:
|
||||||
|
|
||||||
# ------------------------------------------ process data ---------------------------------------
|
# ------------------------------------------ process data ---------------------------------------
|
||||||
|
|
||||||
hexPoints = numpy.array([[-1,-1,-1],
|
hexPoints = np.array([[-1,-1,-1],
|
||||||
[ 1,-1,-1],
|
[ 1,-1,-1],
|
||||||
[ 1, 1,-1],
|
[ 1, 1,-1],
|
||||||
[-1, 1,-1],
|
[-1, 1,-1],
|
||||||
|
@ -175,9 +155,9 @@ for file in files:
|
||||||
table.data[:,0:3] *= info['size']
|
table.data[:,0:3] *= info['size']
|
||||||
table.data[:,0:3] += info['origin']
|
table.data[:,0:3] += info['origin']
|
||||||
|
|
||||||
# minD = numpy.array(options.size,dtype=float)
|
# minD = np.array(options.size,dtype=float)
|
||||||
# for i in xrange(3):
|
# for i in xrange(3):
|
||||||
# coords = numpy.unique(table.data[:,i])
|
# coords = np.unique(table.data[:,i])
|
||||||
# minD[i] = coords[-1]-coords[0]
|
# minD[i] = coords[-1]-coords[0]
|
||||||
# for j in xrange(len(coords)-1):
|
# for j in xrange(len(coords)-1):
|
||||||
# d = coords[j+1]-coords[j]
|
# d = coords[j+1]-coords[j]
|
||||||
|
|
Loading…
Reference in New Issue