diff --git a/python/damask/_result.py b/python/damask/_result.py index 412c66f6f..34c6e9437 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1,5 +1,6 @@ import multiprocessing import re +import inspect import glob import os import datetime @@ -502,7 +503,7 @@ class Result: 'meta': { 'Unit': x['meta']['Unit'], 'Description': 'Absolute value of {} ({})'.format(x['label'],x['meta']['Description']), - 'Creator': 'damask.Result.add_abs v{}'.format(version) + 'Creator': 'add_absolute' } } def add_absolute(self,x): @@ -530,7 +531,7 @@ class Result: 'meta': { 'Unit': kwargs['unit'], 'Description': '{} (formula: {})'.format(kwargs['description'],kwargs['formula']), - 'Creator': 'damask.Result.add_calculation v{}'.format(version) + 'Creator': 'add_calculation' } } def add_calculation(self,label,formula,unit='n/a',description=None,vectorized=True): @@ -569,7 +570,7 @@ class Result: 'Description': 'Cauchy stress calculated from {} ({}) '.format(P['label'], P['meta']['Description'])+\ 'and {} ({})'.format(F['label'],F['meta']['Description']), - 'Creator': 'damask.Result.add_Cauchy v{}'.format(version) + 'Creator': 'add_Cauchy' } } def add_Cauchy(self,P='P',F='F'): @@ -595,7 +596,7 @@ class Result: 'meta': { 'Unit': T['meta']['Unit'], 'Description': 'Determinant of tensor {} ({})'.format(T['label'],T['meta']['Description']), - 'Creator': 'damask.Result.add_determinant v{}'.format(version) + 'Creator': 'add_determinant' } } def add_determinant(self,T): @@ -619,7 +620,7 @@ class Result: 'meta': { 'Unit': T['meta']['Unit'], 'Description': 'Deviator of tensor {} ({})'.format(T['label'],T['meta']['Description']), - 'Creator': 'damask.Result.add_deviator v{}'.format(version) + 'Creator': 'add_deviator' } } def add_deviator(self,T): @@ -643,7 +644,7 @@ class Result: 'meta' : { 'Unit': T_sym['meta']['Unit'], 'Description': 'Eigenvalues of {} ({})'.format(T_sym['label'],T_sym['meta']['Description']), - 'Creator': 'damask.Result.add_eigenvalues v{}'.format(version) + 'Creator': 'add_eigenvalues' } } def add_eigenvalues(self,T_sym): @@ -667,7 +668,7 @@ class Result: 'meta' : { 'Unit': '1', 'Description': 'Eigenvectors of {} ({})'.format(T_sym['label'],T_sym['meta']['Description']), - 'Creator': 'damask.Result.add_eigenvectors v{}'.format(version) + 'Creator': 'add_eigenvectors' } } def add_eigenvectors(self,T_sym): @@ -703,7 +704,7 @@ class Result: 'Unit': 'RGB (8bit)', 'Lattice': lattice, 'Description': 'Inverse Pole Figure (IPF) colors along sample direction [{} {} {}]'.format(*m), - 'Creator': 'damask.Result.add_IPFcolor v{}'.format(version) + 'Creator': 'add_IPFcolor' } } def add_IPFcolor(self,q,l): @@ -729,7 +730,7 @@ class Result: 'meta': { 'Unit': T_sym['meta']['Unit'], 'Description': 'Maximum shear component of {} ({})'.format(T_sym['label'],T_sym['meta']['Description']), - 'Creator': 'damask.Result.add_maximum_shear v{}'.format(version) + 'Creator': 'add_maximum_shear' } } def add_maximum_shear(self,T_sym): @@ -756,7 +757,7 @@ class Result: 'meta': { 'Unit': T_sym['meta']['Unit'], 'Description': 'Mises equivalent {} of {} ({})'.format(t,T_sym['label'],T_sym['meta']['Description']), - 'Creator': 'damask.Result.add_Mises v{}'.format(version) + 'Creator': 'add_Mises' } } def add_Mises(self,T_sym): @@ -792,7 +793,7 @@ class Result: 'meta': { 'Unit': x['meta']['Unit'], 'Description': '{}-norm of {} {} ({})'.format(o,t,x['label'],x['meta']['Description']), - 'Creator': 'damask.Result.add_norm v{}'.format(version) + 'Creator': 'add_norm' } } def add_norm(self,x,ord=None): @@ -820,7 +821,7 @@ class Result: 'Description': '2. Kirchhoff stress calculated from {} ({}) '.format(P['label'], P['meta']['Description'])+\ 'and {} ({})'.format(F['label'],F['meta']['Description']), - 'Creator': 'damask.Result.add_PK2 v{}'.format(version) + 'Creator': 'add_PK2' } } def add_PK2(self,P='P',F='F'): @@ -856,7 +857,7 @@ class Result: 'Unit': '1', 'Description': '{} coordinates of stereographic projection of pole (direction/plane) in crystal frame'\ .format('Polar' if polar else 'Cartesian'), - 'Creator' : 'damask.Result.add_pole v{}'.format(version) + 'Creator' : 'add_pole' } } def add_pole(self,q,p,polar=False): @@ -884,7 +885,7 @@ class Result: 'meta': { 'Unit': F['meta']['Unit'], 'Description': 'Rotational part of {} ({})'.format(F['label'],F['meta']['Description']), - 'Creator': 'damask.Result.add_rotational_part v{}'.format(version) + 'Creator': 'add_rotational_part' } } def add_rotational_part(self,F): @@ -908,7 +909,7 @@ class Result: 'meta': { 'Unit': T['meta']['Unit'], 'Description': 'Spherical component of tensor {} ({})'.format(T['label'],T['meta']['Description']), - 'Creator': 'damask.Result.add_spherical v{}'.format(version) + 'Creator': 'add_spherical' } } def add_spherical(self,T): @@ -932,7 +933,7 @@ class Result: 'meta': { 'Unit': F['meta']['Unit'], 'Description': 'Strain tensor of {} ({})'.format(F['label'],F['meta']['Description']), - 'Creator': 'damask.Result.add_strain_tensor v{}'.format(version) + 'Creator': 'add_strain_tensor' } } def add_strain_tensor(self,F='F',t='V',m=0.0): @@ -964,7 +965,7 @@ class Result: 'Unit': F['meta']['Unit'], 'Description': '{} stretch tensor of {} ({})'.format('Left' if t == 'V' else 'Right', F['label'],F['meta']['Description']), - 'Creator': 'damask.Result.add_stretch_tensor v{}'.format(version) + 'Creator': 'add_stretch_tensor' } } def add_stretch_tensor(self,F='F',t='V'): @@ -1031,13 +1032,18 @@ class Result: if self._allow_overwrite and result[0]+'/'+result[1]['label'] in f: dataset = f[result[0]+'/'+result[1]['label']] datset = result[1]['data'] - dataset.attrs['Overwritten'] = True + dataset.attrs['Overwritten'] = 'Yes'.encode() else: dataset = f[result[0]].create_dataset(result[1]['label'],data=result[1]['data']) + now = datetime.datetime.now().astimezone() dataset.attrs['Created'] = now.strftime('%Y-%m-%d %H:%M:%S%z').encode() + for l,v in result[1]['meta'].items(): dataset.attrs[l]=v.encode() + creator = 'damask.Result.{} v{}'.format(dataset.attrs['Creator'].decode(),version) + dataset.attrs['Creator'] = creator.encode() + except OSError as err: print('Could not add dataset: {}.'.format(err)) lock.release()