Exemple #1
0
 def test_read(self):
     """ Check it reads a mask OK """
     i = fit2dmaskimage()
     i.read(self.filename)
     self.assertEqual(i.shape, (1024, 1024))
     self.assertEqual(i.bpp, 1)
     self.assertEqual(i.bytecode, numpy.uint8)
     self.assertEqual(i.data.shape, (1024, 1024))
Exemple #2
0
 def testBzip2(self):
     self.filename = os.path.join(self.tmpdir, "random.msk.gz")
     e = fit2dmaskimage(data=self.data, header=self.header)
     e.write(self.filename)
     r = fabio.open(self.filename)
     self.assert_(r.header == self.header, "header are OK")
     self.assertEqual(e.dim1, r.dim1, "dim1 are the same")
     self.assertEqual(e.dim2, r.dim2, "dim2 are the same")
     self.assert_(abs(r.data - self.data).max() == 0, "data are OK")
Exemple #3
0
 def checkFile(self, filename):
     """ check we can read Fit2D mask with openimage"""
     obj = openimage(filename)
     obj2 = fit2dmaskimage()
     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)
     self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)
Exemple #4
0
 def testFlat(self):
     self.filename = os.path.join(UtilsTest.tempdir, "random.msk")
     e = fit2dmaskimage(data=self.data, header=self.header)
     e.write(self.filename)
     r = fabio.open(self.filename)
     self.assertEqual(e.dim1, r.dim1, "dim1 are the same")
     self.assertEqual(e.dim2, r.dim2, "dim2 are the same")
     self.assert_(r.header == self.header, "header are OK")
     self.assert_(abs(r.data - self.data).max() == 0, "data are OK")
Exemple #5
0
 def test_getmatch(self):
     """ test edf and msk are the same """
     i = fit2dmaskimage()
     i.read(self.filename)
     j = fabio.open(self.edffilename)
     self.assertEqual(i.shape, j.shape)
     self.assertEqual(i.data.shape, j.data.shape)
     diff = j.data - i.data
     sumd = abs(diff).sum(dtype=float)
     self.assertEqual(sumd, 0.0)
Exemple #6
0
    def atest(self):
        e = fit2dmaskimage(data=self.data, header=self.header)
        e.write(self.filename)
        r = fabio.open(self.filename)
        self.assertEqual(e.shape, r.shape, "shape are the same")
        if r.header != self.header:
            print("Issue with header in TestMskWrite.testFlat")
            for k, v in r.header.items():
                print(k, v, self.header.get(k))
            print(e.header)
            print(r.header)
            print(self.header)

        else:
            self.assertTrue(r.header == self.header, "header are OK")
        self.assertTrue(abs(r.data - self.data).max() == 0, "data are OK")