phasing out python shell scripts

This commit is contained in:
Martin Diehl 2019-11-24 15:13:26 +01:00
parent 8186be6293
commit 816e86ae5f
2 changed files with 27 additions and 15 deletions

View File

@ -55,20 +55,9 @@ for name in filenames:
np.array([o*float(n.lower().replace('x','')) if n.lower().endswith('x') \ np.array([o*float(n.lower().replace('x','')) if n.lower().endswith('x') \
else float(n) for o,n in zip(size,options.size)],dtype=float) else float(n) for o,n in zip(size,options.size)],dtype=float)
damask.util.croak(geom.update(microstructure = geom.scale(new_grid)
ndimage.interpolation.zoom( damask.util.croak(geom.update(microstructure = None,
geom.microstructure, size = new_size))
new_grid/grid,
output=geom.microstructure.dtype,
order=0,
mode='nearest',
prefilter=False,
) if np.any(new_grid != grid) \
else None,
size = new_size))
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
if name is None: geom.to_file(sys.stdout if name is None else name)
sys.stdout.write(str(geom.show()))
else:
geom.to_file(name)

View File

@ -467,6 +467,29 @@ class Geom():
#self.add_comments('tbd') #self.add_comments('tbd')
def scale(self,grid):
"""
Scale microstructure to new grid
Parameters
----------
grid : iterable of int
new grid dimension
"""
return self.update(
ndimage.interpolation.zoom(
self.microstructure,
grid/self.get_grid(),
output=self.microstructure.dtype,
order=0,
mode='nearest',
prefilter=False
)
)
#self.add_comments('tbd')
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.