Changeset e84e1e6 in sasview for DataLoader/test/utest_averaging.py
- Timestamp:
- Jan 26, 2010 8:43:38 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- c1469ebe
- Parents:
- 25e3fc9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/test/utest_averaging.py
r2e83ff3 re84e1e6 3 3 4 4 from DataLoader.loader import Loader 5 from DataLoader.manipulations import Ring, CircularAverage 5 from DataLoader.manipulations import Ring, CircularAverage, SectorPhi, get_q 6 6 7 7 import os.path 8 import numpy, math 9 import DataLoader.data_info as data_info 10 11 class Averaging(unittest.TestCase): 12 """ 13 Test averaging manipulations on a flat distribution 14 """ 15 def setUp(self): 16 """ 17 Create a flat 2D distribution. All averaging results 18 should return the predefined height of the distribution (1.0). 19 """ 20 x_0 = numpy.ones([100,100]) 21 dx_0 = numpy.ones([100,100]) 22 self.data = data_info.Data2D(x_0, dx_0) 23 detector = data_info.Detector() 24 detector.distance = 1000.0 25 detector.pixel_size.x = 1.0 26 detector.pixel_size.y = 1.0 27 detector.beam_center.x = 50 28 detector.beam_center.y = 50 29 self.data.detector.append(detector) 30 31 source = data_info.Source() 32 source.wavelength = 10.0 33 self.data.source = source 34 35 self.qmin = get_q(1.0, 1.0, 1000.0, 10.0) 36 37 def test_ring_flat_distribution(self): 38 """ 39 Test ring averaging 40 """ 41 r = Ring(r_min=2*self.qmin, r_max=5*self.qmin, 42 center_x=self.data.detector[0].beam_center.x, 43 center_y=self.data.detector[0].beam_center.y) 44 r.nbins_phi = 20 45 46 o = r(self.data) 47 for i in range(20): 48 self.assertEqual(o.y[i], 1.0) 49 50 def test_sectorphi_full(self): 51 """ 52 Test sector averaging 53 """ 54 r = SectorPhi(r_min=self.qmin, r_max=3*self.qmin, phi_min=0, phi_max=math.pi*2.0) 55 r.nbins_phi = 20 56 o = r(self.data) 57 for i in range(20): 58 self.assertEqual(o.y[i], 1.0) 59 60 61 def test_sectorphi_partial(self): 62 """ 63 """ 64 phi_max = 1.5 65 r = SectorPhi(r_min=self.qmin, r_max=3*self.qmin, phi_min=0, phi_max=phi_max) 66 self.assertEqual(r.phi_max, phi_max) 67 r.nbins_phi = 20 68 o = r(self.data) 69 self.assertEqual(r.phi_max, phi_max) 70 for i in range(20): 71 self.assertEqual(o.y[i], 1.0) 72 73 8 74 9 75 class data_info_tests(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.