Changeset 836fe6e in sasview for sansmodels/src


Ignore:
Timestamp:
Jan 29, 2009 5:34:59 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:
da3dae3
Parents:
1f3655a
Message:

c_model wrappergenerator modified…
self.fixed list added to model

Location:
sansmodels/src/sans/models
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/BaseComponent.py

    r988130c6 r836fe6e  
    88#TO DO: that about a way to make the parameter 
    99#is self return if it is fittable or not   
     10 
    1011class BaseComponent: 
    1112    """  
     
    4243        return par_name.lower() not in self.fixed 
    4344        #For the future 
    44         #return self.params['par_name'].is_fittable() 
     45        #return self.params[str(par_name)].is_fittable() 
    4546    
    4647    def run(self, x): return NotImplemented 
     
    7172        # Look for dispersion parameters 
    7273        toks = name.split('.') 
     74        print "dispersion",self.dispersion 
    7375        if len(toks)==2: 
    7476            for item in self.dispersion.keys(): 
     
    8385                if item.lower()==name.lower(): 
    8486                    self.params[item] = value 
     87                    #self.params[item] = Parameter(name= item,value=value, is_fixed=False) 
     88                    #print "setparam,self.param",self.params.values() 
    8589                    return 
    8690             
     
    105109            for item in self.params.keys(): 
    106110                if item.lower()==name.lower(): 
     111                    #print "getparam", self.params 
     112                    #return self.params[item].value 
    107113                    return self.params[item] 
    108114             
  • sansmodels/src/sans/models/CoreShellCylinderModel.py

    r988130c6 r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/core_shell_cylinder.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\core_shell_cylinder.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class CoreShellCylinderModel(CCoreShellCylinderModel, BaseComponent): 
    2929    """ Class that evaluates a CoreShellCylinderModel model.  
    30         This file was auto-generated from ../c_extensions/core_shell_cylinder.h. 
     30        This file was auto-generated from ..\c_extensions\core_shell_cylinder.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    5454        ## Name of the model 
    5555        self.name = "CoreShellCylinderModel" 
     56        ## Model description 
    5657        self.description ="""P(q,alpha)= scale/Vs*f(q)^(2) + bkg  Where:\n\ 
    5758                f(q)= 2(core_sld- solvant_sld)* Vc*sin[qLcos(alpha/2)]/\n\ 
     
    7273                theta: axis_theta of the cylinder 
    7374                phi: the axis_phi of the cylinder""" 
     75        
    7476                ## Parameter details [units, min, max] 
    7577        self.details = {} 
     
    8486        self.details['axis_theta'] = ['rad', None, None] 
    8587        self.details['axis_phi'] = ['rad', None, None] 
    86         # fixed paramaters 
    87         self.fixed=['axis_phi.npts','axis_phi.nsigmas', 
    88                                     'axis_theta.npts','axis_theta.nsigmas', 
    89                                     'length.npts','length.nsigmas', 
    90                                     'radius.npts','radius.nsigmas', 
    91                                     'thickness.npts','thickness.nsigmas' ] 
     88 
     89                ## fittable parameters 
     90        self.fixed=['axis_phi.width', 'axis_theta.width', 'length.width', 'radius.width', 'thickness_width'] 
    9291    
    9392    def clone(self): 
  • sansmodels/src/sans/models/CoreShellModel.py

    r988130c6 r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/core_shell.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\core_shell.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class CoreShellModel(CCoreShellModel, BaseComponent): 
    2929    """ Class that evaluates a CoreShellModel model.  
    30         This file was auto-generated from ../c_extensions/core_shell.h. 
     30        This file was auto-generated from ..\c_extensions\core_shell.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    5151        ## Name of the model 
    5252        self.name = "CoreShellModel" 
     53        ## Model description 
    5354        self.description ="""""""" 
     55        
    5456                ## Parameter details [units, min, max] 
    5557        self.details = {} 
     
    6163        self.details['solvent_sld'] = ['A-2', None, None] 
    6264        self.details['background'] = ['cm-1', None, None] 
    63          
    64         self.fixed = ['radius.npts','radius.nsigmas','thickness.npts','thickness.nsigmas'] 
     65 
     66                ## fittable parameters 
     67        self.fixed=['thickness.width', 'radius.width'] 
    6568    
    6669    def clone(self): 
  • sansmodels/src/sans/models/CylinderModel.py

    r988130c6 r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/cylinder.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\cylinder.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class CylinderModel(CCylinderModel, BaseComponent): 
    2929    """ Class that evaluates a CylinderModel model.  
    30         This file was auto-generated from ../c_extensions/cylinder.h. 
     30        This file was auto-generated from ..\c_extensions\cylinder.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    5151        ## Name of the model 
    5252        self.name = "CylinderModel" 
     53        ## Model description 
    5354        self.description ="""P(q,alpha)= scale/V*f(q)^(2)+bkg 
    5455                f(q)= 2*(scatter_sld - solvent_sld)*V*sin(qLcos(alpha/2))/[qLcos(alpha/2)]* 
     
    6162                for 1D:the ouput is P(q)=scale/V*integral from pi/2 to zero of f(q)^(2)* 
    6263                sin(alpha)*dalpha+ bkg""" 
     64        
    6365                ## Parameter details [units, min, max] 
    6466        self.details = {} 
     
    7072        self.details['cyl_theta'] = ['rad', None, None] 
    7173        self.details['cyl_phi'] = ['rad', None, None] 
    72         # fixed parameters 
    73         self.fixed = ['cyl_phi.npts','cyl_phi.nsigmas','cyl_theta.npts','cyl_theta.nsigmas', 
    74                                           'length.npts','length.nsigmas','radius.npts','radius.nsigmas']  
     74 
     75                ## fittable parameters 
     76        self.fixed=['cyl_phi.width', 'cyl_theta.width', 'length.width', 'radius.width'] 
    7577    
    7678    def clone(self): 
  • sansmodels/src/sans/models/EllipsoidModel.py

    r988130c6 r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/ellipsoid.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\ellipsoid.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class EllipsoidModel(CEllipsoidModel, BaseComponent): 
    2929    """ Class that evaluates a EllipsoidModel model.  
    30         This file was auto-generated from ../c_extensions/ellipsoid.h. 
     30        This file was auto-generated from ..\c_extensions\ellipsoid.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    5151        ## Name of the model 
    5252        self.name = "EllipsoidModel" 
     53        ## Model description 
    5354        self.description =""""P(q.alpha)= scale*f(q)^(2)+ bkg\n\ 
    5455                f(q)= 3*(scatter_sld- scatter_solvent)*V*[sin(q*r(Ra,Rb,alpha)) - q*r*cos(qr(Ra,Rb,alpha))] 
     
    6061                Ra: radius along the rotation axis of the Ellipsoid 
    6162                Rb: radius perpendicular to the rotation axis of the ellipsoid""" 
     63        
    6264                ## Parameter details [units, min, max] 
    6365        self.details = {} 
     
    6971        self.details['axis_theta'] = ['rad', None, None] 
    7072        self.details['axis_phi'] = ['rad', None, None] 
    71         # fixed paramaters 
    72         self.fixed=['axis_phi.npts','axis_phi.nsigmas', 
    73                                     'axis_theta.npts','axis_theta.nsigmas', 
    74                                     'radius_a.npts','radius_a.nsigmas', 
    75                                     'radius_b.npts','radius_b.nsigmas' ] 
     73 
     74                ## fittable parameters 
     75        self.fixed=['axis_phi.width', 'axis_theta', 'radius_a.width'] 
    7676    
    7777    def clone(self): 
  • sansmodels/src/sans/models/EllipticalCylinderModel.py

    r988130c6 r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/elliptical_cylinder.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\elliptical_cylinder.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class EllipticalCylinderModel(CEllipticalCylinderModel, BaseComponent): 
    2929    """ Class that evaluates a EllipticalCylinderModel model.  
    30         This file was auto-generated from ../c_extensions/elliptical_cylinder.h. 
     30        This file was auto-generated from ..\c_extensions\elliptical_cylinder.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    5353        ## Name of the model 
    5454        self.name = "EllipticalCylinderModel" 
     55        ## Model description 
    5556        self.description ="""""""" 
     57        
    5658                ## Parameter details [units, min, max] 
    5759        self.details = {} 
     
    6567        self.details['cyl_phi'] = ['rad', None, None] 
    6668        self.details['cyl_psi'] = ['rad', None, None] 
    67         # fixed paramaters 
    68         self.fixed=['cyl_phi.npts','cyl_phi.nsigmas', 
    69                                     'cyl_psi.npts','cyl_phi.nsigmas', 
    70                                     'cyl_theta.npts','cyl_theta.nsigmas', 
    71                                     'length.npts','length.nsigmas', 
    72                                     'r_minor.npts','r_miror.nsigmas', 
    73                                     'r_ratio.npts','r_ratio.nsigmas' ] 
     69 
     70                ## fittable parameters 
     71        self.fixed=['cyl_theta', 'cyl_psi.width', 'length.width', 'r_minor.width', 'r_ratio.width'] 
    7472    
    7573    def clone(self): 
  • sansmodels/src/sans/models/SphereModel.py

    r7dde98e r836fe6e  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/sphere.h 
     19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\sphere.h 
    2020                 AND RE-RUN THE GENERATOR SCRIPT 
    2121 
     
    2828class SphereModel(CSphereModel, BaseComponent): 
    2929    """ Class that evaluates a SphereModel model.  
    30         This file was auto-generated from ../c_extensions/sphere.h. 
     30        This file was auto-generated from ..\c_extensions\sphere.h. 
    3131        Refer to that file and the structure it contains 
    3232        for details of the model. 
     
    4848        ## Name of the model 
    4949        self.name = "SphereModel" 
     50        ## Model description 
    5051        self.description ="""P(q)=(scale/V)*[3V(scatter_sld-solvent_sld)*(sin(qR)-qRcos(qR))/(qR)^3]^(2) 
    5152                +bkg 
     
    5556                scatter_sld: the scattering length density of the scatter 
    5657                solvent_sld: the scattering length density of the solvent""" 
     58        
    5759                ## Parameter details [units, min, max] 
    5860        self.details = {} 
     
    6264        self.details['background'] = ['cm-1', None, None] 
    6365 
     66                ## fittable parameters 
     67        self.fixed=['radius.width'] 
    6468    
    6569    def clone(self): 
  • sansmodels/src/sans/models/c_extensions/core_shell.h

    r96672c0 r836fe6e  
    88 //[DISP_PARAMS] = radius, thickness 
    99 //[DESCRIPTION] ="" 
     10 //[FIXED]= <text> thickness.width;radius.width</text> 
    1011typedef struct { 
    1112    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/core_shell_cylinder.h

    r4d3acb6 r836fe6e  
    2626 //                                     phi: the axis_phi of the cylinder 
    2727 //                                     </text> 
     28 //[FIXED]= <text> axis_phi.width; axis_theta.width; length.width;radius.width; thickness_width</text> 
    2829 
    2930typedef struct { 
  • sansmodels/src/sans/models/c_extensions/cylinder.h

    r4ce29e0 r836fe6e  
    1515                                                sin(alpha)*dalpha+ bkg 
    1616                                        </text> 
     17        [FIXED]= <text> cyl_phi.width; cyl_theta.width; length.width;radius.width</text> 
    1718         
    1819 **/ 
  • sansmodels/src/sans/models/c_extensions/ellipsoid.h

    r4d3acb6 r836fe6e  
    1919 //                                             Rb: radius perpendicular to the rotation axis of the ellipsoid 
    2020 //                                             </text> 
     21 //[FIXED]= <text> axis_phi.width; axis_theta;radius_a.width; 
     22 //radius_b.width; length.width; r_minor.width, r_ratio.width</text> 
    2123typedef struct { 
    2224    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h

    r96672c0 r836fe6e  
    66 * [DISP_PARAMS] = r_minor, r_ratio, length, cyl_theta, cyl_phi, cyl_psi 
    77 * [DESCRIPTION] = "" 
     8 * [FIXED]= <text> cyl_phi.width; 
     9 * cyl_theta; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text> 
    810 * */ 
    911typedef struct { 
  • sansmodels/src/sans/models/c_extensions/sphere.h

    r98bfd10 r836fe6e  
    1515 //                                             solvent_sld: the scattering length density of the solvent 
    1616 //                             </text> 
     17 //[FIXED]= <text> radius.width</text> 
    1718  
    1819typedef struct { 
  • sansmodels/src/sans/models/c_models/CSphereModel.cpp

    r0f5bc9f r836fe6e  
    8383         
    8484        // Initialize parameter dictionary 
    85         PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",0.000001)); 
     85        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 
    8686        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",60.000000)); 
    8787        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 
    88         PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",1.000000)); 
     88        PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000001)); 
    8989        // Initialize dispersion / averaging parameter dict 
    9090        DispersionVisitor* visitor = new DispersionVisitor(); 
  • sansmodels/src/sans/models/c_models/WrapperGenerator.py

    r95986b5 r836fe6e  
    8181        #model description 
    8282        self.description='' 
     83        # paramaters for fittable 
     84        self.fixed= [] 
    8385         
    8486    def __repr__(self): 
     
    8991        rep += "  params:     %s\n" % self.params 
    9092        rep += "  description:     %s\n" % self.description 
     93        rep += "  fittable paramaters list %s\n"% self.fixed 
    9194        return rep 
    9295         
     
    108111        self.details += "        self.details = {}\n" 
    109112         # Catch Description 
     113        key = "[FIXED]" 
     114        #open item in this case Fixed 
     115        text='text' 
     116        key2="<%s>"%text.lower() 
     117        # close an item in this case fixed 
     118        text='text' 
     119        key3="</%s>"%text.lower() 
     120        temp="" 
     121        # flag to found key 
     122        find_fixed= 0 
     123         
     124        for line in lines: 
     125            if line.count(key)>0 :#[FIXED]= ..... 
     126                try: 
     127                    find_fixed= 1 
     128                    index = line.index(key) 
     129                    toks  = line[index:].split("=",1 ) 
     130                    temp  = toks[1].lstrip().rstrip() 
     131                    if re.match(key2,temp)!=None:#[FIXED]= <text> axis_phi.width; axis_theta</text> 
     132                        print "when here" 
     133                        toks2=temp.split(key2,1)\ 
     134                        # split the ";" inside the string 
     135                        print "toks[2]",toks2,toks2[1] 
     136                        if  re.search(";",toks2[1]) !=None: 
     137                            params= toks2[1].split(";") 
     138                            for item in params: 
     139                                print "item", item 
     140                                if  re.search( key3,item)!=None: 
     141                                    par= item.split(key3)#remove key3 
     142                                    print "par", par, par[0] 
     143                                    new_par=par[0].lstrip().rstrip() 
     144                                    break 
     145                            #print "Key2 and Key3 in the same line , more than 1 param", self.fixed 
     146                        else:#only 1 param with key2 and key3 
     147                            if  re.search( key3,toks2[1])!=None: 
     148                                par= toks2[1].split(key3)#remove key3 
     149                                new_par=par[0].lstrip().rstrip() 
     150                                self.fixed.append(new_par.lstrip().rstrip()) 
     151                                #print "Key2 and Key3 in the same line , only 1 param ",self.fixed  
     152                                break 
     153                    else: # no key2 and key3 #[FIXED]=  axis_phi.width; axis_theta 
     154                        temp2 = temp.lstrip().rstrip() 
     155                        if  re.search(";", temp2) !=None:# more than 1 param in the same line 
     156                            params= temp2.split(";") 
     157                            #print "no key2 and key3  params", params 
     158                            for item in params: 
     159                                if item!='': 
     160                                    self.fixed.append(item.lstrip().rstrip()) 
     161                            #print "no key2 and key3, more than 1 param ",self.fixed 
     162                        else:# only one param per line #[FIXED]=  axis_phi.width 
     163                             self.fixed.append(temp2) 
     164                             #print "no key2 and key3, only 1 param ",self.fixed 
     165                        break 
     166                except: 
     167                     raise 
     168                     raise ValueError, "Could not parse file %s" % self.file 
     169            if find_fixed==1:# go to the 2nd line containing info found 1 key2 
     170                #[FIXED]= <text> axis_phi.width; axis_theta;radius_a.width; 
     171                #radius_</text> 
     172                if re.search(key3,line)!=None:# find  </text> 
     173                    tok=line.split(key3,1) 
     174                    print "tok",tok,tok[0] 
     175                    if re.match('//',tok[0].lstrip().rstrip())!=None:# look for '//' 
     176                        temp=tok[0].split("//",1)# remove "//" 
     177                    elif re.match('\*',tok[0].lstrip().rstrip())!=None: 
     178                        temp=tok[0].split("*",1)# remove "*" 
     179                    else: 
     180                        # missing "*" or "//" on comment  
     181                        raise 
     182                        #raise ValueError, "Could not parse file %s" % self.file 
     183                    for item in temp: 
     184                        if item.lstrip().rstrip() !='': 
     185                            pars= item.lstrip().rstrip() 
     186                            if  re.search(";",pars) !=None:# split string by ";" more than 1 parameter 
     187                                params= pars.split(";") 
     188                                for name in params: 
     189                                    if name.lstrip().rstrip() !='': 
     190                                        self.fixed.append(name.lstrip().rstrip()) 
     191                            else:# contains only one parameter 
     192                                name=pars.lstrip().rstrip() 
     193                                if name!='' and name!= key3:#only 1 parameter but ignore key3 
     194                                    self.fixed.append(name.lstrip().rstrip()) 
     195                                    #print "the line contains only one parameters",name.lstrip().rstrip() 
     196                                break 
     197             
     198                 
     199        # Catch Description 
    110200        key = "[DESCRIPTION]" 
    111201        find_description= 0 
     
    393483                                        "[PAR_DETAILS]", self.details) 
    394484            
    395  
     485            # fixed list  details 
     486            newline = self.replaceToken(newline,  
     487                                        "[FIXED]",str(self.fixed)) 
     488            
    396489            # Write new line to the wrapper .c file 
    397490            file.write(newline+'\n') 
     
    409502        lenkey = len(key) 
    410503        newline = line 
     504        
    411505        while newline.count(key)>0: 
    412506            index = newline.index(key) 
    413507            newline = newline[:index]+value+newline[index+lenkey:] 
     508         
    414509        return newline 
    415510         
  • sansmodels/src/sans/models/c_models/modelTemplate.txt

    r9316609 r836fe6e  
    4343        ## Name of the model 
    4444        self.name = "[PYTHONCLASS]" 
     45        ## Model description 
    4546        self.description ="""[DESCRIPTION]""" 
     47        
    4648                [PAR_DETAILS] 
     49                ## fittable parameters 
     50        self.fixed=[FIXED] 
    4751    
    4852    def clone(self): 
Note: See TracChangeset for help on using the changeset viewer.