PYTHON: Use None for fields in chunks with dblocks == 0.
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
51cc3ea83b
commit
9a7235b72d
@ -117,10 +117,14 @@ class AmunH5(Amun):
|
||||
if os.path.exists(cname):
|
||||
with h5py.File(cname, 'r') as h5:
|
||||
self.chunks[n]['dblocks'] = h5['attributes'].attrs['dblocks'][0]
|
||||
|
||||
self.chunks[n]['levels'] = numpy.array(h5['coordinates']['levels'])
|
||||
self.chunks[n]['bounds'] = numpy.array(h5['coordinates']['bounds'])
|
||||
self.chunks[n]['coords'] = numpy.array(h5['coordinates']['coords'])
|
||||
if self.chunks[n]['dblocks'] > 0:
|
||||
self.chunks[n]['levels'] = numpy.array(h5['coordinates']['levels'])
|
||||
self.chunks[n]['bounds'] = numpy.array(h5['coordinates']['bounds'])
|
||||
self.chunks[n]['coords'] = numpy.array(h5['coordinates']['coords'])
|
||||
else:
|
||||
self.chunks[n]['levels'] = None
|
||||
self.chunks[n]['coords'] = None
|
||||
self.chunks[n]['bounds'] = None
|
||||
else:
|
||||
raise Exception("Snapshot's chunk '{}' not present!".format(cname))
|
||||
|
||||
|
@ -168,9 +168,9 @@ class AmunXML(Amun):
|
||||
|
||||
self.chunks[n]['bounds'] = numpy.array([bounds[:,:,ii[p]].T for p in range(self.chunks[n]['dblocks'])]).T
|
||||
else:
|
||||
self.chunks[n]['levels'] = numpy.zeros((1), dtype = numpy.int32)
|
||||
self.chunks[n]['coords'] = numpy.zeros((3,1), dtype = numpy.int32)
|
||||
self.chunks[n]['bounds'] = numpy.zeros((2,3,1), dtype = numpy.float64)
|
||||
self.chunks[n]['levels'] = None
|
||||
self.chunks[n]['coords'] = None
|
||||
self.chunks[n]['bounds'] = None
|
||||
|
||||
|
||||
def __read_binary_data__(self, dataset_name, chunk_number):
|
||||
|
Loading…
x
Reference in New Issue
Block a user