Changeset a55fac1 in sasview for sansmodels/src


Ignore:
Timestamp:
Jun 10, 2008 11:27:07 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
38fc601
Parents:
06290c8
Message:

Modified 2D non-shape models to be the same as 1D when not defined otherwise

Location:
sansmodels/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/release_notes.txt

    r3de85b8 ra55fac1  
    22============= 
    33 
    4 SANS Models version 0.4.0 
     4SANS Models version 0.4.1 
    55 
    66Package name: sans.models  
    77 
    8 1- What's New in Version 0.4.0 
     81- What's New in Version 0.4.1 
     9    - Release date: 6/9/2008 
     10    - Modified non-shape models so that the 2D output is the 1D output for the length of Q 
     11 
     12    Version 0.4.0 
    913        - Release date: 4/15/2008 
    1014        - Added shape-independent models. 
     
    1317        - Release date: 2/14/2008 
    1418        - Added models to be used in magnetic analysis. 
    15             
    1619 
    1720 
  • sansmodels/src/sans/models/BEPolyelectrolyte.py

    r3db3895 ra55fac1  
    9494        """ 
    9595        if x.__class__.__name__ == 'list': 
    96             return self._BEPoly(x[0]*math.cos(x[1]))*self._BEPoly(x[0]*math.sin(x[1])) 
     96            return self._BEPoly(x[0]) 
    9797        elif x.__class__.__name__ == 'tuple': 
    9898            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    106106        """ 
    107107        if x.__class__.__name__ == 'list': 
    108             return self._BEPoly(x[0])*self._BEPoly(x[1]) 
     108            q = math.sqrt(x[0]**2 + x[1]**2) 
     109            return self._BEPoly(q) 
    109110        elif x.__class__.__name__ == 'tuple': 
    110111            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/DABModel.py

    r3db3895 ra55fac1  
    5757        """ 
    5858        if x.__class__.__name__ == 'list': 
    59             return self._DAB(x[0]*math.cos(x[1]))*self._DAB(x[0]*math.sin(x[1])) 
     59            return self._DAB(x[0]) 
    6060        elif x.__class__.__name__ == 'tuple': 
    6161            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    6969        """ 
    7070        if x.__class__.__name__ == 'list': 
    71             return self._DAB(x[0])*self._DAB(x[1]) 
     71            q = math.sqrt(x[0]**2 + x[1]**2) 
     72            return self._DAB(q) 
    7273        elif x.__class__.__name__ == 'tuple': 
    7374            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/DebyeModel.py

    rf629e346 ra55fac1  
    6464        """ 
    6565        if x.__class__.__name__ == 'list': 
    66             return self._debye(x[0]*math.cos(x[1]))*self._debye(x[0]*math.sin(x[1])) 
     66            return self._debye(x[0]) 
    6767        elif x.__class__.__name__ == 'tuple': 
    6868            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    7676        """ 
    7777        if x.__class__.__name__ == 'list': 
    78             return self._debye(x[0])*self._debye(x[1]) 
     78            q = math.sqrt(x[0]**2 + x[1]**2) 
     79            return self._debye(q) 
    7980        elif x.__class__.__name__ == 'tuple': 
    8081            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/FractalModel.py

    r36948c92 ra55fac1  
    9999            # Take absolute value of Q, since this model is really meant to 
    100100            # be defined in 1D for a given length of Q 
    101             qx = math.fabs(x[0]*math.cos(x[1])) 
    102             qy = math.fabs(x[0]*math.sin(x[1])) 
     101            #qx = math.fabs(x[0]*math.cos(x[1])) 
     102            #qy = math.fabs(x[0]*math.sin(x[1])) 
    103103             
    104             return self._Fractal(qx)*self._Fractal(qy) 
     104            return self._Fractal(math.fabs(x[0])) 
    105105        elif x.__class__.__name__ == 'tuple': 
    106106            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    114114        """ 
    115115        if x.__class__.__name__ == 'list': 
    116             return self._Fractal(x[0])*self._Fractal(x[1]) 
     116            q = math.sqrt(x[0]**2 + x[1]**2) 
     117            return self._Fractal(q) 
    117118        elif x.__class__.__name__ == 'tuple': 
    118119            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/GuinierModel.py

    r3db3895 ra55fac1  
    4848        """ 
    4949        if x.__class__.__name__ == 'list': 
    50             return self._guinier(x[0]*math.cos(x[1]))*self._guinier(x[0]*math.sin(x[1])) 
     50            return self._guinier(x[0]) 
    5151        elif x.__class__.__name__ == 'tuple': 
    5252            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    6060        """ 
    6161        if x.__class__.__name__ == 'list': 
    62             return self._guinier(x[0])*self._guinier(x[1]) 
     62            q = math.sqrt(x[0]**2 + x[1]**2) 
     63            return self._guinier(q) 
    6364        elif x.__class__.__name__ == 'tuple': 
    6465            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/LorentzModel.py

    r3db3895 ra55fac1  
    5757        """ 
    5858        if x.__class__.__name__ == 'list': 
    59             return self._lorentz(x[0]*math.cos(x[1]))*self._lorentz(x[0]*math.sin(x[1])) 
     59            return self._lorentz(x[0]) 
    6060        elif x.__class__.__name__ == 'tuple': 
    6161            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    6969        """ 
    7070        if x.__class__.__name__ == 'list': 
    71             return self._lorentz(x[0])*self._lorentz(x[1]) 
     71            q = math.sqrt(x[0]**2 + x[1]**2) 
     72            return self._lorentz(q) 
    7273        elif x.__class__.__name__ == 'tuple': 
    7374            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/PorodModel.py

    r36948c92 ra55fac1  
    4545        """ 
    4646        if x.__class__.__name__ == 'list': 
    47             return self._porod(x[0]*math.cos(x[1]))*self._porod(x[0]*math.sin(x[1])) 
     47            return self._porod(x[0]) 
    4848        elif x.__class__.__name__ == 'tuple': 
    4949            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    5757        """ 
    5858        if x.__class__.__name__ == 'list': 
    59             return self._porod(x[0])*self._porod(x[1]) 
     59            q = math.sqrt(x[0]**2 + x[1]**2) 
     60            return self._porod(q) 
    6061        elif x.__class__.__name__ == 'tuple': 
    6162            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/PowerLawModel.py

    r36948c92 ra55fac1  
    6161            # Take absolute value of Q, since this model is really meant to 
    6262            # be defined in 1D for a given length of Q 
    63             qx = math.fabs(x[0]*math.cos(x[1])) 
    64             qy = math.fabs(x[0]*math.sin(x[1])) 
    65             return self._PowerLaw(qx)*self._PowerLaw(qy) 
     63            #qx = math.fabs(x[0]*math.cos(x[1])) 
     64            #qy = math.fabs(x[0]*math.sin(x[1])) 
     65            return self._PowerLaw(math.fabs(x[0])) 
    6666        elif x.__class__.__name__ == 'tuple': 
    6767            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    7575        """ 
    7676        if x.__class__.__name__ == 'list': 
    77             return self._PowerLaw(x[0])*self._PowerLaw(x[1]) 
     77            q = math.sqrt(x[0]**2 + x[1]**2) 
     78            return self._PowerLaw(q) 
    7879        elif x.__class__.__name__ == 'tuple': 
    7980            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/TeubnerStreyModel.py

    rf629e346 ra55fac1  
    6262        """ 
    6363        if x.__class__.__name__ == 'list': 
    64             return self._TeubnerStrey(x[0]*math.cos(x[1]))\ 
    65              *self._TeubnerStrey(x[0]*math.sin(x[1])) 
     64            return self._TeubnerStrey(x[0]) 
    6665        elif x.__class__.__name__ == 'tuple': 
    6766            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     
    7574        """ 
    7675        if x.__class__.__name__ == 'list': 
    77             return self._TeubnerStrey(x[0])*self._TeubnerStrey(x[1]) 
     76            q = math.sqrt(x[0]**2 + x[1]**2) 
     77            return self._TeubnerStrey(q) 
    7878        elif x.__class__.__name__ == 'tuple': 
    7979            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
  • sansmodels/src/sans/models/test/utest_nonshape.py

    r6b8399b ra55fac1  
    4242        self.model.setParam('rg', 1.0) 
    4343         
    44         value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 
    45         self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 
     44        #value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 
     45        value = self._func(2.0, 1.0, math.sqrt(5.0)) 
     46        #self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 
     47        self.assertEqual(self.model.runXY([0.0,0.0]), 2.0) 
    4648        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    4749         
     
    5557        phi = math.atan2(y, x) 
    5658         
    57         value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 
     59        #value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 
     60        value = self._func(2.0, 1.0, r) 
    5861         
    5962        #self.assertEqual(self.model.run([r, phi]), value) 
     
    8386         
    8487    def test2D(self): 
    85         value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
    86         self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    87          
    88     def test2Dphi(self): 
    89         x = 1.0 
    90         y = 2.0 
    91         r = math.sqrt(x**2 + y**2) 
    92         phi = math.atan2(y, x) 
    93          
    94         value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     88        #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     89        value = self._func(2.0, math.sqrt(5.0)) 
     90        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     91         
     92    def test2Dphi(self): 
     93        x = 1.0 
     94        y = 2.0 
     95        r = math.sqrt(x**2 + y**2) 
     96        phi = math.atan2(y, x) 
     97         
     98        #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     99        value = self._func(2.0, r) 
    95100        self.assertAlmostEquals(self.model.run([r, phi]), value,1) 
    96101         
     
    127132         
    128133    def test2D(self): 
    129         value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 
     134        #value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 
     135        value = self._func(50.0, 1.0, 0.001, math.sqrt(5.0)) 
    130136        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    131137         
     
    172178        self.model.setParam('background', 1.0) 
    173179         
    174         value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0)     
     180        #value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0)     
     181        value = self._func(100.0, 50.0, 1.0, math.sqrt(5.0))   
    175182        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    176183         
     
    220227         
    221228    def test2D(self): 
    222         value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0)     
     229        #value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0)     
     230        value = self._func(self.scale, self.length, self.back, math.sqrt(5.0)) 
    223231        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    224232         
     
    272280        self.model.setParam('background', 1.0) 
    273281         
    274         value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 
    275         *self._func(math.exp(-6), 4.0, 1.0, 2.0)     
     282        #value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 
     283        #*self._func(math.exp(-6), 4.0, 1.0, 2.0)     
     284        value = self._func(math.exp(-6), 4.0, 1.0, math.sqrt(5.0)) 
    276285         
    277286        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     
    332341        self.model.setParam('scale', 0.1) 
    333342        self.model.setParam('background', 0.1) 
    334         value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 
    335         *self._func(0.1,-30.0,5000.0,0.1, 2.0)     
     343        #value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 
     344        #*self._func(0.1,-30.0,5000.0,0.1, 2.0)     
     345        value = self._func(0.1,-30.0,5000.0,0.1, math.sqrt(5.0)) 
    336346         
    337347        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     
    348358        phi = math.atan2(y, x) 
    349359         
    350         value = self._func(0.1,-30.0,5000.0,0.1, x)\ 
    351         *self._func(0.1,-30.0,5000.0,0.1, y) 
     360        #value = self._func(0.1,-30.0,5000.0,0.1, x)\ 
     361        #*self._func(0.1,-30.0,5000.0,0.1, y) 
     362        value = self._func(0.1,-30.0,5000.0,0.1, r) 
    352363        self.assertAlmostEquals(self.model.run([r, phi]), value,1) 
    353364         
     
    415426          
    416427    def test2D(self): 
    417         self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 
    418          
    419     def test2Dphi(self): 
    420  
    421         x = 1.0 
    422         y = 2.0 
    423         r = math.sqrt(x**2 + y**2) 
    424         phi = math.atan2(y, x) 
    425          
    426         self.assertAlmostEquals(self.model.run([r, phi]), self._func(x)*self._func(y), 8) 
     428        #self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 
     429        self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(math.sqrt(1.0+2.0**2)), 8) 
     430         
     431    def test2Dphi(self): 
     432 
     433        x = 1.0 
     434        y = 2.0 
     435        r = math.sqrt(x**2 + y**2) 
     436        phi = math.atan2(y, x) 
     437         
     438        self.assertAlmostEquals(self.model.run([r, phi]), self._func(r), 8) 
    427439         
    428440class TestFractalModel(unittest.TestCase): 
     
    493505        iq_y = self._func(y) 
    494506         
    495         self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 
    496         self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 
     507        #self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 
     508        self.assertEqual(self.model.run([r, phi]), self.model.run(r)) 
     509        #self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 
     510        self.assertEqual(self.model.runXY([x,y]), self.model.run(r)) 
    497511         
    498512if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.