def test_simple(self): """`TableToTimeGrid`: check simple""" # Use filter f = TableToTimeGrid() f.SetInputDataObject(self.table) f.set_dimensions(0, 1, 2, 3) f.set_extent(20, 2, 5, 2) f.set_spacing(5, 5, 5) f.set_origin(3.3, 6.0, 7) f.set_use_points(False) f.set_order('C') for t in range(2): f.UpdateTimeStep(t) ido = f.GetOutput() checkme = [None] * len(self.arrs) for i, arr in enumerate(self.arrs): a = arr.reshape((20, 2, 5, 2))[:,:,:,t] checkme[i] = a.flatten(order='F') # Order F because in XYZ format self.check_data_fidelity(ido, checkme, points=False) f.set_use_points(True) f.Update() for t in range(2): f.UpdateTimeStep(t) ido = f.GetOutput() checkme = [None] * len(self.arrs) for i, arr in enumerate(self.arrs): a = arr.reshape((20, 2, 5, 2))[:,:,:,t] checkme[i] = a.flatten(order='F') # Order F because in XYZ format self.check_data_fidelity(ido, checkme, points=True) return
def test_seplib(self): """`TableToTimeGrid`: check a SEPLib ordered array""" def sepit(a): a = a.swapaxes(0, 2) a = a.swapaxes(0, 1) return a # Use filter f = TableToTimeGrid() f.SetInputDataObject(self.table) f.set_dimensions(1, 2, 0, 3) f.set_extent(20, 2, 5, 2) f.set_spacing(5, 5, 5) f.set_origin(3.3, 6.0, 7) f.set_use_points(False) f.set_order('F') for t in range(2): f.UpdateTimeStep(t) ido = f.GetOutput() self.assertEqual(ido.GetDimensions(), (3, 6, 21)) checkme = [None] * len(self.arrs) for i, arr in enumerate(self.arrs): a = arr.reshape((20, 2, 5, 2), order='F')[:, :, :, t] a = sepit(a) checkme[i] = a.flatten( order='F') # Order F because in XYZ format self.check_data_fidelity(ido, checkme, points=False) f.set_use_points(True) f.Update() for t in range(2): f.UpdateTimeStep(t) ido = f.GetOutput() self.assertEqual(ido.GetDimensions(), (2, 5, 20)) checkme = [None] * len(self.arrs) for i, arr in enumerate(self.arrs): a = arr.reshape((20, 2, 5, 2), order='F')[:, :, :, t] a = sepit(a) checkme[i] = a.flatten( order='F') # Order F because in XYZ format self.check_data_fidelity(ido, checkme, points=True) return
def set_order(self, order): o = ['C', 'F'] TableToTimeGrid.set_order(self, o[order])