Changeset da3dae3 in sasview for sansmodels/src/sans/models
- Timestamp:
- Jan 30, 2009 4:04:23 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:
- 68dada4
- Parents:
- 836fe6e
- Location:
- sansmodels/src/sans/models
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/EllipsoidModel.py
r836fe6e rda3dae3 73 73 74 74 ## fittable parameters 75 self.fixed=['axis_phi.width', 'axis_theta ', 'radius_a.width']75 self.fixed=['axis_phi.width', 'axis_theta.width', 'radius_a.width', 'radius_b.width', 'length.width', 'r_minor.width', 'r_ratio.width'] 76 76 77 77 def clone(self): -
sansmodels/src/sans/models/EllipticalCylinderModel.py
r836fe6e rda3dae3 69 69 70 70 ## fittable parameters 71 self.fixed=['cyl_ theta', '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'] 72 72 73 73 def clone(self): -
sansmodels/src/sans/models/c_extensions/cylinder.h
r836fe6e rda3dae3 15 15 sin(alpha)*dalpha+ bkg 16 16 </text> 17 [FIXED]= <text> cyl_phi.width; cyl_theta.width; length.width;radius.width</text> 17 [FIXED]= <text> 18 cyl_phi.width; cyl_theta.width; length.width;radius.width 19 </text> 18 20 19 21 **/ -
sansmodels/src/sans/models/c_extensions/ellipsoid.h
r836fe6e rda3dae3 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 //[FIXED]= <text> axis_phi.width; axis_theta.width;radius_a.width; 22 //radius_b.width; length.width; r_minor.width 23 //, r_ratio.width</text> 23 24 typedef struct { 24 25 /// Scale factor -
sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h
r836fe6e rda3dae3 7 7 * [DESCRIPTION] = "" 8 8 * [FIXED]= <text> cyl_phi.width; 9 * cyl_theta ; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text>9 * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text> 10 10 * */ 11 11 typedef struct { -
sansmodels/src/sans/models/c_extensions/sphere.h
r836fe6e rda3dae3 15 15 // solvent_sld: the scattering length density of the solvent 16 16 // </text> 17 //[FIXED]= <text> radius.width</text>17 //[FIXED]= radius.width 18 18 19 19 typedef struct { -
sansmodels/src/sans/models/c_models/WrapperGenerator.py
r836fe6e rda3dae3 4 4 5 5 import 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 6 56 7 57 class WrapperGenerator: … … 116 166 key2="<%s>"%text.lower() 117 167 # close an item in this case fixed 118 text=' text'168 text='TexT' 119 169 key3="</%s>"%text.lower() 120 170 temp="" 121 171 # flag to found key 122 find_fixed= 0 172 find_fixed= False 173 find_key2=False 174 find_key3=False 123 175 124 176 for line in lines: 125 177 if line.count(key)>0 :#[FIXED]= ..... 126 178 try: 127 find_fixed= 1179 find_fixed= True 128 180 index = line.index(key) 129 181 toks = line[index:].split("=",1 ) 130 182 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 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 # 165 223 break 166 224 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 "*" 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) 179 250 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 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 199 280 # Catch Description 200 281 key = "[DESCRIPTION]"
Note: See TracChangeset
for help on using the changeset viewer.