consistent and correct number of leading zeros

This commit is contained in:
Martin Diehl 2020-03-19 08:45:25 +01:00
parent b5899b51e1
commit 0871111c11
3 changed files with 32 additions and 29 deletions

View File

@ -59,15 +59,18 @@ options = parser.parse_args()
for filename in options.filenames:
f = damask.Result(filename)
N_digits = int(np.floor(np.log10(int(f.increments[-1][3:]))))+1
f.pick('increments',options.inc)
for increment in damask.util.show_progress(f.iterate('increments'),len(f.selection['increments'])):
for inc in damask.util.show_progress(f.iterate('increments'),len(f.selection['increments'])):
dirname = os.path.abspath(os.path.join(os.path.dirname(filename),options.dir))
try:
os.mkdir(dirname)
except FileExistsError:
pass
o = h5py.File(dirname + '/' + os.path.splitext(filename)[0] + '_{}.dream3D'.format(increment),'w')
o = h5py.File(dirname + '/' + os.path.splitext(filename)[0] \
+ 'inc_{}.dream3D'.format(inc[3:].zfill(N_digits)),'w')
o.attrs['DADF5toDREAM3D'] = '1.0'
o.attrs['FileVersion'] = '7.0'

View File

@ -1039,7 +1039,7 @@ class Result:
elif mode.lower()=='point':
v = VTK.from_polyData(self.cell_coordinates())
N_digits = int(np.floor(np.log10(min(int(self.increments[-1][3:]),1))))+1
N_digits = int(np.floor(np.log10(int(self.increments[-1][3:]))))+1
for i,inc in enumerate(util.show_progress(self.iterate('increments'),len(self.selection['increments']))):

View File

@ -258,7 +258,7 @@ def scale_to_coprime(v):
return m//reduce(np.gcd,m)
class return_message():
class return_message:
"""Object with formatted return message."""
def __init__(self,message):