def test_AcquisitionDataPadder(self):
        reader = NexusReader(self.filename)
        ad = reader.get_acquisition_data_whole()
        print(ad.geometry)
        cf = CenterOfRotationFinder()
        cf.set_input(ad)
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())

        adp = AcquisitionDataPadder(
            acquisition_geometry=cf.get_input().geometry,
            center_of_rotation=cf.get_output(),
            pad_value=0)
        adp.set_input(ad)
        padded_data = adp.get_output()
        print("Padded data shape", padded_data.shape)
        print("      ", padded_data.dimension_labels)
        idx = None
        for k, v in padded_data.dimension_labels.items():
            if v == AcquisitionGeometry.HORIZONTAL:
                idx = k

        padded_axis = padded_data.shape[idx]
        self.assertEqual(padded_axis, math.ceil(cf.get_output() * 2))
        numpy.save("pippo.npy", padded_data.as_array())
示例#2
0
    def test_CenterOfRotation(self):
        reader = NexusReader(self.filename)
        data = reader.get_acquisition_data_whole()

        ad = data.clone()
        print(ad)
        cf = CenterOfRotationFinder()
        cf.set_input(ad)
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())

        #def test_CenterOfRotation_transpose(self):
        #reader = NexusReader(self.filename)
        #data = reader.get_acquisition_data_whole()

        ad = data.clone()
        ad = ad.subset(['vertical', 'angle', 'horizontal'])
        print(ad)
        cf = CenterOfRotationFinder()
        cf.set_input(ad)
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())

        #def test_CenterOfRotation_singleslice(self):
        #reader = NexusReader(self.filename)
        #data = reader.get_acquisition_data_whole()

        ad = data.clone()
        ad = ad.subset(vertical=67)
        print(ad)
        cf = CenterOfRotationFinder()
        cf.set_input(ad)
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())

        #def test_CenterOfRotation_slice(self):
        #reader = NexusReader(self.filename)
        #data = reader.get_acquisition_data_whole()

        ad = data.clone()
        print(ad)
        cf = CenterOfRotationFinder()
        cf.set_input(ad)
        cf.set_slice(80)
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())
        cf.set_slice()
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())
        cf.set_slice('centre')
        print("Center of rotation", cf.get_output())
        self.assertAlmostEqual(86.25, cf.get_output())
        
        labels += [data.dimension_labels[i] \
                   for i in range(len(data.dimension_labels)) if i != ax]
        y = DataContainer( stats[:4] , False, 
                    dimension_labels=labels)
        return y

directory = r'E:\Documents\Dataset\CCPi\Nexus_test'
data_path="entry1/instrument/pco1_hw_hdf_nochunking/data"

reader = NexusReader(os.path.join( os.path.abspath(directory) , '74331.nxs'))

print ("read flat")
read_flat = NexusReader(os.path.join( os.path.abspath(directory) , '74240.nxs'))
read_flat.data_path = data_path
flatsslice = read_flat.get_acquisition_data_whole()
avg = DataStatMoments('angle')

avg.set_input(flatsslice)
flats = avg.get_output()

ave = averager()
ave.stats(flatsslice.array[:,0,0])

print ("avg" , ave.avg, flats.array[0][0][0])
print ("var" , ave.var, flats.array[1][0][0])

print ("read dark")
read_dark = NexusReader(os.path.join( os.path.abspath(directory) , '74243.nxs'))
read_dark.data_path = data_path