Changeset 836fe6e in sasview for sansmodels/src/sans/models
- Timestamp:
- Jan 29, 2009 5:34:59 PM (16 years ago)
- 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
- Location:
- sansmodels/src/sans/models
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/BaseComponent.py
r988130c6 r836fe6e 8 8 #TO DO: that about a way to make the parameter 9 9 #is self return if it is fittable or not 10 10 11 class BaseComponent: 11 12 """ … … 42 43 return par_name.lower() not in self.fixed 43 44 #For the future 44 #return self.params[ 'par_name'].is_fittable()45 #return self.params[str(par_name)].is_fittable() 45 46 46 47 def run(self, x): return NotImplemented … … 71 72 # Look for dispersion parameters 72 73 toks = name.split('.') 74 print "dispersion",self.dispersion 73 75 if len(toks)==2: 74 76 for item in self.dispersion.keys(): … … 83 85 if item.lower()==name.lower(): 84 86 self.params[item] = value 87 #self.params[item] = Parameter(name= item,value=value, is_fixed=False) 88 #print "setparam,self.param",self.params.values() 85 89 return 86 90 … … 105 109 for item in self.params.keys(): 106 110 if item.lower()==name.lower(): 111 #print "getparam", self.params 112 #return self.params[item].value 107 113 return self.params[item] 108 114 -
sansmodels/src/sans/models/CoreShellCylinderModel.py
r988130c6 r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/core_shell_cylinder.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\core_shell_cylinder.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class CoreShellCylinderModel(CCoreShellCylinderModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 54 54 ## Name of the model 55 55 self.name = "CoreShellCylinderModel" 56 ## Model description 56 57 self.description ="""P(q,alpha)= scale/Vs*f(q)^(2) + bkg Where:\n\ 57 58 f(q)= 2(core_sld- solvant_sld)* Vc*sin[qLcos(alpha/2)]/\n\ … … 72 73 theta: axis_theta of the cylinder 73 74 phi: the axis_phi of the cylinder""" 75 74 76 ## Parameter details [units, min, max] 75 77 self.details = {} … … 84 86 self.details['axis_theta'] = ['rad', None, None] 85 87 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'] 92 91 93 92 def clone(self): -
sansmodels/src/sans/models/CoreShellModel.py
r988130c6 r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/core_shell.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\core_shell.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class CoreShellModel(CCoreShellModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 51 51 ## Name of the model 52 52 self.name = "CoreShellModel" 53 ## Model description 53 54 self.description ="""""""" 55 54 56 ## Parameter details [units, min, max] 55 57 self.details = {} … … 61 63 self.details['solvent_sld'] = ['A-2', None, None] 62 64 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'] 65 68 66 69 def clone(self): -
sansmodels/src/sans/models/CylinderModel.py
r988130c6 r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/cylinder.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\cylinder.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class CylinderModel(CCylinderModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 51 51 ## Name of the model 52 52 self.name = "CylinderModel" 53 ## Model description 53 54 self.description ="""P(q,alpha)= scale/V*f(q)^(2)+bkg 54 55 f(q)= 2*(scatter_sld - solvent_sld)*V*sin(qLcos(alpha/2))/[qLcos(alpha/2)]* … … 61 62 for 1D:the ouput is P(q)=scale/V*integral from pi/2 to zero of f(q)^(2)* 62 63 sin(alpha)*dalpha+ bkg""" 64 63 65 ## Parameter details [units, min, max] 64 66 self.details = {} … … 70 72 self.details['cyl_theta'] = ['rad', None, None] 71 73 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'] 75 77 76 78 def clone(self): -
sansmodels/src/sans/models/EllipsoidModel.py
r988130c6 r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/ellipsoid.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\ellipsoid.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class EllipsoidModel(CEllipsoidModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 51 51 ## Name of the model 52 52 self.name = "EllipsoidModel" 53 ## Model description 53 54 self.description =""""P(q.alpha)= scale*f(q)^(2)+ bkg\n\ 54 55 f(q)= 3*(scatter_sld- scatter_solvent)*V*[sin(q*r(Ra,Rb,alpha)) - q*r*cos(qr(Ra,Rb,alpha))] … … 60 61 Ra: radius along the rotation axis of the Ellipsoid 61 62 Rb: radius perpendicular to the rotation axis of the ellipsoid""" 63 62 64 ## Parameter details [units, min, max] 63 65 self.details = {} … … 69 71 self.details['axis_theta'] = ['rad', None, None] 70 72 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'] 76 76 77 77 def clone(self): -
sansmodels/src/sans/models/EllipticalCylinderModel.py
r988130c6 r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/elliptical_cylinder.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\elliptical_cylinder.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class EllipticalCylinderModel(CEllipticalCylinderModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 53 53 ## Name of the model 54 54 self.name = "EllipticalCylinderModel" 55 ## Model description 55 56 self.description ="""""""" 57 56 58 ## Parameter details [units, min, max] 57 59 self.details = {} … … 65 67 self.details['cyl_phi'] = ['rad', None, None] 66 68 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'] 74 72 75 73 def clone(self): -
sansmodels/src/sans/models/SphereModel.py
r7dde98e r836fe6e 17 17 18 18 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY .. /c_extensions/sphere.h19 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\sphere.h 20 20 AND RE-RUN THE GENERATOR SCRIPT 21 21 … … 28 28 class SphereModel(CSphereModel, BaseComponent): 29 29 """ 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. 31 31 Refer to that file and the structure it contains 32 32 for details of the model. … … 48 48 ## Name of the model 49 49 self.name = "SphereModel" 50 ## Model description 50 51 self.description ="""P(q)=(scale/V)*[3V(scatter_sld-solvent_sld)*(sin(qR)-qRcos(qR))/(qR)^3]^(2) 51 52 +bkg … … 55 56 scatter_sld: the scattering length density of the scatter 56 57 solvent_sld: the scattering length density of the solvent""" 58 57 59 ## Parameter details [units, min, max] 58 60 self.details = {} … … 62 64 self.details['background'] = ['cm-1', None, None] 63 65 66 ## fittable parameters 67 self.fixed=['radius.width'] 64 68 65 69 def clone(self): -
sansmodels/src/sans/models/c_extensions/core_shell.h
r96672c0 r836fe6e 8 8 //[DISP_PARAMS] = radius, thickness 9 9 //[DESCRIPTION] ="" 10 //[FIXED]= <text> thickness.width;radius.width</text> 10 11 typedef struct { 11 12 /// Scale factor -
sansmodels/src/sans/models/c_extensions/core_shell_cylinder.h
r4d3acb6 r836fe6e 26 26 // phi: the axis_phi of the cylinder 27 27 // </text> 28 //[FIXED]= <text> axis_phi.width; axis_theta.width; length.width;radius.width; thickness_width</text> 28 29 29 30 typedef struct { -
sansmodels/src/sans/models/c_extensions/cylinder.h
r4ce29e0 r836fe6e 15 15 sin(alpha)*dalpha+ bkg 16 16 </text> 17 [FIXED]= <text> cyl_phi.width; cyl_theta.width; length.width;radius.width</text> 17 18 18 19 **/ -
sansmodels/src/sans/models/c_extensions/ellipsoid.h
r4d3acb6 r836fe6e 19 19 // Rb: radius perpendicular to the rotation axis of the ellipsoid 20 20 // </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> 21 23 typedef struct { 22 24 /// Scale factor -
sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h
r96672c0 r836fe6e 6 6 * [DISP_PARAMS] = r_minor, r_ratio, length, cyl_theta, cyl_phi, cyl_psi 7 7 * [DESCRIPTION] = "" 8 * [FIXED]= <text> cyl_phi.width; 9 * cyl_theta; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text> 8 10 * */ 9 11 typedef struct { -
sansmodels/src/sans/models/c_extensions/sphere.h
r98bfd10 r836fe6e 15 15 // solvent_sld: the scattering length density of the solvent 16 16 // </text> 17 //[FIXED]= <text> radius.width</text> 17 18 18 19 typedef struct { -
sansmodels/src/sans/models/c_models/CSphereModel.cpp
r0f5bc9f r836fe6e 83 83 84 84 // 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)); 86 86 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",60.000000)); 87 87 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)); 89 89 // Initialize dispersion / averaging parameter dict 90 90 DispersionVisitor* visitor = new DispersionVisitor(); -
sansmodels/src/sans/models/c_models/WrapperGenerator.py
r95986b5 r836fe6e 81 81 #model description 82 82 self.description='' 83 # paramaters for fittable 84 self.fixed= [] 83 85 84 86 def __repr__(self): … … 89 91 rep += " params: %s\n" % self.params 90 92 rep += " description: %s\n" % self.description 93 rep += " fittable paramaters list %s\n"% self.fixed 91 94 return rep 92 95 … … 108 111 self.details += " self.details = {}\n" 109 112 # 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 110 200 key = "[DESCRIPTION]" 111 201 find_description= 0 … … 393 483 "[PAR_DETAILS]", self.details) 394 484 395 485 # fixed list details 486 newline = self.replaceToken(newline, 487 "[FIXED]",str(self.fixed)) 488 396 489 # Write new line to the wrapper .c file 397 490 file.write(newline+'\n') … … 409 502 lenkey = len(key) 410 503 newline = line 504 411 505 while newline.count(key)>0: 412 506 index = newline.index(key) 413 507 newline = newline[:index]+value+newline[index+lenkey:] 508 414 509 return newline 415 510 -
sansmodels/src/sans/models/c_models/modelTemplate.txt
r9316609 r836fe6e 43 43 ## Name of the model 44 44 self.name = "[PYTHONCLASS]" 45 ## Model description 45 46 self.description ="""[DESCRIPTION]""" 47 46 48 [PAR_DETAILS] 49 ## fittable parameters 50 self.fixed=[FIXED] 47 51 48 52 def clone(self):
Note: See TracChangeset
for help on using the changeset viewer.