This commit is contained in:
Martin Diehl 2019-11-24 08:52:46 +01:00
parent c9b1944493
commit 6060abb375
3 changed files with 6 additions and 7 deletions

View File

@ -5,9 +5,6 @@ import sys
from io import StringIO from io import StringIO
from optparse import OptionParser from optparse import OptionParser
from scipy import ndimage
import numpy as np
import damask import damask

View File

@ -5,8 +5,6 @@ import sys
from io import StringIO from io import StringIO
from optparse import OptionParser from optparse import OptionParser
import numpy as np
import damask import damask

View File

@ -311,8 +311,8 @@ class Geom():
""" """
header = self.get_header() header = self.get_header()
grid = self.get_grid() grid = self.get_grid()
format_string = '%{}i'.format(1+int(np.floor(np.log10(np.nanmax(self.microstructure))))) if self.microstructure.dtype == int \ format_string = '%g' if self.microstructure in np.sctypes['float'] else \
else '%g' '%{}i'.format(1+int(np.floor(np.log10(np.nanmax(self.microstructure)))))
np.savetxt(fname, np.savetxt(fname,
self.microstructure.reshape([grid[0],np.prod(grid[1:])],order='F').T, self.microstructure.reshape([grid[0],np.prod(grid[1:])],order='F').T,
header='\n'.join(header), fmt=format_string, comments='') header='\n'.join(header), fmt=format_string, comments='')
@ -390,12 +390,14 @@ class Geom():
def mirror(self,directions,reflect=False): def mirror(self,directions,reflect=False):
""" """
Mirror microstructure along given directions. Mirror microstructure along given directions.
Parameters Parameters
---------- ----------
directions : iterable containing str directions : iterable containing str
direction(s) along which the microstructure is mirrored. Valid entries are 'x', 'y', 'z'. direction(s) along which the microstructure is mirrored. Valid entries are 'x', 'y', 'z'.
reflect : bool, optional reflect : bool, optional
reflect (include) outermost layers. reflect (include) outermost layers.
""" """
valid = {'x','y','z'} valid = {'x','y','z'}
if not all(isinstance(d, str) for d in directions): if not all(isinstance(d, str) for d in directions):
@ -420,10 +422,12 @@ class Geom():
def clean(self,stencil=3): def clean(self,stencil=3):
""" """
Smooth microstructure by selecting most frequent index within given stencil at each location. Smooth microstructure by selecting most frequent index within given stencil at each location.
Parameters Parameters
---------- ----------
stencil : int, optional stencil : int, optional
size of smoothing stencil. size of smoothing stencil.
""" """
def mostFrequent(arr): def mostFrequent(arr):
unique, inverse = np.unique(arr, return_inverse=True) unique, inverse = np.unique(arr, return_inverse=True)