示例#1
0
    def test_write(self):
        fname = TESTIMAGES.split()[0]
        obt = openimage(os.path.join(self.im_dir, fname))
        name = os.path.basename(fname)

        obj = Bruker100Image(data=obt.data, header=obt.header)
        obj.write(os.path.join(UtilsTest.tempdir, name))
        other = openimage(os.path.join(UtilsTest.tempdir, name))
        self.assertEqual(abs(obt.data - other.data).max(), 0, "data are the same")
        for key in obt.header:
            self.assertTrue(key in other.header, "Key %s is in header" % key)
            self.assertEqual(obt.header[key], other.header[key], "value are the same for key %s" % key)
        os.unlink(os.path.join(UtilsTest.tempdir, name))
示例#2
0
 def test_read(self):
     """ check we can read bruker100 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 = Bruker100Image()
         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")