source: sasview/sansinvariant/test/utest_inv_mapper.py @ c911f34

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 c911f34 was ad4053a, checked in by Jessica Tumarkin <jtumarki@…>, 13 years ago
  • Property mode set to 100644
File size: 1.8 KB
Line 
1"""
2   Implementation of the use-case from a usage perspective.
3"""
4
5import unittest
6import numpy
7from DataLoader.loader import  Loader
8from sans.invariant import invariant
9from sans.invariant.invariant_mapper import InvariantMapper
10
11N_INVARIANT = 10
12CONTRAST = 2.6e-6
13POROD_CONSTANT = 2.0
14
15class TestInvPolySphere(unittest.TestCase):
16    """
17        Test iteration through unsmeared data for invariant computation
18    """
19    def setUp(self):
20        self.list_of_invariant = []
21        self.list_of_contrast = []
22        self.list_of_porod_const = []
23        #Define an invariant mapper
24        self.mapper = InvariantMapper()
25        for i in range(N_INVARIANT):
26            data = Loader().load("PolySpheres.txt")
27            # Create invariant object. Background and scale left as defaults.
28            inv = invariant.InvariantCalculator(data=data)
29            self.list_of_invariant.append(inv)
30            self.list_of_contrast.append(CONTRAST)
31            self.list_of_porod_const.append(POROD_CONSTANT)
32       
33    def test_use_case_1(self):
34        """
35        Invariant without extrapolation
36        """
37        qstar_list = map(self.mapper.get_qstar, self.list_of_invariant)
38       
39        for qstar in qstar_list:
40            self.assertAlmostEquals(qstar, 7.48959e-5, 2)
41       
42        v_list = map(self.mapper.get_volume_fraction_with_error,
43                         self.list_of_invariant, self.list_of_contrast)
44        for v, dv in v_list:
45            self.assertAlmostEquals(v, 0.005644689, 4)
46           
47        s_list = map(self.mapper.get_surface_with_error,
48                         self.list_of_invariant,
49                         self.list_of_contrast,
50                         self.list_of_porod_const)
51        for s, ds in s_list:
52            self.assertAlmostEquals(s , 941.7452, 3)
53       
54   
Note: See TracBrowser for help on using the repository browser.