Changeset ed8fa6a3 in sasview for fittingview


Ignore:
Timestamp:
Dec 21, 2011 9:18:23 AM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
491d0fc
Parents:
6e01f06
Message:

simplified custom models

Location:
fittingview/src/sans/perspectives/fitting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/fitting.py

    r6e01f06 red8fa6a3  
    267267                textdial.write_string(fname, name1, name2) 
    268268                textdial.compile_file(fname) 
    269  
    270                 page = self.fit_panel.get_current_page() 
    271                 temp = self.fit_panel.reset_pmodel_list() 
    272                 if temp: 
    273                     page.model_list_box = temp 
    274                     current_val = page.formfactorbox.GetValue() 
    275                     pos = page.formfactorbox.GetSelection() 
    276                     page._show_combox_helper() 
    277                     page.formfactorbox.SetSelection(pos) 
    278                     page.formfactorbox.SetValue(current_val) 
     269                self.update_custom_combo() 
    279270            except: 
    280271                raise 
     
    287278        textdial.Destroy() 
    288279 
    289    
     280    def update_custom_combo(self): 
     281        """ 
     282        Update custom model list in the fitpage combo box 
     283        """ 
     284        try: 
     285            temp = self.fit_panel.reset_pmodel_list() 
     286            if temp: 
     287                # Set the new custom model list for all fit pages 
     288                for uid, page in self.fit_panel.opened_pages.iteritems(): 
     289                    if hasattr(page, "formfactorbox"): 
     290                        page.model_list_box = temp 
     291                        current_val = page.formfactorbox.GetValue() 
     292                        pos = page.formfactorbox.GetSelection() 
     293                        page._show_combox_helper() 
     294                        page.formfactorbox.SetSelection(pos) 
     295                        page.formfactorbox.SetValue(current_val) 
     296        except: 
     297            pass 
     298         
     299         
    290300    def set_edit_menu(self, owner):     
    291301        """ 
  • fittingview/src/sans/perspectives/fitting/plugin_models/polynominal5.py

    r7c8d3093 red8fa6a3  
    77""" 
    88from sans.models.pluginmodel import Model1DPlugin  ##DO NOT CHANGE THIS LINE!!! 
     9 
     10## FOR MORE INFORMATION CHECK http://docs.python.org/library/math.html       
     11## AND http://www.scipy.org/Numpy_Functions_by_Category 
    912import math                    ##DO NOT CHANGE THIS LINE!!! 
    10 import numpy                    ##DO NOT CHANGE THIS LINE!!! 
    11  
    12 ##PLEASE READ COMMENTS CAREFULLY !!! COMMENT ARE IN CAPITAL LETTERS AND AFTER ## 
    13 ## THESE COMMENTS ARE THERE TO GUIDE YOU. YOU CAN REMOVE THEM ONLY WHEN YOU ARE 
    14 ## CONFORTABLE ENOUGH WITH OUR MODEL PLUGIN OPTION 
    15  
     13import numpy                   ##DO NOT CHANGE THIS LINE!!! 
    1614 
    1715## <-----  SIGN DEFINES WHERE YOU CAN MODIFY THE CODE 
     
    2523    """ 
    2624    ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " "  
    27     ## TO RENAME YOUR MODEL 
    28     name = "polynomial5" ## <----- NAME OF THE MODEL    
     25    ## TO RENAME YOUR MODEL: THIS NAME IS WHAT YOU SEE ON GUI. 
     26    name = "polynomial5"        ## <----- NAME OF THE MODEL    
    2927                                 
    3028    def __init__(self):      ##DO NOT CHANGE THIS LINE!!! 
     
    3432        Model1DPlugin.__init__(self, name=self.name) ##DO NOT CHANGE THIS LINE!!! 
    3533         
    36         ## EDIT PARAMETERS' NAMES AND VALUE 
    37         ## DELETE MODIFIABLE LINE HERE WILL REDUCE THE NUMBER OF PARAMETERS 
    38         self.params = {}                ##DO NOT CHANGE THIS LINE!!! 
    39           
    40         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    41         ## YOU CAN ALSO DELETE THIS LINE                                                       
    42         self.params['A'] = 0.0       ## <-----    
    43         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    44         ## YOU CAN ALSO DELETE THIS LINE                  
    45         self.params['B'] = 10.0      ## <-----    
    46         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    47         ## YOU CAN ALSO DELETE THIS LINE                   
    48         self.params['C'] = 0.0       ## <-----    
    49         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    50         ## YOU CAN ALSO DELETE THIS LINE                 
    51         self.params['D'] = 0.0     ## <-----    
    52         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    53         ## YOU CAN ALSO DELETE THIS LINE                    
    54         self.params['E'] = 0.0     ## <-----    
    55         ## YOU CAN MODIFY THELINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    56         ## YOU CAN ALSO DELETE THIS LINE                   
    57         self.params['F'] = 0.0     ## <-----           
    58  
    59         ## STORING PARAMETERS  [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 
    60         self.details = {}    ##DO NOT CHANGE THIS LINE!!!  
    61         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    62         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    63         self.details['A'] = ['', None, None]        ## <-----    
    64         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    65         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    66         self.details['B'] = ['', None, None]        ## <-----    
    67         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    68         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    69         self.details['C'] = ['', None, None]        ## <-----    
    70         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    71         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    72         self.details['D'] = ['', None, None]        ## <-----    
    73         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    74         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    75         self.details['E'] = ['', None, None]        ## <-----    
    76         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    77         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    78         self.details['F'] = ['', None, None]           ## <-----    
    79         ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """   """  ONLY!!!! 
    80         self.description = """ 
    81         F(x) where F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5 
    82         """                        ## <-----    
     34        ## HERE WE DEFINE THE PARAM NAME AND ITS INITIAL VALUE  
     35        ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER                                                       
     36        self.params['A'] = 0.1       ## <-----                 
     37        self.params['B'] = 10.0      ## <-----                  
     38        self.params['C'] = 0.0       ## <-----                 
     39        self.params['D'] = 0.0       ## <-----                     
     40        self.params['E'] = 0.0       ## <-----                   
     41        self.params['F'] = 0.0       ## <-----    
     42         
     43        ## DEFINE DEFAULT DETAILS 
     44        self.set_details()      ##DO NOT DELETE OR CHANGE THIS LINE!!! 
     45         
     46        ## IN THIS EXAMPLE THE FUNTION IS: 
     47        ## F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5              
    8348    
    8449    def function(self, x = 0.0): ##DO NOT CHANGE THIS LINE!!! 
     
    8853        :return: function value 
    8954        """ 
    90         ## ADD YOUR FUNCTION HERE. 
    91         ## REUSE THE PARAMETERS DEFINED PREVIOUSLY TO WRITE YOUR FUNCTION. 
    92          
    93         ## IN THIS EXAMPLE THE FUNTION IS: 
    94         ## F(x)=A+B*x+C*x^2+D*x^3+E*x^4+F*x^5 
    95       
    96         ## NOTE: pow IS A FUNCTION IMPORTED FROM PYTHON MATH LIBRARY 
    97         ## FOR MORE INFORMATION CHECK http://docs.python.org/library/math.html       
    98         ## OTHER FUNCTIONS ARE ALSO  
    99         ###  AVAILABLE http://www.scipy.org/Numpy_Functions_by_Category 
    100         ## numpy FUNCTIONS ARE FOR EXPERT USER 
    101          
    102           
     55        ## DEFINE YOUR FUNCTION HERE. 
    10356        ## YOU CAN ERASE EVERYTHING BELLOW FOR YOUR OWN FUNCTION 
    104         #Redefine parameters as local parameters 
     57        #Redefine parameters as local parameters, or skip and use long name 
    10558        a = self.params['A']       ## <-----    
    10659        b = self.params['B']       ## <-----    
     
    10861        d = self.params['D']       ## <-----    
    10962        e = self.params['E']       ## <-----    
    110         f = self.params['F']        ## <-----    
     63        f = self.params['F']       ## <-----    
    11164  
    11265        ##THIS OUR FUNCTION TEMPLATE 
    113         poly = a + b*x + c*math.pow(x,2) + d*math.pow(x,3) \ 
    114              + e*math.pow(x,4) +f*math.pow(x,5)      ## <-----                 
     66        poly = a + b * x + c * math.pow(x,2) + d * math.pow(x,3) \ 
     67                + e * math.pow(x,4) + f * math.pow(x,5)              ## <-----                 
    11568         
     69        #(Just note: In Python, indentation defines the belongings  
     70        # of 'if', 'for', and so on..) 
    11671        #(lim x --> 0)  
    117         #(Just note: In Python, indentation defines the belongings of 'if', 'for', and so on..) 
    118         if x == 0:                       ## <-----    
     72        if x == 0:                          ## <-----    
    11973            result = a                      ## <-----    
    12074        else:                               ## <-----    
    121             result = poly    ## <-----     
     75            result = poly                   ## <-----     
    12276 
    123         return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
     77        return result       ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
    12478 
    125 ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     79############################################################################### 
     80## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
    12681if __name__ == "__main__":  
    12782    m= Model()  
  • fittingview/src/sans/perspectives/fitting/plugin_models/sph_bessel_jn.py

    r7c8d3093 red8fa6a3  
    5454        self.params['n'] = 1      ## <-----  
    5555  
    56         ## STORING PARAMETERS  [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 
    57         self.details = {}    ##DO NOT CHANGE THIS LINE!!! 
    58         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    59         ## ' ', TWO OTHER NUMBESR TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE       
    60         self.details['C'] = ['',None, None]    ## <-----    
    61         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    62         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    63         self.details['A'] = ['', None, None]        ## <-----    
    64         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    65         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    66         self.details['B'] = ['', None, None]        ## <-----    
    67         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    68         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    69         self.details['D'] = ['', None, None]        ## <-----    
    70         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    71         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE      
    72         self.details['n'] = ['', None, None]        ## <-----    
    73  
     56        ## DEFINE DEFAULT DETAILS 
     57        self.set_details()      ##DO NOT DELETE OR CHANGE THIS LINE!!! 
     58         
    7459        ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """   """  ONLY!!!! 
    7560        self.description = """ 
     
    11196        #(Just note: In Python, indentation defines the belongings of 'if', 'for', and so on..) 
    11297        input = a * x + b 
    113         # sph_out and _ are in array from scipy upto n'th order 
     98        # sph_out and _ are in array types from scipy upto n'th order 
     99        # where _ is not used for this function. 
    114100        sph_out, _ = scipy.special.sph_jn(n, input) 
    115101        # Take only n'th value 
     
    117103 
    118104        return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
    119      
     105 
     106###############################################################################    
    120107## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
    121108if __name__ == "__main__":  
  • fittingview/src/sans/perspectives/fitting/plugin_models/sum_Ap1_1_Ap2.py

    r7c8d3093 red8fa6a3  
    22import copy 
    33from sans.models.pluginmodel import Model1DPlugin 
    4 # Possible model names 
     4# Available model names for this sum model 
    55""" 
    66BCCrystalModel, BEPolyelectrolyte, BarBellModel, BinaryHSModel, BroadPeakModel, 
     
    1818TwoLorentzianModel, TwoPowerLawModel, VesicleModel 
    1919""" 
    20 ## This is DIFFERENT from the Easy Custom Sum(p1 + p2)  
     20## This model is DIFFERENT from the Easy Custom Sum(p1 + p2)  
    2121## by definition of the scale factor ***************************************** 
    2222# 
     
    2828 
    2929#####DO NOT CHANGE ANYTHING BELOW THIS LINE  
    30 #####------------------------------------------------------------------------ 
     30#####--------------------------------------------------------------------------- 
    3131class Model(Model1DPlugin): 
    3232    """ 
     
    379379                                        ( p_model1.name, p_model2.name ) 
    380380        self.description += description 
    381                  
     381 
     382### FOR TEST                 
    382383if __name__ == "__main__":  
    383384    m1= Model()  
    384     #m1.setParam("p1_scale", 25)   
    385     #m1.setParam("p1_length", 1000) 
    386     #m1.setParam("p2_scale", 100)  
    387     #m1.setParam("p2_rg", 100)  
    388385    out1 = m1.runXY(0.01) 
    389  
    390386    m2= Model() 
    391     #m2.p_model1.setParam("scale", 25)  
    392     #m2.p_model1.setParam("length", 1000)  
    393     #m2.p_model2.setParam("scale", 100) 
    394     #m2.p_model2.setParam("rg", 100) 
    395387    out2 = 0.5 * m2.p_model1.runXY(0.01) + 0.5 * m2.p_model2.runXY(0.01) 
    396388    print "Testing at Q = 0.01:" 
  • fittingview/src/sans/perspectives/fitting/plugin_models/sum_p1_p2.py

    r7c8d3093 red8fa6a3  
    22import copy 
    33from sans.models.pluginmodel import Model1DPlugin 
    4 # Possible model names 
     4# Available model names for this sum model 
    55""" 
    66BCCrystalModel, BEPolyelectrolyte, BarBellModel, BinaryHSModel, BroadPeakModel, 
     
    2727 
    2828#####DO NOT CHANGE ANYTHING BELOW THIS LINE  
    29 #####------------------------------------------------------------------------ 
     29#####--------------------------------------------------------------------------- 
    3030class Model(Model1DPlugin): 
    3131    """ 
  • fittingview/src/sans/perspectives/fitting/plugin_models/testmodel.py

    r7c8d3093 red8fa6a3  
    4848        self.params['C'] = 10.0      ## <-----   
    4949 
    50         ## STORING PARAMETERS  [UNIT, MINIMUM VALUE, MAXIMUM VALUE] 
    51         self.details = {}       ##DO NOT CHANGE THIS LINE!!! 
    52         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    53         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE     
    54         self.details['A'] = ['', -1e16, 1e16]        ## <-----  
    55         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    56         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE     
    57         self.details['B'] = ['', -1e16, 1e16]         ## <-----  
    58         ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ',WORD BETWEEN 
    59         ## ' ', TWO OTHER NUMBERS TO NEW VALUE OR YOU CAN ALSO DELETE TH LINE     
    60         self.details['C'] = ['', -1e16, 1e16]         ## <-----  
     50        ## DEFINE DEFAULT DETAILS 
     51        self.set_details()      ##DO NOT DELETE OR CHANGE THIS LINE!!! 
     52         
    6153        ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """   """  ONLY!!!! 
    62         self.description = "F(x)=A+Bcos(2x)+Csin(2x) " ## <-----  
     54        self.description = "F(x)=A+Bcos(2x)+Csin(2x) "     ## <-----  
    6355    
    6456    def function(self, x = 0.0):  ##DO NOT CHANGE THIS LINE!!! 
Note: See TracChangeset for help on using the changeset viewer.