added option to override bounding box calculation from data with own geometry.
This commit is contained in:
parent
72e9c512bd
commit
e3c4e0ecfc
|
@ -2,6 +2,7 @@
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,itertools,numpy,damask
|
import os,sys,string,itertools,numpy,damask
|
||||||
|
from collections import defaultdict
|
||||||
from optparse import OptionParser, Option
|
from optparse import OptionParser, Option
|
||||||
|
|
||||||
scriptID = '$Id$'
|
scriptID = '$Id$'
|
||||||
|
@ -61,6 +62,8 @@ Examples:
|
||||||
|
|
||||||
parser.add_option('-p', '--positions', dest = 'pos', type = 'string',
|
parser.add_option('-p', '--positions', dest = 'pos', type = 'string',
|
||||||
help = 'coordinate label')
|
help = 'coordinate label')
|
||||||
|
parser.add_option('--boundingbox', dest = 'box', type = 'float', nargs = 6,
|
||||||
|
help = 'min (x,y,z) and max (x,y,z) to specify bounding box [auto]')
|
||||||
parser.add_option('-i', '--index', dest = 'index', type = 'string',
|
parser.add_option('-i', '--index', dest = 'index', type = 'string',
|
||||||
help = 'microstructure index label')
|
help = 'microstructure index label')
|
||||||
parser.add_option('-w','--white', dest = 'whitelist', action = 'extend', type = 'string', \
|
parser.add_option('-w','--white', dest = 'whitelist', action = 'extend', type = 'string', \
|
||||||
|
@ -70,6 +73,7 @@ parser.add_option('-b','--black', dest='blacklist', action='extend', type='str
|
||||||
|
|
||||||
parser.set_defaults(pos = 'pos')
|
parser.set_defaults(pos = 'pos')
|
||||||
parser.set_defaults(index = 'microstructure')
|
parser.set_defaults(index = 'microstructure')
|
||||||
|
parser.set_defaults(box = [])
|
||||||
parser.set_defaults(whitelist = [])
|
parser.set_defaults(whitelist = [])
|
||||||
parser.set_defaults(blacklist = [])
|
parser.set_defaults(blacklist = [])
|
||||||
|
|
||||||
|
@ -113,9 +117,8 @@ for file in files:
|
||||||
theTable.head_read()
|
theTable.head_read()
|
||||||
|
|
||||||
# --------------- figure out columns to process
|
# --------------- figure out columns to process
|
||||||
active = {}
|
active = defaultdict(list)
|
||||||
column = {}
|
column = defaultdict(dict)
|
||||||
head = []
|
|
||||||
|
|
||||||
for datatype,info in datainfo.items():
|
for datatype,info in datainfo.items():
|
||||||
for label in info['label']:
|
for label in info['label']:
|
||||||
|
@ -123,8 +126,6 @@ for file in files:
|
||||||
for key in ['1_'+label,label]:
|
for key in ['1_'+label,label]:
|
||||||
if key in theTable.labels:
|
if key in theTable.labels:
|
||||||
foundIt = True
|
foundIt = True
|
||||||
if datatype not in active: active[datatype] = []
|
|
||||||
if datatype not in column: column[datatype] = {}
|
|
||||||
active[datatype].append(label)
|
active[datatype].append(label)
|
||||||
column[datatype][label] = theTable.labels.index(key) # remember columns of requested data
|
column[datatype][label] = theTable.labels.index(key) # remember columns of requested data
|
||||||
if not foundIt:
|
if not foundIt:
|
||||||
|
@ -140,6 +141,9 @@ for file in files:
|
||||||
|
|
||||||
#--- finding bounding box ------------------------------------------------------------------------------------
|
#--- finding bounding box ------------------------------------------------------------------------------------
|
||||||
boundingBox = numpy.array((numpy.amin(theTable.data[:,0:3],axis = 0),numpy.amax(theTable.data[:,0:3],axis = 0)))
|
boundingBox = numpy.array((numpy.amin(theTable.data[:,0:3],axis = 0),numpy.amax(theTable.data[:,0:3],axis = 0)))
|
||||||
|
if len(options.box) == 6:
|
||||||
|
boundingBox[0,:] = numpy.minimum(options.box[0:3],boundingBox[0,:])
|
||||||
|
boundingBox[1,:] = numpy.maximum(options.box[3:6],boundingBox[1,:])
|
||||||
|
|
||||||
#--- rescaling coordinates ------------------------------------------------------------------------------------
|
#--- rescaling coordinates ------------------------------------------------------------------------------------
|
||||||
theTable.data[:,0:3] -= boundingBox[0,:]
|
theTable.data[:,0:3] -= boundingBox[0,:]
|
||||||
|
|
Loading…
Reference in New Issue