vicinityOffset to specific triggering IDs instead of just any other ID
This commit is contained in:
parent
d17debbd5e
commit
1b12457fe6
|
@ -10,13 +10,24 @@ import damask
|
||||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||||
scriptID = ' '.join([scriptName,damask.version])
|
scriptID = ' '.join([scriptName,damask.version])
|
||||||
|
|
||||||
|
def taintedNeighborhood(stencil,trigger=[],size=1):
|
||||||
|
|
||||||
|
me = stencil[stencil.shape[0]//2]
|
||||||
|
if len(trigger) == 0:
|
||||||
|
return np.any(stencil != me)
|
||||||
|
if me in trigger:
|
||||||
|
trigger = set(trigger)
|
||||||
|
trigger.remove(me)
|
||||||
|
trigger = list(trigger)
|
||||||
|
return np.any(np.in1d(stencil,np.array(trigger)))
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
Offset microstructure index for points which see a microstructure different from themselves within a given (cubic) vicinity,
|
Offset microstructure index for points which see a microstructure different from themselves
|
||||||
i.e. within the region close to a grain/phase boundary.
|
(or listed as triggers) within a given (cubic) vicinity, i.e. within the region close to a grain/phase boundary.
|
||||||
|
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
|
@ -29,6 +40,9 @@ parser.add_option('-m', '--microstructureoffset',
|
||||||
type = 'int', metavar = 'int',
|
type = 'int', metavar = 'int',
|
||||||
help = 'offset (positive or negative) for tagged microstructure indices. '+
|
help = 'offset (positive or negative) for tagged microstructure indices. '+
|
||||||
'"0" selects maximum microstructure index [%default]')
|
'"0" selects maximum microstructure index [%default]')
|
||||||
|
parser.add_option('-t', '--trigger',
|
||||||
|
action = 'extend', dest = 'trigger', metavar = '<int LIST>',
|
||||||
|
help = 'list of microstructure indices triggering a change')
|
||||||
parser.add_option('-n', '--nonperiodic',
|
parser.add_option('-n', '--nonperiodic',
|
||||||
dest = 'mode',
|
dest = 'mode',
|
||||||
action = 'store_const', const = 'nearest',
|
action = 'store_const', const = 'nearest',
|
||||||
|
@ -36,10 +50,13 @@ parser.add_option('-n', '--nonperiodic',
|
||||||
|
|
||||||
parser.set_defaults(vicinity = 1,
|
parser.set_defaults(vicinity = 1,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
|
trigger = [],
|
||||||
mode = 'wrap',
|
mode = 'wrap',
|
||||||
)
|
)
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
options.trigger = np.array(options.trigger, dtype=int)
|
||||||
|
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
# --- loop over input files -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -84,9 +101,12 @@ for name in filenames:
|
||||||
|
|
||||||
if options.offset == 0: options.offset = microstructure.max()
|
if options.offset == 0: options.offset = microstructure.max()
|
||||||
|
|
||||||
microstructure = np.where(ndimage.filters.maximum_filter(microstructure,size=1+2*options.vicinity,mode=options.mode) ==
|
microstructure = np.where(ndimage.filters.generic_filter(microstructure,
|
||||||
ndimage.filters.minimum_filter(microstructure,size=1+2*options.vicinity,mode=options.mode),
|
taintedNeighborhood,
|
||||||
microstructure, microstructure + options.offset)
|
size=1+2*options.vicinity,mode=options.mode,
|
||||||
|
extra_arguments=(),
|
||||||
|
extra_keywords={"trigger":options.trigger,"size":1+2*options.vicinity}),
|
||||||
|
microstructure + options.offset,microstructure)
|
||||||
|
|
||||||
newInfo['microstructures'] = microstructure.max()
|
newInfo['microstructures'] = microstructure.max()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue