[io] fix bug in selecting data at a given time for static objects
@@ -969,7 +969,15 @@ class IOReader(VTKPythonAlgorithmBase):
self._index = id_t
self.pos_data = self._idpos_data[self._id_t_m, :]
self.velo_data = self._ivelo_data[self._id_t_m, :]
- self.pos_static_data = self._ispos_data[self._id_t_m, :]
+
+ static_id_t = max(0, numpy.searchsorted(self._static_times, t, side='right') - 1)
+ if static_id_t < len(self._static_indices)-1:
+ self._static_id_t_m = list(range(self._static_indices[static_id_t],
+ self._static_indices[static_id_t+1]))
+ else:
+ self._static_id_t_m = [self._static_indices[static_id_t]]
+
+ self.pos_static_data = self._ispos_data[self._static_id_t_m, :]
vtk_pos_data = dsa.numpyTovtkDataArray(self.pos_data)
vtk_pos_data.SetName('pos_data')
@@ -1152,6 +1160,12 @@ class IOReader(VTKPythonAlgorithmBase):
# build times steps
self._times, self._indices = numpy.unique(self._raw_times,
return_index=True)
+ # all times as hdf5 slice for static objects
+ self._static_raw_times = self._ispos_data[:, 0]
+
+ # build times steps for static objects
+ self._static_times, self._static_indices = numpy.unique(self._static_raw_times,
+ return_index=True)
dcf = self._times[1:]-self._times[:-1]
self._avg_timestep = numpy.mean(dcf)
self._min_timestep = numpy.min(dcf)
