source: sasview/DataLoader/test/utest_averaging.py @ 76e2369

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 76e2369 was 76e2369, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

Added ring averaging and circular averaging + tests

  • Property mode set to 100644
File size: 1.5 KB
Line 
1
2import unittest
3
4from DataLoader.loader import  Loader
5from DataLoader.manipulations import Ring, CircularAverage
6 
7import os.path
8
9class data_info_tests(unittest.TestCase):
10   
11    def setUp(self):
12        self.data = Loader().load('MAR07232_rest.ASC')
13       
14    def test_ring(self):
15        """
16            Test ring averaging
17        """
18        r = Ring(r_min=.005, r_max=.01, 
19                 center_x=self.data.detector[0].beam_center.x, 
20                 center_y=self.data.detector[0].beam_center.y)
21        r.nbins_phi = 20
22       
23        o = r(self.data)
24        answer = Loader().load('ring_testdata.txt')
25        for i in range(r.nbins_phi):
26            self.assertAlmostEqual(o.x[i], answer.x[i], 4)
27            self.assertAlmostEqual(o.y[i], answer.y[i], 4)
28            self.assertAlmostEqual(o.dy[i], answer.dy[i], 4)
29           
30    def test_circularavg(self):
31        """
32            Test circular averaging
33            The test data was not generated by IGOR.
34        """
35        r = CircularAverage(r_min=.00, r_max=.025, 
36                 bin_width=0.0003)
37        r.nbins_phi = 20
38       
39        o = r(self.data)
40        answer = Loader().load('avg_testdata.txt')
41        for i in range(r.nbins_phi):
42            self.assertAlmostEqual(o.x[i], answer.x[i], 4)
43            self.assertAlmostEqual(o.y[i], answer.y[i], 4)
44            self.assertAlmostEqual(o.dy[i], answer.dy[i], 4)
45           
46
47if __name__ == '__main__':
48    unittest.main()
Note: See TracBrowser for help on using the repository browser.