improved naming

- clearer variable names
- no '-' in attributes
- single source of truth
This commit is contained in:
Martin Diehl 2019-11-30 09:01:37 +01:00
parent 354c0123a1
commit 8f77843b0f
2 changed files with 14 additions and 10 deletions

View File

@ -30,9 +30,14 @@ class DADF5():
"""
with h5py.File(filename,'r') as f:
self.DADF5-major = f.attrs['DADF5-major']
self.DADF5-minor = f.attrs['DADF5-minor']
if self.DADF5-major != 0 or not 2 <= self.DADF5-minor <= 4:
try:
self.version_major = f.attrs['DADF5_version_major']
self.version_minor = f.attrs['DADF5_version_minor']
except KeyError:
self.version_major = f.attrs['DADF5-major']
self.version_minor = f.attrs['DADF5-minor']
if self.version_major != 0 or not 2 <= self.version_minor <= 4:
raise TypeError('Unsupported DADF5 version {} '.format(f.attrs['DADF5-version']))
self.structured = 'grid' in f['geometry'].attrs.keys()
@ -168,7 +173,7 @@ class DADF5():
end increment (included)
"""
if self.DADF5-minor >= 4:
if self.version_minor >= 4:
self.__manage_visible([ 'inc{}'.format(i) for i in range(start,end+1)],'increments','set')
else:
self.__manage_visible(['inc{:05d}'.format(i) for i in range(start,end+1)],'increments','set')
@ -186,7 +191,7 @@ class DADF5():
end increment (included)
"""
if self.DADF5-minor >= 4:
if self.version_minor >= 4:
self.__manage_visible([ 'inc{}'.format(i) for i in range(start,end+1)],'increments','add')
else:
self.__manage_visible(['inc{:05d}'.format(i) for i in range(start,end+1)],'increments','add')
@ -204,7 +209,7 @@ class DADF5():
end increment (included)
"""
if self.DADF5-minor >= 4:
if self.version_minor >= 4:
self.__manage_visible([ 'inc{}'.format(i) for i in range(start,end+1)],'increments','del')
else:
self.__manage_visible(['inc{:05d}'.format(i) for i in range(start,end+1)],'increments','del')

View File

@ -68,10 +68,9 @@ subroutine results_init
write(6,'(a)') ' https://doi.org/10.1007/s40192-017-0084-5'
resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','w',.true.)
call HDF5_addAttribute(resultsFile,'DADF5-version',0.4_pReal)
call HDF5_addAttribute(resultsFile,'DADF5-major',0)
call HDF5_addAttribute(resultsFile,'DADF5-minor',4)
call HDF5_addAttribute(resultsFile,'DAMASK',DAMASKVERSION)
call HDF5_addAttribute(resultsFile,'DADF5_version_major',0)
call HDF5_addAttribute(resultsFile,'DADF5_version_minor',4)
call HDF5_addAttribute(resultsFile,'DAMASK_version',DAMASKVERSION)
call get_command(commandLine)
call HDF5_addAttribute(resultsFile,'call',trim(commandLine))
call HDF5_closeGroup(results_addGroup('mapping'))