Merge branch 'PythonImprovements' into no-crystallite
This commit is contained in:
commit
faeb5a98b4
|
@ -30,6 +30,6 @@ for name in filenames:
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||||
damask.util.croak(geom.renumber)
|
damask.util.croak(geom.renumber())
|
||||||
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
|
||||||
geom.to_file(sys.stdout if name is None else name,pack=False)
|
geom.to_file(sys.stdout if name is None else name,pack=False)
|
||||||
|
|
|
@ -250,11 +250,15 @@ class Geom():
|
||||||
geometry file to read.
|
geometry file to read.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with (open(fname) if isinstance(fname,str) else fname) as f:
|
try:
|
||||||
f.seek(0)
|
f = open(fname)
|
||||||
header_length,keyword = f.readline().split()[:2]
|
except TypeError:
|
||||||
header_length = int(header_length)
|
f = fname
|
||||||
content = f.readlines()
|
|
||||||
|
f.seek(0)
|
||||||
|
header_length,keyword = f.readline().split()[:2]
|
||||||
|
header_length = int(header_length)
|
||||||
|
content = f.readlines()
|
||||||
|
|
||||||
if not keyword.startswith('head') or header_length < 3:
|
if not keyword.startswith('head') or header_length < 3:
|
||||||
raise TypeError('Header length information missing or invalid')
|
raise TypeError('Header length information missing or invalid')
|
||||||
|
@ -320,15 +324,15 @@ class Geom():
|
||||||
plain = not pack
|
plain = not pack
|
||||||
|
|
||||||
if plain:
|
if plain:
|
||||||
format_string = '%g' if self.microstructure in np.sctypes['float'] else \
|
format_string = '%g' if self.microstructure.dtype in np.sctypes['float'] else \
|
||||||
'%{}i'.format(1+int(np.floor(np.log10(np.nanmax(self.microstructure)))))
|
'%{}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='')
|
||||||
else:
|
else:
|
||||||
if isinstance(fname,str):
|
try:
|
||||||
f = open(fname,'w')
|
f = open(fname,'w')
|
||||||
else:
|
except TypeError:
|
||||||
f = fname
|
f = fname
|
||||||
|
|
||||||
compressType = None
|
compressType = None
|
||||||
|
|
Loading…
Reference in New Issue