diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-08-15 19:06:01 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-08-15 19:06:01 +0200 |
commit | 9451cab86cea77e361a531c537252a24b97d1edf (patch) | |
tree | 4f578ee2aefd887024f3035c8a88f4f6145c9fd2 | |
parent | 8f07b260661afd9d74b8cb7f1f40be3153e7aa47 (diff) |
datafile: do not rely on timestep being present in all datasets
-rw-r--r-- | datafile.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/datafile.py b/datafile.py index f9f758f..7b7b6e3 100644 --- a/datafile.py +++ b/datafile.py @@ -41,12 +41,12 @@ class _DataSlice(object): it = None time = None - def __init__(self, data, layout): + def __init__(self, data, layout, it, time): self.layout = layout self.data = data - self.it = data.attrs['timestep'] - self.time = data.attrs['time'] + self.it = it + self.time = time def __getitem__(self, key): return self.data[key] @@ -129,7 +129,7 @@ class _DataSet(object): data = self._df._f[querystr] layout = _SliceLayout(data.attrs['origin'], data.attrs['delta'], data.shape[::-1]) - return _DataSlice(data, layout) + return _DataSlice(data, layout, it, data.attrs['time']) def _slice_merge_components(self, it, rl): data = [] @@ -177,7 +177,7 @@ class _DataSet(object): res[sl] = d.data[:] layout = _SliceLayout(coord_min, step, res.shape[::-1]) - return _DataSlice(res, layout) + return _DataSlice(res, layout, it, data[0].time) def slice(self, it = None, time = None, rl = None, component = None): if it is None and time is not None: |