def checkFile(self, filename): """ check we can read it""" obj = openimage(filename) obj2 = adscimage() 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 testsame(self): """test ADSC image match to EDF""" im1 = edfimage() im1.read(self.fn_edf) im2 = adscimage() im2.read(self.fn_adsc) diff = (im1.data.astype("float32") - im2.data.astype("float32")) logger.debug("type: %s %s shape %s %s " % (im1.data.dtype, im2.data.dtype, im1.data.shape, im2.data.shape)) logger.debug("im1 min %s %s max %s %s " % (im1.data.min(), im2.data.min(), im1.data.max(), im2.data.max())) logger.debug("delta min %s max %s mean %s" % (diff.min(), diff.max(), diff.mean())) self.assertEqual(abs(diff).max(), 0.0, "asdc data == edf data")
def test_read(self): """ check we can read flat ADSC 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 = adscimage() obj.read(os.path.join(self.im_dir, 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")