Changeset cf3b781 in sasview for park_integration/Fitting.py


Ignore:
Timestamp:
Jul 7, 2008 4:37:27 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
1b0b3ca
Parents:
672c44da
Message:

need more tests.but usecase 3 implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • park_integration/Fitting.py

    r4408fb0 rcf3b781  
    4242        """ return list of data""" 
    4343     
    44     def set_param(self,model, pars): 
     44    def set_param(self,model,name, pars): 
    4545        """ Recieve a dictionary of parameter and save it """ 
    4646    
    47     def add_constraint(self, constraint): 
    48         """ User specify contraint to fit """ 
     47    def remove_data(self,Uid,data=None): 
     48        """ remove one or all data""" 
     49                  
     50    def remove_model(self,Uid): 
     51        """ remove model """ 
    4952         
    50     def get_constraint(self): 
    51         """ return the contraint value """ 
    52    
    53     def set_constraint(self,constraint): 
    54         """  
    55             receive a string as a constraint 
    56             @param constraint: a string used to constraint some parameters to get a  
    57                 specific value 
    5853        """ 
    59 if __name__ == "__main__":  
    60     load= Load() 
    61     # test scipy  
    62     """test fit one data set one model with scipy """ 
    63     #load data  
    64     load.set_filename("testdata_line.txt") 
    65     load.set_values() 
    66     data1 = Data1D(x=[], y=[], dx=None,dy=None) 
    67     data1.name = "data1" 
    68     load.load_data(data1) 
    69     #choose a model 
    70     from sans.guitools.LineModel import LineModel 
    71     model  = LineModel() 
    72     #Create a Fit engine 
    73     fitter =Fit() 
    74     fitter.fit_engine('scipy') 
    75     engine = fitter.returnEngine() 
    76      
    77     #set the model 
    78     engine.set_model(model,1) 
    79     engine.set_data(data1,1) 
    80      
    81     print"fit only one data SCIPY:",engine.fit({'A':2,'B':1},None,None) 
    82      
    83      
    84     """ test fit one data set one model with park """ 
    85     fitter.fit_engine('scipy') 
    86     engine = fitter.returnEngine() 
    87     #set the model 
    88     engine.set_model(model,1) 
    89     engine.set_data(data1,1) 
    90      
    91     print"fit only one data PARK:",engine.fit({'A':2,'B':1},None,None) 
    92      
    93      
    94     """test fit with 2 data and one model SCIPY:""" 
    95     # reinitialize the fitter 
    96     fitter =Fit() 
    97     #create an engine 
    98     fitter.fit_engine("scipy") 
    99     engine=fitter.returnEngine() 
    100     #set the model for fit 
    101     engine.set_model(model,2 ) 
    102     #load 1 st data 
    103     load.set_filename("testdata1.txt") 
    104     load.set_values() 
    105     data2 = Data1D(x=[], y=[], dx=None,dy=None) 
    106     data2.name = "data2" 
    107     load.load_data(data2) 
    108     #load  2nd data 
    109     load.set_filename("testdata2.txt") 
    110     load.set_values() 
    111     data3 = Data1D(x=[], y=[], dx=None,dy=None) 
    112     data3.name = "data2" 
    113     load.load_data(data3) 
    114      
    115     #set data in the engine 
    116     engine.set_data(data2,2) 
    117     engine.set_data(data3,2) 
    118     print"fit two data SCIPY:",engine.fit({'A':2,'B':1},None,None) 
    119      
    120     """ test fit with 2 data and one model PARK:""" 
    121     fitter.fit_engine("park") 
    122     engine=fitter.returnEngine() 
    123     #set the model for fit 
    124     engine.set_model(model,2 ) 
    125     #load 1 st data 
    126     load.set_filename("testdata1.txt") 
    127     load.set_values() 
    128     data2 = Data1D(x=[], y=[], dx=None,dy=None) 
    129     data2.name = "data2" 
    130     load.load_data(data2) 
    131     #load  2nd data 
    132     load.set_filename("testdata2.txt") 
    133     load.set_values() 
    134     data3 = Data1D(x=[], y=[], dx=None,dy=None) 
    135     data3.name = "data2" 
    136     load.load_data(data3) 
    137      
    138     #set data in the engine 
    139     engine.set_data(data2,2) 
    140     engine.set_data(data3,2) 
    141     print"fit two data PARK:",engine.fit({'A':2,'B':1},None,None) 
    142      
    143    
Note: See TracChangeset for help on using the changeset viewer.