source: sasview/park_integration/test/test_large_model.py @ daa56d0

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 daa56d0 was 48882d1, checked in by Gervaise Alina <gervyh@…>, 16 years ago

park fitting with new model and new data

  • Property mode set to 100644
File size: 2.6 KB
Line 
1"""
2    Unit tests for fitting module
3"""
4import unittest
5from sans.guitools.plottables import Theory1D
6from sans.guitools.plottables import Data1D
7from sans.fit.AbstractFitEngine import Data,Model
8import math
9class testFitModule(unittest.TestCase):
10    """ test fitting """
11    def test_cylinder_park(self):
12        """ test fitting large model with park"""
13        #load data
14        from sans.fit.Loader import Load
15        load= Load()
16        load.set_filename("cyl_testdata.txt")
17        load.set_values()
18        data11 = Data1D(x=[], y=[],dx=None, dy=None)
19        load.load_data(data11)
20        data1=Data(sans_data=data11)
21       
22       
23        #Importing the Fit module
24        from sans.fit.Fitting import Fit
25        fitter= Fit('park')
26       
27        # Receives the type of model for the fitting
28        from sans.models.CylinderModel import CylinderModel
29        model1  = CylinderModel()
30        model =Model(model1)
31       
32        #Do the fit SCIPY
33        fitter.set_data(data1,1)
34        import math
35        #pars1=['background','contrast', 'length']
36        pars1=['background','contrast',\
37                'cyl_phi','cyl_theta','length','radius','scale']
38        pars1.sort()
39        fitter.set_model(model,"M1",1,pars1)
40        fitter.set_data(data1,1)
41     
42        result=fitter.fit()
43        print "park",result.fitness,result.cov, result.pvec
44        self.assert_(result.fitness)
45       
46     
47    def test_cylinder_scipy(self):
48        """ test fitting large model with scipy"""
49        #load data
50        from sans.fit.Loader import Load
51        load= Load()
52        load.set_filename("cyl_testdata.txt")
53        load.set_values()
54        data11 = Data1D(x=[], y=[],dx=None, dy=None)
55        load.load_data(data11)
56        data1=Data(sans_data=data11)
57       
58       
59        #Importing the Fit module
60        from sans.fit.Fitting import Fit
61        fitter= Fit('scipy')
62       
63        # Receives the type of model for the fitting
64        from sans.models.CylinderModel import CylinderModel
65        model1  = CylinderModel()
66        model =Model(model1)
67       
68        #Do the fit SCIPY
69        fitter.set_data(data1,1)
70        import math
71        #pars1=['background','contrast', 'length']
72        pars1=['background','contrast',\
73                'cyl_phi','cyl_theta','length','radius','scale']
74        pars1.sort()
75        fitter.set_model(model,"M1",1,pars1)
76        fitter.set_data(data1,1)
77     
78        result=fitter.fit()
79        print "scipy",result.fitness,result.cov, result.pvec
80        self.assert_(result.fitness)
81       
82   
Note: See TracBrowser for help on using the repository browser.