Commit d6a1592f authored by Jait Dixit's avatar Jait Dixit

Rever to Dataset instead of attrs for metadata

parent b61ff2d1
......@@ -892,13 +892,12 @@ class Field(Loggable, Versionable, object):
# ---Serialization---
def _to_hdf5(self, hdf5_group):
# metadata
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group.attrs['distribution_strategy'] = self.distribution_strategy
hdf5_group.attrs['field_type_axes'] = str(self.field_type_axes)
hdf5_group.attrs['domain_axes'] = str(self.domain_axes)
hdf5_group.attrs['num_domain'] = len(self.domain)
hdf5_group.attrs['num_ft'] = len(self.field_type)
hdf5_group['dtype'] = self.dtype.name
hdf5_group['distribution_strategy'] = self.distribution_strategy
hdf5_group['field_type_axes'] = str(self.field_type_axes)
hdf5_group['domain_axes'] = str(self.domain_axes)
hdf5_group['num_domain'] = len(self.domain)
hdf5_group['num_ft'] = len(self.field_type)
ret_dict = {
'val' : self.val
......@@ -921,20 +920,20 @@ class Field(Loggable, Versionable, object):
new_field.__class__ = cls
# set values
temp_domain = []
for i in range(hdf5_group.attrs['num_domain']):
for i in range(hdf5_group['num_domain'][()]):
temp_domain.append(loopback_get('s_' + str(i)))
new_field.domain = tuple(temp_domain)
temp_ft = []
for i in range(hdf5_group.attrs['num_ft']):
for i in range(hdf5_group['num_ft'][()]):
temp_domain.append(loopback_get('ft_' + str(i)))
new_field.field_type = tuple(temp_ft)
exec('new_field.domain_axes = ' + hdf5_group.attrs['domain_axes'])
exec('new_field.field_type_axes = ' + hdf5_group.attrs['field_type_axes'])
exec('new_field.domain_axes = ' + hdf5_group['domain_axes'][()])
exec('new_field.field_type_axes = ' + hdf5_group['field_type_axes'][()])
new_field._val = loopback_get('val')
new_field.dtype = np.dtype(hdf5_group.attrs['dtype'])
new_field.distribution_strategy = hdf5_group.attrs['distribution_strategy']
new_field.dtype = np.dtype(hdf5_group['dtype'][()])
new_field.distribution_strategy = hdf5_group['distribution_strategy'][()]
return new_field
......
......@@ -215,8 +215,7 @@ class GLSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['nlat'] = self.nlat
hdf5_group['nlon'] = self.nlon
# metadata
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group['dtype'] = self.dtype.name
return None
......@@ -225,7 +224,7 @@ class GLSpace(Versionable, Space):
result = cls(
nlat=hdf5_group['nlat'][()],
nlon=hdf5_group['nlon'][()],
dtype=np.dtype(hdf5_group.attrs['dtype'])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
......@@ -209,16 +209,13 @@ class HPSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['nside'] = self.nside
# metadata
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group['dtype'] = self.dtype.name
return None
@classmethod
def _from_hdf5(cls, hdf5_group, loopback_get):
result = cls(
nside=hdf5_group['nside'][()],
dtype=np.dtype(hdf5_group.attrs['dtype'])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
......@@ -187,15 +187,13 @@ class LMSpace(Versionable, Space):
def _to_hdf5(self, hdf5_group):
hdf5_group['lmax'] = self.lmax
# metadata
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group['dtype'] = self.dtype.name
return None
@classmethod
def _from_hdf5(cls, hdf5_group, loopback_get):
result = cls(
lmax=hdf5_group['lmax'][()],
dtype=np.dtype(hdf5_group.attrs['dtype'])
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
......@@ -163,11 +163,10 @@ class PowerSpace(Versionable, Space):
hdf5_group['kindex'] = self.kindex
hdf5_group['rho'] = self.rho
hdf5_group['pundex'] = self.pundex
# metadata
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group.attrs['log'] = self.log
hdf5_group.attrs['nbin'] = str(self.nbin)
hdf5_group.attrs['binbounds'] = str(self.binbounds)
hdf5_group['dtype'] = self.dtype.name
hdf5_group['log'] = self.log
hdf5_group['nbin'] = str(self.nbin)
hdf5_group['binbounds'] = str(self.binbounds)
return {
'harmonic_domain': self.harmonic_domain,
......@@ -182,11 +181,11 @@ class PowerSpace(Versionable, Space):
# reset class
new_ps.__class__ = cls
# set all values
new_ps.dtype = np.dtype(hdf5_group.attrs['dtype'])
new_ps.dtype = np.dtype(hdf5_group['dtype'][()])
new_ps._harmonic_domain = loopback_get('harmonic_domain')
new_ps._log = hdf5_group.attrs['log']
exec('new_ps._nbin = ' + hdf5_group.attrs['nbin'])
exec('new_ps._binbounds = ' + hdf5_group.attrs['binbounds'])
new_ps._log = hdf5_group['log'][()]
exec('new_ps._nbin = ' + hdf5_group['nbin'][()])
exec('new_ps._binbounds = ' + hdf5_group['binbounds'][()])
new_ps._pindex = loopback_get('pindex')
new_ps._kindex = hdf5_group['kindex'][:]
......
......@@ -328,9 +328,8 @@ class RGSpace(Versionable, Space):
hdf5_group['shape'] = self.shape
hdf5_group['zerocenter'] = self.zerocenter
hdf5_group['distances'] = self.distances
# metadata
hdf5_group.attrs['harmonic'] = self.harmonic
hdf5_group.attrs['dtype'] = self.dtype.name
hdf5_group['harmonic'] = self.harmonic
hdf5_group['dtype'] = self.dtype.name
return None
......@@ -340,7 +339,7 @@ class RGSpace(Versionable, Space):
shape=hdf5_group['shape'][:],
zerocenter=hdf5_group['zerocenter'][:],
distances=hdf5_group['distances'][:],
harmonic=hdf5_group.attrs['harmonic'],
dtype=np.dtype(hdf5_group.attrs['dtype'])
harmonic=hdf5_group['harmonic'][()],
dtype=np.dtype(hdf5_group['dtype'][()])
)
return result
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment