Changeset 25a608f5 in sasview


Ignore:
Timestamp:
Apr 14, 2009 4:24:14 PM (15 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:
9cb364a
Parents:
7b78bb6
Message:

add list of orientation _parameters to models

Location:
sansmodels/src/sans/models
Files:
1 added
17 edited

Legend:

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

    rc9636f7 r25a608f5  
    3333        #list of parameter that can be fitted 
    3434        self.fixed= [] 
     35        ## parameters with orientation 
     36        self.orientation_params =[] 
    3537            
    3638    def __str__(self): 
  • sansmodels/src/sans/models/CoreShellCylinderModel.py

    r836fe6e r25a608f5  
    8989                ## fittable parameters 
    9090        self.fixed=['axis_phi.width', 'axis_theta.width', 'length.width', 'radius.width', 'thickness_width'] 
     91         
     92        ## parameters with orientation 
     93        self.orientation_params =['axis_phi', 'axis_theta', 'axis_phi.width', 'axis_theta.width'] 
    9194    
    9295    def clone(self): 
  • sansmodels/src/sans/models/CoreShellModel.py

    r369e492e r25a608f5  
    1717 
    1818        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    19                  DO NOT MODIFY THIS FILE, MODIFY c:\ECLPS\workspace\trunk\sansmodels\src\sans\models\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:\ECLPS\workspace\trunk\sansmodels\src\sans\models\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. 
     
    7575                ## fittable parameters 
    7676        self.fixed=['thickness.width', 'radius.width'] 
     77         
     78        ## parameters with orientation 
     79        self.orientation_params =[] 
    7780    
    7881    def clone(self): 
  • sansmodels/src/sans/models/CylinderModel.py

    r836fe6e r25a608f5  
    7575                ## fittable parameters 
    7676        self.fixed=['cyl_phi.width', 'cyl_theta.width', 'length.width', 'radius.width'] 
     77         
     78        ## parameters with orientation 
     79        self.orientation_params =['cyl_phi', 'cyl_theta', 'cyl_phi.width', 'cyl_theta.width'] 
    7780    
    7881    def clone(self): 
  • sansmodels/src/sans/models/EllipsoidModel.py

    rda3dae3 r25a608f5  
    7373 
    7474                ## fittable parameters 
    75         self.fixed=['axis_phi.width', 'axis_theta.width', 'radius_a.width', 'radius_b.width', 'length.width', 'r_minor.width', 'r_ratio.width'] 
     75        self.fixed=['axis_phi.width', 'axis_theta.width', 'radius_a.width', 'radius_b.width', 'length.width', 'r_minor.width'] 
     76         
     77        ## parameters with orientation 
     78        self.orientation_params =['axis_phi.width', 'axis_theta.width', 'axis_phi', 'axis_theta'] 
    7679    
    7780    def clone(self): 
  • sansmodels/src/sans/models/EllipticalCylinderModel.py

    rda3dae3 r25a608f5  
    6969 
    7070                ## fittable parameters 
    71         self.fixed=['cyl_phi.width', 'cyl_theta.width', 'cyl_psi.width', 'length.width', 'r_minor.width', 'r_ratio.width'] 
     71        self.fixed=['cyl_phi.width', 'cyl_theta.width', 'cyl_psi.width', 'length.width', 'r_minor.width', 'r_ratio.width </text>'] 
     72         
     73        ## parameters with orientation 
     74        self.orientation_params =['cyl_phi', 'cyl_theta', 'cyl_psi', 'cyl_phi.width', 'cyl_theta.width', 'cyl_psi.width'] 
    7275    
    7376    def clone(self): 
  • sansmodels/src/sans/models/SphereModel.py

    r836fe6e r25a608f5  
    6666                ## fittable parameters 
    6767        self.fixed=['radius.width'] 
     68         
     69        ## parameters with orientation 
     70        self.orientation_params =[] 
    6871    
    6972    def clone(self): 
  • sansmodels/src/sans/models/c_extensions/Hardsphere.h

    r25579e8 r25a608f5  
    2121 //      </text> 
    2222 //[FIXED]= radius.width   
     23 
     24 
    2325typedef struct { 
    2426    /// Radius of hardsphere [A] 
  • sansmodels/src/sans/models/c_extensions/SquareWell.h

    r25579e8 r25a608f5  
    2222//                      </text> 
    2323//   [FIXED]= radius.width  
     24//[ORIENTATION_PARAMS]= <text> </text> 
    2425 
    2526 
  • sansmodels/src/sans/models/c_extensions/core_shell.h

    r25579e8 r25a608f5  
    1919 //                             </text> 
    2020 //[FIXED]= <text> thickness.width;radius.width</text> 
     21 
     22 
    2123typedef struct { 
    2224    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/core_shell_cylinder.h

    r836fe6e r25a608f5  
    2727 //                                     </text> 
    2828 //[FIXED]= <text> axis_phi.width; axis_theta.width; length.width;radius.width; thickness_width</text> 
     29 //[ORIENTATION_PARAMS]= axis_phi; axis_theta;axis_phi.width; axis_theta.width  
     30 
    2931 
    3032typedef struct { 
  • sansmodels/src/sans/models/c_extensions/cylinder.h

    rda3dae3 r25a608f5  
    1515                                                sin(alpha)*dalpha+ bkg 
    1616                                        </text> 
    17         [FIXED]= <text> 
    18                                 cyl_phi.width; cyl_theta.width; length.width;radius.width 
    19                         </text> 
     17        [FIXED]= <text>cyl_phi.width; cyl_theta.width; length.width;radius.width</text> 
     18        [ORIENTATION_PARAMS]= <text>cyl_phi; cyl_theta; cyl_phi.width; cyl_theta.width</text> 
    2019         
     20 
    2121 **/ 
    2222typedef struct { 
  • sansmodels/src/sans/models/c_extensions/ellipsoid.h

    rda3dae3 r25a608f5  
    2222 //radius_b.width; length.width; r_minor.width 
    2323 //, r_ratio.width</text> 
     24 //[ORIENTATION_PARAMS]=  axis_phi.width; axis_theta.width;axis_phi; axis_theta 
     25 
     26 
    2427typedef struct { 
    2528    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h

    rda3dae3 r25a608f5  
    88 * [FIXED]= <text> cyl_phi.width; 
    99 * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text> 
     10 * [ORIENTATION_PARAMS]= cyl_phi; cyl_theta; cyl_psi;  cyl_phi.width; cyl_theta.width; cyl_psi.width  
    1011 * */ 
     12 
     13 
    1114typedef struct { 
    1215    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/sphere.h

    rda3dae3 r25a608f5  
    1616 //                             </text> 
    1717 //[FIXED]=  radius.width 
     18 //[ORIENTATION_PARAMS]= <text> </text> 
    1819  
    1920typedef struct { 
  • sansmodels/src/sans/models/c_models/WrapperGenerator.py

    rda3dae3 r25a608f5  
    44 
    55import os, sys,re 
    6 def split_list(separator, mylist, n=0): 
    7     """ 
    8         @return a list of string without white space of separator 
    9         @param separator: the string to remove 
    10     """ 
    11     list=[] 
    12     for item in mylist: 
    13         if re.search( separator,item)!=None: 
    14             if n >0: 
    15                 word =re.split(separator,item,int(n)) 
    16             else: 
    17                 word =re.split( separator,item) 
    18             for new_item in word:  
    19                 if new_item.lstrip().rstrip() !='': 
    20                     list.append(new_item.lstrip().rstrip()) 
    21     return list 
    22 def split_text(separator, string1, n=0): 
    23     """ 
    24         @return a list of string without white space of separator 
    25         @param separator: the string to remove 
    26     """ 
    27     list=[] 
    28     if re.search( separator,string1)!=None: 
    29         if n >0: 
    30             word =re.split(separator,string1,int(n)) 
    31         else: 
    32             word =re.split(separator,string1) 
    33         for item in word:  
    34             if item.lstrip().rstrip() !='': 
    35                 list.append(item.lstrip().rstrip()) 
    36     return list 
    37 def look_for_tag( string1,begin, end=None ): 
    38     """ 
    39         @note: this method  remove the begin and end tags given by the user 
    40         from the string . 
    41         @param begin: the initial tag 
    42         @param end: the final tag 
    43         @param string: the string to check 
    44         @return: begin_flag==True if begin was found, 
    45          end_flag==if end was found else return false, false 
    46           
    47     """ 
    48     begin_flag= False 
    49     end_flag= False 
    50     if  re.search( begin,string1)!=None: 
    51         begin_flag= True 
    52     if end !=None: 
    53         if  re.search(end,string1)!=None: 
    54             end_flag= True 
    55     return begin_flag, end_flag 
     6import lineparser 
    567 
    578class WrapperGenerator: 
     
    13384        # paramaters for fittable 
    13485        self.fixed= [] 
     86        ## parameters with orientation 
     87        self.orientation_params =[] 
     88         
    13589         
    13690    def __repr__(self): 
    13791        """ Simple output for printing """ 
    13892         
    139         rep  = "Python class: %s\n" % self.pythonClass 
    140         rep += "  struc name: %s\n" % self.structName 
    141         rep += "  params:     %s\n" % self.params 
    142         rep += "  description:     %s\n" % self.description 
    143         rep += "  fittable paramaters list %s\n"% self.fixed 
     93        rep  = "\n Python class: %s\n\n" % self.pythonClass 
     94        rep += "  struc name: %s\n\n" % self.structName 
     95        rep += "  params:     %s\n\n" % self.params 
     96        rep += "  description:    %s\n\n" % self.description 
     97        rep += "  Fittable parameters:     %s\n\n"% self.fixed 
     98        rep += "  Orientation parameters:  %s\n\n"% self.orientation_params 
    14499        return rep 
    145100         
     
    160115        self.details  = "## Parameter details [units, min, max]\n" 
    161116        self.details += "        self.details = {}\n" 
    162          # Catch Description 
    163         key = "[FIXED]" 
     117         
    164118        #open item in this case Fixed 
    165119        text='text' 
     
    168122        text='TexT' 
    169123        key3="</%s>"%text.lower() 
    170         temp="" 
    171         # flag to found key 
    172         find_fixed= False 
    173         find_key2=False 
    174         find_key3=False 
    175          
    176         for line in lines: 
    177             if line.count(key)>0 :#[FIXED]= ..... 
    178                 try: 
    179                     find_fixed= True 
    180                     index = line.index(key) 
    181                     toks  = line[index:].split("=",1 ) 
    182                     temp  = toks[1].lstrip().rstrip() 
    183                     find_key2, find_key3=look_for_tag( string1=temp,begin=key2, end=key3 ) 
    184                     if find_key2 and find_key3: 
    185                         #print"Found both:find_key2, find_key3", find_key2, find_key3 
    186                         temp1=[] 
    187                         temp2=[] 
    188                         temp3=[] 
    189                         temp4=[] 
    190                         temp1=split_text(separator=key2, string1=temp) 
    191                         temp2=split_list(separator=key3, mylist=temp1) 
    192                         temp3=split_list(separator=';', mylist=temp2) 
    193                         temp4=split_list(separator=',', mylist=temp3) 
    194                         self.fixed= temp3 + temp4 
    195                         break 
    196                          
    197                     elif find_key2 and not find_key3: 
    198                         #print"Find  find_key2 not find_key3", find_key2, find_key3 
    199                         temp1=[] 
    200                         temp2=[] 
    201                         temp3=[] 
    202                         temp4=[] 
    203                         temp1=split_text(separator=key2, string1=temp) 
    204                         temp3=split_list(separator=';', mylist=temp1) 
    205                         temp4=split_list(separator=',', mylist=temp3) 
    206                         #print "found only key2 , temp4", temp3,temp4 
    207                         if len(temp3+ temp4)==0:# [FIXED]=  only one param 
    208                             self.fixed+= temp1 
    209                         self.fixed+=temp3+temp4 # 
    210                     elif not (find_key2 and find_key3) : 
    211                         #print"Find nothing find_key2 not find_key3", find_key2, find_key3 
    212                         temp3=[] 
    213                         temp4=[] 
    214                         if look_for_tag( string1=temp,begin=";")[0]:# split ";" first 
    215                             temp3=split_text(separator=';',string1=temp) 
    216                             temp4=split_list(separator=',', mylist=temp3) 
    217                         else: 
    218                             temp3=split_text(separator=',',string1=temp)# slip "," first 
    219                             temp4=split_list(separator=';', mylist=temp3) 
    220                         if len(temp3+ temp4)==0:# [FIXED]=  only one param 
    221                             self.fixed= [temp] 
    222                         self.fixed+=temp3+temp4 # 
    223                         break 
    224                 except: 
    225                     raise ValueError, "Could not parse file %s" % self.file 
    226              
    227             elif find_fixed: 
    228                 #looking only for key3 
    229                 if not find_key2: 
    230                     raise ValueError, "Could not parse file %s" % self.file 
    231                 find_key3=look_for_tag( string1=line,begin=key3)[0]# split "</text>" first 
    232                 #print "find_key3",find_key3,line,key3 
    233                 if find_key3: 
    234                     temp1=[] 
    235                     temp2=[] 
    236                     temp3=[] 
    237                     temp4=[] 
    238                     temp5=[] 
    239                     
    240                     temp1=split_text(separator=key3, string1=line) 
    241                     temp2=split_list(separator='//',mylist=temp1) 
    242                     temp5=split_list(separator="\*",mylist=temp1) 
    243                      
    244                     if len(temp5)>0: 
    245                         temp3=split_list(separator=';',mylist=temp5) 
    246                         temp4=split_list(separator=',', mylist=temp5) 
    247                     elif len(temp2)>0: 
    248                         temp3=split_list(separator=';',mylist=temp2) 
    249                         temp4=split_list(separator=',', mylist=temp2) 
    250                     else: 
    251                         temp3=split_list(separator=';',mylist=temp1) 
    252                         temp4=split_list(separator=',', mylist=temp1) 
    253                      
    254                     if len(temp3+ temp4)==0:# [FIXED]=  only one param 
    255                         self.fixed+= temp1 
    256                     self.fixed+=temp3+temp4 #    
    257                     break  
    258                 else: 
    259                     temp2=split_text(separator='//',string1=line) 
    260                     temp5=split_text(separator="\*",string1=line) 
    261                     if len(temp5)>0: 
    262                         temp3=split_list(separator=';',mylist=temp5) 
    263                         temp4=split_list(separator=',', mylist=temp5) 
    264                     elif len(temp2)>0: 
    265                         temp3=split_list(separator=';',mylist=temp2) 
    266                         temp4=split_list(separator=',', mylist=temp2) 
    267                     else: 
    268                         if look_for_tag( string1=line,begin=";")[0]:# split ";" first 
    269                             temp3=split_text(separator=';',string1=line) 
    270                             temp4=split_list(separator=',', mylist=temp3) 
    271                         else: 
    272                             temp3=split_text(separator=',',string1=line)# slip "," first 
    273                             temp4=split_list(separator=';', mylist=temp3) 
    274                     if len(temp3+ temp4)==0:# [FIXED]=  only one param 
    275                         self.fixed= [line.lstrip().rstrip()] 
    276                     self.fixed+=temp3+temp4 # 
    277                      
    278                  
    279                      
    280         # Catch Description 
     124         
     125        ## Catch fixed parameters 
     126        key = "[FIXED]" 
     127        try: 
     128            self.fixed= lineparser.readhelper(lines,key, key2,key3, file= self.file) 
     129        except: 
     130           raise    
     131        ## Catch parameters with orientation 
     132        key = "[ORIENTATION_PARAMS]"     
     133        try: 
     134            self.orientation_params = lineparser.readhelper( lines,key,  
     135                                                    key2,key3, file= self.file) 
     136        except: 
     137           raise  
     138        ## Catch Description 
    281139        key = "[DESCRIPTION]" 
    282         find_description= 0 
     140         
     141        find_description = False 
    283142        temp="" 
    284143        for line in lines: 
     
    286145                 
    287146                try: 
    288                     find_description= 1 
     147                    find_description= True 
    289148                    index = line.index(key) 
    290149                    toks = line[index:].split("=",1 ) 
     
    293152                    key2="<%s>"%text.lower() 
    294153                    if re.match(key2,temp)!=None: 
    295                         #index2 = line.index(key2) 
    296                         #temp = temp[index2:] 
     154     
    297155                        toks2=temp.split(key2,1) 
    298156                        self.description=toks2[1] 
     
    303161                            self.description=temp[0] 
    304162                            break 
    305                         #print self.description 
     163                       
    306164                    else: 
    307165                        self.description=temp 
    308166                        break 
    309167                except: 
    310                      raise 
    311168                     raise ValueError, "Could not parse file %s" % self.file 
    312             elif find_description==1: 
     169            elif find_description: 
    313170                text='text' 
    314171                key2="</%s>"%text.lower() 
    315                 #print "second line",line,key2,re.search(key2,line) 
    316172                if re.search(key2,line)!=None: 
    317173                    tok=line.split(key2,1) 
     
    320176                    break 
    321177                else: 
    322                     #if re.search("*",line)!=None: 
    323                     #    temp=line.split("*",1) 
    324                     #    self.description+='\n'+temp[1].lstrip().rstrip() 
    325178                    if re.search("//",line)!=None: 
    326179                        temp=line.split("//",1) 
     
    567420            newline = self.replaceToken(newline,  
    568421                                        "[FIXED]",str(self.fixed)) 
     422            ## parameters with orientation 
     423        
     424            newline = self.replaceToken(newline,  
     425                               "[ORIENTATION_PARAMS]",str(self.orientation_params)) 
    569426            
    570427            # Write new line to the wrapper .c file 
  • sansmodels/src/sans/models/c_models/modelTemplate.txt

    r836fe6e r25a608f5  
    4949                ## fittable parameters 
    5050        self.fixed=[FIXED] 
     51         
     52        ## parameters with orientation 
     53        self.orientation_params =[ORIENTATION_PARAMS] 
    5154    
    5255    def clone(self): 
Note: See TracChangeset for help on using the changeset viewer.