def test_data_fidelity(self): """`MadagascarReader`: Check data fidelity""" # Create a temporary directory self.test_dir = tempfile.mkdtemp() self.n = 100 # Make data and write out dtype = np.dtype('f') self.data = np.array(np.random.random(self.n), dtype=dtype) filename = os.path.join(self.test_dir, 'test.rsf') # Write ascii header lines = ['hello\n'] * 10 with open(filename, 'w') as f: f.writelines(lines) # Write data with open(filename, 'ab') as f: f.write(b'\014\014\004') # The control sequence self.data.tofile(f) # Set up reader reader = MadagascarReader() reader.AddFileName(filename) reader.set_data_type('f') reader.set_data_name('Test Data') self.assertEqual(reader.get_data_name(), 'Test Data') # Perfrom Read reader.Update() table = reader.GetOutput() arr = nps.vtk_to_numpy(table.GetColumn(0)) self.assertTrue(np.allclose(self.data, arr)) #, rtol=0.0001)) self.assertEqual(table.GetColumnName(0), 'Test Data') return
def GetTimestepValues(self): """This is critical for registering the timesteps""" return MadagascarReader.GetTimestepValues(self)
def SetTimeDelta(self, dt): MadagascarReader.SetTimeDelta(self, dt)
def AddFileName(self, fname): MadagascarReader.AddFileName(self, fname)
def __init__(self): MadagascarReader.__init__(self)
def SetDataName(self, dataName): MadagascarReader.SetDataName(self, dataName)
def SetDataType(self, dtype): MadagascarReader.SetDataType(self, dtype)
def SetEndian(self, endian): MadagascarReader.SetEndian(self, endian)
def set_data_name(self, data_name): MadagascarReader.set_data_name(self, data_name)
def set_data_type(self, dtype): MadagascarReader.set_data_type(self, dtype)
def set_endian(self, endian): MadagascarReader.set_endian(self, endian)
def get_time_step_values(self): """This is critical for registering the timesteps""" return MadagascarReader.get_time_step_values(self)
def set_time_delta(self, dt): MadagascarReader.set_time_delta(self, dt)