def test_write(self): "Test writing with self consistency at the fabio level" for vals in TESTIMAGES: name = vals[0] obj = OXDimage() obj.read(self.fn[name]) if obj.header.get("Compression") not in ["NO ", "TY1"]: logger.info("Skip write test for now") continue obj.write(os.path.join(UtilsTest.tempdir, name)) other = OXDimage() other.read(os.path.join(UtilsTest.tempdir, name)) self.assertEqual( abs(obj.data - other.data).max(), 0, "data are not the same for %s" % name) for key in obj.header: if key == "filename": continue self.assertTrue(key in other.header, "Key %s is in header" % key) self.assertEqual( obj.header[key], other.header[key], "metadata '%s' are not the same for %s" % (key, name)) os.unlink(os.path.join(UtilsTest.tempdir, name))
def checkFile(self, filename): """ check we can read OXD images with openimage""" obj = openimage(filename) obj2 = OXDimage() obj2.read(filename) self.assertEqual(obj.data[10, 10], obj2.data[10, 10]) self.assertEqual(type(obj), type(obj2)) self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)
def test_write(self): "Test writing with self consistency at the fabio level" for line in TESTIMAGES.split("\n"): vals = line.split() name = vals[0] obj = OXDimage() obj.read(self.fn[name]) obj.write(os.path.join(self.tempdir, name)) other = OXDimage() other.read(os.path.join(self.tempdir, name)) self.assertEqual(abs(obj.data - other.data).max(), 0, "data are the same") for key in obj.header: if key == "filename": continue self.assertTrue(key in other.header, "Key %s is in header" % key) self.assertEqual(obj.header[key], other.header[key], "value are the same for key %s" % key)
def test_read(self): "Test reading of compressed OXD images" for line in TESTIMAGES.split("\n"): vals = line.split() name = vals[0] dim1, dim2 = [int(x) for x in vals[1:3]] mini, maxi, mean, stddev = [float(x) for x in vals[3:]] obj = OXDimage() obj.read(self.fn[name]) self.assertAlmostEqual(mini, obj.getmin(), 2, "getmin") self.assertAlmostEqual(maxi, obj.getmax(), 2, "getmax") self.assertAlmostEqual(mean, obj.getmean(), 2, "getmean") self.assertAlmostEqual(stddev, obj.getstddev(), 2, "getstddev") self.assertEqual(dim1, obj.dim1, "dim1") self.assertEqual(dim2, obj.dim2, "dim2")
def test_write(self): "Test writing with self consistency at the fabio level" for vals in TESTIMAGES: name = vals[0] obj = OXDimage() obj.read(self.fn[name]) if obj.header.get("Compression") not in ["NO ", "TY1"]: logger.info("Skip write test for now") continue obj.write(os.path.join(UtilsTest.tempdir, name)) other = OXDimage() other.read(os.path.join(UtilsTest.tempdir, name)) self.assertEqual(abs(obj.data - other.data).max(), 0, "data are not the same for %s" % name) for key in obj.header: if key == "filename": continue self.assertTrue(key in other.header, "Key %s is in header" % key) self.assertEqual(obj.header[key], other.header[key], "metadata '%s' are not the same for %s" % (key, name)) os.unlink(os.path.join(UtilsTest.tempdir, name))
def test_read(self): "Test reading of compressed OXD images" for vals in TESTIMAGES: name = vals[0] dim1, dim2 = vals[1:3] shape = dim2, dim1 mini, maxi, mean, stddev = vals[3:7] detector_type = vals[7] obj = OXDimage() obj.read(self.fn[name]) self.assertEqual(shape, obj.shape) self.assertAlmostEqual(mini, obj.getmin(), 2, "getmin on " + name) self.assertAlmostEqual(maxi, obj.getmax(), 2, "getmax on " + name) self.assertAlmostEqual(mean, obj.getmean(), 2, "getmean on " + name) self.assertAlmostEqual(stddev, obj.getstddev(), 2, "getstddev on " + name) self.assertIn(detector_type, obj.header["Detector type"], "detector type on " + name)