Changeset 836fe6e in sasview for sansmodels/src/sans/models/c_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/c_models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.