Changeset fb59ed9 in sasview
- Timestamp:
- Oct 20, 2010 6:08:34 PM (14 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:
- d2539aa
- Parents:
- f118fe2f
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
ra1b2471 rfb59ed9 94 94 ##[cb state, name, value, "+/-", error of fit, min, max , units] 95 95 self.parameters=[] 96 # non-fittable parameter whose value is astring 97 self.str_parameters = [] 96 98 ## list of parameters to fit , must be like self.parameters 97 99 self.param_toFit=[] … … 947 949 self._reset_parameters_state(self.orientation_params, 948 950 state.orientation_params) 951 self._reset_parameters_state(self.str_parameters, 952 state.str_parameters) 949 953 self._reset_parameters_state(self.parameters,state.parameters) 950 954 ## display dispersion info layer … … 1486 1490 elif k == "Structure Factors": 1487 1491 self.struct_rbutton.SetValue(True) 1492 elif k == "Multi-Functions": 1493 continue 1488 1494 else: 1489 1495 self.plugin_rbutton.SetValue(True) … … 1536 1542 elif k == "Structure Factors": 1537 1543 self.struct_rbutton.SetValue(True) 1544 elif k == "Multi-Functions": 1545 continue 1538 1546 else: 1539 1547 self.plugin_rbutton.SetValue(True) … … 1622 1630 self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" ) 1623 1631 self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: " ) 1632 self.mutifactor_text1 = wx.StaticText( self,-1,"" ) 1624 1633 self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" ) 1625 1634 self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld) … … 1652 1661 mutifactor_selection.Add(self.mutifactor_text) 1653 1662 mutifactor_selection.Add(self.multifactorbox) 1663 mutifactor_selection.Add((5,5)) 1664 mutifactor_selection.Add(self.mutifactor_text1) 1654 1665 mutifactor_selection.Add((10,5)) 1655 1666 mutifactor_selection.Add(self.show_sld_button) … … 1662 1673 1663 1674 self._set_multfactor_combobox() 1675 self.multifactorbox.SetSelection(1) 1664 1676 self.show_sld_button.Hide() 1665 1677 #-------------------------------------------------------- … … 1680 1692 sld_data = Data1D(x,y) 1681 1693 sld_data.name = 'SLD' 1682 1683 self.panel = SLDPanel(self, data=sld_data, id =-1 )1694 sld_data.axes = self.sld_axes 1695 self.panel = SLDPanel(self, data=sld_data,axes =self.sld_axes,id =-1 ) 1684 1696 self.panel.ShowModal() 1685 1697 1686 def _set_multfactor_combobox(self ):1698 def _set_multfactor_combobox(self, multiplicity=10): 1687 1699 """ 1688 1700 Set comboBox for muitfactor of CoreMultiShellModel 1689 """ 1690 for idx in range(0,5): 1701 :param multiplicit: no. of multi-functionality 1702 """ 1703 # build content of the combobox 1704 for idx in range(0,multiplicity): 1691 1705 self.multifactorbox.Append(str(idx),int(idx)) 1692 self.multifactorbox.SetSelection(1)1706 #self.multifactorbox.SetSelection(1) 1693 1707 self._hide_multfactor_combobox() 1694 1708 … … 1699 1713 if not self.mutifactor_text.IsShown(): 1700 1714 self.mutifactor_text.Show(True) 1715 self.mutifactor_text1.Show(True) 1701 1716 if not self.multifactorbox.IsShown(): 1702 1717 self.multifactorbox.Show(True) … … 1708 1723 if self.mutifactor_text.IsShown(): 1709 1724 self.mutifactor_text.Hide() 1725 self.mutifactor_text1.Hide() 1710 1726 if self.multifactorbox.IsShown(): 1711 1727 self.multifactorbox.Hide() … … 1862 1878 # set multifactor for Mutifunctional models 1863 1879 if form_factor().__class__ in self.model_list_box["Multi-Functions"]: 1880 m_id = self.multifactorbox.GetCurrentSelection() 1881 multiplicity = form_factor().multiplicity_info[0] 1882 self.multifactorbox.Clear() 1883 #self.mutifactor_text.SetLabel(form_factor().details[]) 1884 self._set_multfactor_combobox(multiplicity) 1864 1885 self._show_multfactor_combobox() 1865 self.show_sld_button.Show(True) 1866 m_id = self.multifactorbox.GetCurrentSelection() 1886 #ToDo: this info should be called directly from the model 1887 text = form_factor().multiplicity_info[1]#'No. of Shells: ' 1888 1889 #self.mutifactor_text.Clear() 1890 self.mutifactor_text.SetLabel(text) 1891 if m_id > multiplicity -1: 1892 # default value 1893 m_id = 1 1894 1867 1895 self.multi_factor = self.multifactorbox.GetClientData(m_id) 1868 1896 if self.multi_factor == None: self.multi_factor =0 1869 1897 form_factor = form_factor(int(self.multi_factor)) 1898 self.multifactorbox.SetSelection(m_id) 1899 # Check len of the text1 and max_multiplicity 1900 text = '' 1901 if form_factor.multiplicity_info[0] == len(form_factor.multiplicity_info[2]): 1902 text = form_factor.multiplicity_info[2][self.multi_factor] 1903 self.mutifactor_text1.SetLabel(text) 1904 # Check if model has get sld profile. 1905 if len(form_factor.multiplicity_info[3]) > 0: 1906 self.sld_axes = form_factor.multiplicity_info[3] 1907 self.show_sld_button.Show(True) 1908 else: 1909 self.sld_axes = "" 1910 1870 1911 else: 1871 1912 self._hide_multfactor_combobox() -
sansview/perspectives/fitting/fitpage.py
r20905a0 rfb59ed9 1192 1192 self.smear_accuracy.Append(list[idx],idx) 1193 1193 1194 def _set_fun_box_list(self,fun_box): 1195 """ 1196 Set the list of func for multifunctional models 1197 """ 1198 # Check if it is multi_functional model 1199 if self.model.__class__ not in self.model_list_box["Multi-Functions"]: 1200 return None 1201 # Get the func name list 1202 list = self.model.fun_list 1203 if len(list) == 0: 1204 return None 1205 # build function (combo)box 1206 ind = 0 1207 while(ind < len(list)): 1208 for key, val in list.iteritems(): 1209 if (val == ind): 1210 fun_box.Append(key,val) 1211 break 1212 ind += 1 1213 1194 1214 def _on_select_accuracy(self,event): 1195 1215 """ … … 1206 1226 if self.current_smearer != None: 1207 1227 self.current_smearer.set_accuracy(accuracy = self.smear2d_accuracy) 1228 event.Skip() 1229 1230 def _on_fun_box(self,event): 1231 """ 1232 Select an func: Erf,Rparabola,LParabola 1233 """ 1234 fun_val = None 1235 fun_box = event.GetEventObject() 1236 name = fun_box.Name 1237 value = fun_box.GetValue() 1238 if self.model.fun_list.has_key(value): 1239 fun_val = self.model.fun_list[value] 1240 1241 self.model.setParam(name,fun_val) 1242 # save state 1243 self._copy_parameters_state(self.str_parameters, self.state.str_parameters) 1244 # update params 1245 self._update_paramv_on_fit() 1246 # draw 1247 self._draw_model() 1248 self.Refresh() 1249 # get ready for new event 1208 1250 event.Skip() 1209 1251 … … 2046 2088 self.sizer3.Clear(True) 2047 2089 self.parameters = [] 2090 self.str_parameters = [] 2048 2091 self.param_toFit=[] 2049 2092 self.fittable_param=[] … … 2074 2117 Custom compare to order, first by alphabets then second by number. 2075 2118 """ 2119 # number at the last digit 2076 2120 a_last = a[len(a)-1] 2077 2121 b_last = b[len(b)-1] 2078 2122 # default 2079 2123 num_a = None 2080 2124 num_b = None 2125 # split the names 2126 a2 = a.lower().split('_') 2127 b2 = b.lower().split('_') 2128 # check length of a2, b2 2129 len_a2 = len(a2) 2130 len_b2 = len(b2) 2081 2131 # check if it contains a int number(<10) 2082 2132 try: … … 2086 2136 num_b = int(b_last) 2087 2137 except: pass 2138 # Put 'scale' near the top; happens 2139 # when numbered param name exists 2140 if a == 'scale': 2141 return -1 2088 2142 # both have a number 2089 2143 if num_a != None and num_b != None: 2090 if num_a > num_b: return 1 2144 if num_a > num_b: return -1 2145 # same number 2091 2146 elif num_a == num_b: 2092 return cmp(a.lower(), b.lower()) 2093 else: return -1 2147 # different last names 2148 if a2[len_a2-1] != b2[len_b2-1] and num_a != 0: 2149 return -cmp(a2[len_a2-1], b2[len_b2-1]) 2150 else: 2151 return cmp(a, b) 2152 else: return 1 2094 2153 # one of them has a number 2095 2154 elif num_a != None: return 1 2096 2155 elif num_b != None: return -1 2097 # no nu umbers2156 # no numbers 2098 2157 else: return cmp(a.lower(), b.lower()) 2158 2099 2159 2100 2160 keys.sort(custom_compare) … … 2147 2207 iy += 1 2148 2208 ix = 0 2149 ## add parameters name with checkbox for selecting to fit 2150 cb = wx.CheckBox(self, -1, item ) 2151 cb.SetToolTipString(" Check for fitting.") 2152 #cb.SetValue(True) 2153 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 2154 2155 sizer.Add( cb,( iy, ix),(1,1), 2156 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 2157 2158 ## add parameter value 2159 ix += 1 2160 value= self.model.getParam(item) 2161 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 2162 style=wx.TE_PROCESS_ENTER) 2163 ctl1.SetToolTipString("Hit 'Enter' after typing.") 2164 ctl1.SetValue(format_number(value)) 2165 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 2166 ## text to show error sign 2167 ix += 1 2168 text2=wx.StaticText(self, -1, '+/-') 2169 sizer.Add(text2,(iy, ix),(1,1),\ 2170 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2171 text2.Hide() 2172 ix += 1 2173 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 2174 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2175 ctl2.Hide() 2176 2177 ix += 1 2178 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2179 text_enter_callback = self._onparamRangeEnter) 2180 2181 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2182 ctl3.Hide() 2183 2184 ix += 1 2185 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2186 text_enter_callback = self._onparamRangeEnter) 2187 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2188 2189 ctl4.Hide() 2190 2191 if self.engine_type=="park": 2192 ctl3.Show(True) 2193 ctl4.Show(True) 2194 ix +=1 2195 # Units 2196 if self.model.details.has_key(item): 2197 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 2209 if self.model.__class__ in self.model_list_box["Multi-Functions"] \ 2210 and item in self.model.non_fittable: 2211 non_fittable_name = wx.StaticText(self, -1, item ) 2212 sizer.Add(non_fittable_name,(iy, ix),(1,1),\ 2213 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 21) 2214 ## add parameter value 2215 ix += 1 2216 value= self.model.getParam(item) 2217 if len(self.model.fun_list) > 0: 2218 num = item.split('_')[1][5:7] 2219 fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item) 2220 self._set_fun_box_list(fun_box) 2221 fun_box.SetSelection(0) 2222 #self.fun_box.SetToolTipString("A function describing the interface") 2223 wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box) 2224 else: 2225 fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 2226 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 2227 fun_box.SetToolTipString("Hit 'Enter' after typing.") 2228 fun_box.SetValue(format_number(value)) 2229 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 2230 self.str_parameters.append([None,item, fun_box,None,None,None,None,None]) 2231 2232 2198 2233 else: 2199 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 2200 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2234 ## add parameters name with checkbox for selecting to fit 2235 cb = wx.CheckBox(self, -1, item ) 2236 cb.SetToolTipString(" Check for fitting.") 2237 #cb.SetValue(True) 2238 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 2201 2239 2202 ##[cb state, name, value, "+/-", error of fit, min, max , units] 2203 self.parameters.append([cb,item, ctl1, 2204 text2,ctl2, ctl3, ctl4,units]) 2205 2240 sizer.Add( cb,( iy, ix),(1,1), 2241 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 2242 2243 ## add parameter value 2244 ix += 1 2245 value= self.model.getParam(item) 2246 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 2247 style=wx.TE_PROCESS_ENTER) 2248 ctl1.SetToolTipString("Hit 'Enter' after typing.") 2249 ctl1.SetValue(format_number(value)) 2250 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 2251 ## text to show error sign 2252 ix += 1 2253 text2=wx.StaticText(self, -1, '+/-') 2254 sizer.Add(text2,(iy, ix),(1,1),\ 2255 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2256 text2.Hide() 2257 ix += 1 2258 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 2259 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2260 ctl2.Hide() 2261 2262 ix += 1 2263 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2264 text_enter_callback = self._onparamRangeEnter) 2265 2266 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2267 ctl3.Hide() 2268 2269 ix += 1 2270 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2271 text_enter_callback = self._onparamRangeEnter) 2272 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2273 2274 ctl4.Hide() 2275 2276 if self.engine_type=="park": 2277 ctl3.Show(True) 2278 ctl4.Show(True) 2279 ix +=1 2280 # Units 2281 if self.model.details.has_key(item): 2282 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 2283 else: 2284 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 2285 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2286 2287 ##[cb state, name, value, "+/-", error of fit, min, max , units] 2288 self.parameters.append([cb,item, ctl1, 2289 text2,ctl2, ctl3, ctl4,units]) 2290 2206 2291 iy+=1 2207 2292 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) -
sansview/perspectives/fitting/fitting.py
r7a07864 rfb59ed9 823 823 self.fitter.set_model(model, self.fit_id, 824 824 pars,constraints = listOfConstraint) 825 825 print "listOfConstraint",listOfConstraint 826 826 self.fitter.set_data(data=metadata,Uid=self.fit_id, 827 827 smearer=smearer,qmin= qmin,qmax=qmax ) -
sansview/perspectives/fitting/models.py
ra1b2471 rfb59ed9 172 172 173 173 """ 174 ## form factor175 174 from sans.models.SphereModel import SphereModel 176 175 self.shape_list.append(SphereModel) … … 185 184 self.shape_list.append(FuzzySphereModel) 186 185 self.multiplication_factor.append(FuzzySphereModel) 187 186 188 187 from sans.models.CoreShellModel import CoreShellModel 189 188 self.shape_list.append(CoreShellModel) … … 194 193 self.multiplication_factor.append(CoreMultiShellModel) 195 194 self.multi_func_list.append(CoreMultiShellModel) 196 195 197 196 from sans.models.VesicleModel import VesicleModel 198 197 self.shape_list.append(VesicleModel) … … 232 231 self.multiplication_factor.append(ParallelepipedModel) 233 232 233 from sans.models.CSParallelepipedModel import CSParallelepipedModel 234 self.shape_list.append(CSParallelepipedModel) 235 self.multiplication_factor.append(CSParallelepipedModel) 236 234 237 from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 235 238 self.shape_list.append(EllipticalCylinderModel) 236 239 self.multiplication_factor.append(EllipticalCylinderModel) 237 240 241 from sans.models.BarBellModel import BarBellModel 242 self.shape_list.append(BarBellModel) 243 # not implemeted yet! 244 #self.multiplication_factor.append(BarBellModel) 245 246 from sans.models.CappedCylinderModel import CappedCylinderModel 247 self.shape_list.append(CappedCylinderModel) 248 # not implemeted yet! 249 #self.multiplication_factor.append(CappedCylinderModel) 250 238 251 from sans.models.EllipsoidModel import EllipsoidModel 239 252 self.shape_list.append(EllipsoidModel) … … 259 272 from sans.models.LamellarPSHGModel import LamellarPSHGModel 260 273 self.shape_list.append(LamellarPSHGModel) 274 275 from sans.models.LamellarPCrystalModel import LamellarPCrystalModel 276 self.shape_list.append(LamellarPCrystalModel) 277 278 from sans.models.SCCrystalModel import SCCrystalModel 279 self.shape_list.append(SCCrystalModel) 280 281 from sans.models.FCCrystalModel import FCCrystalModel 282 self.shape_list.append(FCCrystalModel) 283 284 from sans.models.BCCrystalModel import BCCrystalModel 285 self.shape_list.append(BCCrystalModel) 261 286 262 287 ## Structure factor … … 272 297 from sans.models.HayterMSAStructure import HayterMSAStructure 273 298 self.struct_list.append(HayterMSAStructure) 274 275 ##shape-independent models 299 300 ##shape-independent models 276 301 from sans.models.PowerLawAbsModel import PowerLawAbsModel 277 302 self.shape_indep_list.append( PowerLawAbsModel ) … … 280 305 self.shape_indep_list.append(BEPolyelectrolyte ) 281 306 self.form_factor_dict[str(wx.NewId())] = [SphereModel] 282 307 308 from sans.models.BroadPeakModel import BroadPeakModel 309 self.shape_indep_list.append(BroadPeakModel) 310 311 from sans.models.CorrLengthModel import CorrLengthModel 312 self.shape_indep_list.append(CorrLengthModel) 313 283 314 from sans.models.DABModel import DABModel 284 315 self.shape_indep_list.append(DABModel ) … … 287 318 self.shape_indep_list.append(DebyeModel ) 288 319 320 #FractalModel (a c-model)is now being used instead of FractalAbsModel. 321 from sans.models.FractalModel import FractalModel 322 self.shape_indep_list.append(FractalModel ) 323 324 from sans.models.FractalCoreShellModel import FractalCoreShellModel 325 self.shape_indep_list.append(FractalCoreShellModel ) 326 327 from sans.models.GaussLorentzGelModel import GaussLorentzGelModel 328 self.shape_indep_list.append(GaussLorentzGelModel) 329 289 330 from sans.models.GuinierModel import GuinierModel 290 331 self.shape_indep_list.append(GuinierModel ) 291 332 292 from sans.models. FractalModel import FractalModel293 self.shape_indep_list.append( FractalModel )294 333 from sans.models.GuinierPorodModel import GuinierPorodModel 334 self.shape_indep_list.append(GuinierPorodModel ) 335 295 336 from sans.models.LorentzModel import LorentzModel 296 337 self.shape_indep_list.append( LorentzModel) … … 304 345 from sans.models.Poly_GaussCoil import Poly_GaussCoil 305 346 self.shape_indep_list.append(Poly_GaussCoil) 306 347 348 from sans.models.PolymerExclVolume import PolymerExclVolume 349 self.shape_indep_list.append(PolymerExclVolume) 350 307 351 from sans.models.PorodModel import PorodModel 308 self.shape_indep_list.append(PorodModel ) 309 310 #FractalModel (a c-model)will be used.311 #from sans.models.FractalAbsModel import FractalAbsModel312 #self.shape_indep_list.append(FractalAbsModel)352 self.shape_indep_list.append(PorodModel ) 353 354 from sans.models.RPA10Model import RPA10Model 355 self.shape_indep_list.append(RPA10Model) 356 self.multi_func_list.append(RPA10Model) 313 357 314 358 from sans.models.TeubnerStreyModel import TeubnerStreyModel 315 359 self.shape_indep_list.append(TeubnerStreyModel ) 316 360 361 from sans.models.TwoLorentzianModel import TwoLorentzianModel 362 self.shape_indep_list.append(TwoLorentzianModel ) 363 364 from sans.models.TwoPowerLawModel import TwoPowerLawModel 365 self.shape_indep_list.append(TwoPowerLawModel ) 366 367 from sans.models.UnifiedPowerRgModel import UnifiedPowerRgModel 368 self.shape_indep_list.append(UnifiedPowerRgModel ) 369 self.multi_func_list.append(UnifiedPowerRgModel) 370 317 371 from sans.models.LineModel import LineModel 318 372 self.shape_indep_list.append(LineModel) 319 373 374 from sans.models.ReflectivityModel import ReflectivityModel 375 self.multi_func_list.append(ReflectivityModel) 376 320 377 #Looking for plugins 321 378 self.plugins = findModels() 379 self._get_multifunc_models() 380 self.plugins.append(ReflectivityModel) 322 381 return 0 323 382 … … 466 525 wx.PostEvent(self.event_owner, evt) 467 526 527 def _get_multifunc_models(self): 528 """ 529 Get the multifunctional models 530 """ 531 for item in self.plugins: 532 try: 533 # check the multiplicity if any 534 if item.multiplicity_info[0] > 1: 535 self.multi_func_list.append(item) 536 except: 537 # pass to other items 538 pass 539 468 540 def get_model_list(self): 469 541 """ -
sansview/perspectives/fitting/pagestate.py
r4523b68 rfb59ed9 66 66 ["weights", "weights"]] 67 67 68 list_of_state_parameters = [["parameters", "parameters"] , 68 list_of_state_parameters = [["parameters", "parameters"] , 69 ["str_parameters", "str_parameters"] , 69 70 ["orientation_parameters", "orientation_params"], 70 71 ["dispersity_parameters", "orientation_params_disp"], … … 172 173 # Contains link between model ,all its parameters, and panel organization 173 174 self.parameters = [] 175 # String parameter list that can not be fitted 176 self.str_parameters = [] 174 177 # Contains list of parameters that cannot be fitted and reference to 175 178 #panel objects … … 270 273 obj.enable2D = copy.deepcopy(self.enable2D) 271 274 obj.parameters = copy.deepcopy(self.parameters) 275 obj.str_parameters = copy.deepcopy(self.str_parameters) 272 276 obj.fixed_param = copy.deepcopy(self.fixed_param) 273 277 obj.fittable_param = copy.deepcopy(self.fittable_param) … … 365 369 rep += "number parameters(self.parameters): %s\n"%len(self.parameters) 366 370 rep = self._repr_helper( list=self.parameters, rep=rep) 371 rep += "number str_parameters(self.str_parameters): %s\n"%len(self.str_parameters) 372 rep = self._repr_helper( list=self.str_parameters, rep=rep) 367 373 rep += "number orientation parameters" 368 374 rep += "(self.orientation_params): %s\n"%len(self.orientation_params) -
sansview/perspectives/fitting/simfitpage.py
r5062bbf rfb59ed9 23 23 for item in model.getParamList(): 24 24 if not item in model.getDispParamList(): 25 fittable_param.append(item) 25 if not item in model.non_fittable: 26 fittable_param.append(item) 26 27 27 28 for item in model.fixed: -
theoryview/perspectives/theory/basepage.py
ra1b2471 rfb59ed9 80 80 ##[cb state, name, value, "+/-", error of fit, min, max , units] 81 81 self.parameters=[] 82 # non-fittable parameter whose value is astring 83 self.str_parameters = [] 82 84 ## list of parameters to fit , must be like self.parameters 83 85 self.param_toFit=[] … … 721 723 self._reset_parameters_state(self.orientation_params, 722 724 state.orientation_params) 725 self._reset_parameters_state(self.str_parameters, 726 state.str_parameters) 723 727 self._reset_parameters_state(self.parameters,state.parameters) 724 728 ## display dispersion info layer … … 1059 1063 elif k == "Structure Factors": 1060 1064 self.struct_rbutton.SetValue(True) 1065 elif k == "Multi-Functions": 1066 continue 1061 1067 else: 1062 1068 self.plugin_rbutton.SetValue(True) … … 1109 1115 elif k == "Structure Factors": 1110 1116 self.struct_rbutton.SetValue(True) 1117 elif k == "Multi-Functions": 1118 continue 1111 1119 else: 1112 1120 self.plugin_rbutton.SetValue(True) … … 1195 1203 self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" ) 1196 1204 self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: " ) 1205 self.mutifactor_text1 = wx.StaticText( self,-1,"" ) 1197 1206 self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" ) 1198 1207 self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld) … … 1244 1253 mutifactor_selection.Add(self.multifactorbox) 1245 1254 mutifactor_selection.Add((5,5)) 1255 mutifactor_selection.Add(self.mutifactor_text1) 1256 mutifactor_selection.Add((10,5)) 1246 1257 mutifactor_selection.Add(self.show_sld_button) 1247 1258 … … 1253 1264 1254 1265 self._set_multfactor_combobox() 1266 self.multifactorbox.SetSelection(1) 1255 1267 self.show_sld_button.Hide() 1256 1268 … … 1271 1283 sld_data = Data1D(x,y) 1272 1284 sld_data.name = 'SLD' 1273 1274 self.panel = SLDPanel(self, data=sld_data, id =-1 )1285 sld_data.axes = self.sld_axes 1286 self.panel = SLDPanel(self, data=sld_data,axes =self.sld_axes,id =-1 ) 1275 1287 self.panel.ShowModal() 1276 1288 1277 def _set_multfactor_combobox(self ):1289 def _set_multfactor_combobox(self, multiplicity=10): 1278 1290 """ 1279 1291 Set comboBox for muitfactor of CoreMultiShellModel 1280 """ 1281 for idx in range(0,5): 1292 :param multiplicit: no. of multi-functionality 1293 """ 1294 # build content of the combobox 1295 for idx in range(0,multiplicity): 1282 1296 self.multifactorbox.Append(str(idx),int(idx)) 1283 self.multifactorbox.SetSelection(1)1297 #self.multifactorbox.SetSelection(1) 1284 1298 self._hide_multfactor_combobox() 1285 1299 … … 1290 1304 if not self.mutifactor_text.IsShown(): 1291 1305 self.mutifactor_text.Show(True) 1306 self.mutifactor_text1.Show(True) 1292 1307 if not self.multifactorbox.IsShown(): 1293 1308 self.multifactorbox.Show(True) … … 1299 1314 if self.mutifactor_text.IsShown(): 1300 1315 self.mutifactor_text.Hide() 1316 self.mutifactor_text1.Hide() 1301 1317 if self.multifactorbox.IsShown(): 1302 1318 self.multifactorbox.Hide() … … 1487 1503 # set multifactor for Mutifunctional models 1488 1504 if form_factor().__class__ in self.model_list_box["Multi-Functions"]: 1505 m_id = self.multifactorbox.GetCurrentSelection() 1506 multiplicity = form_factor().multiplicity_info[0] 1507 self.multifactorbox.Clear() 1508 #self.mutifactor_text.SetLabel(form_factor().details[]) 1509 self._set_multfactor_combobox(multiplicity) 1489 1510 self._show_multfactor_combobox() 1490 self.show_sld_button.Show(True) 1491 m_id = self.multifactorbox.GetCurrentSelection() 1511 text = form_factor().multiplicity_info[1]#'No. of Shells: ' 1512 1513 #self.mutifactor_text.Clear() 1514 self.mutifactor_text.SetLabel(text) 1515 1516 # Check max value 1517 if m_id > multiplicity -1: 1518 # default value 1519 m_id = 1 1492 1520 self.multi_factor = self.multifactorbox.GetClientData(m_id) 1493 1521 if self.multi_factor == None: self.multi_factor =1 1494 1522 form_factor = form_factor(int(self.multi_factor)) 1523 self.multifactorbox.SetSelection(m_id) 1524 # Check len of the text1 and max_multiplicity 1525 text = '' 1526 if form_factor.multiplicity_info[0] == len(form_factor.multiplicity_info[2]): 1527 text = form_factor.multiplicity_info[2][self.multi_factor] 1528 self.mutifactor_text1.SetLabel(text) 1529 # Check if model has get sld profile. 1530 if len(form_factor.multiplicity_info[3]) > 0: 1531 self.sld_axes = form_factor.multiplicity_info[3] 1532 self.show_sld_button.Show(True) 1533 else: 1534 self.sld_axes = "" 1495 1535 else: 1496 1536 self._hide_multfactor_combobox() -
theoryview/perspectives/theory/model_panel.py
r20905a0 rfb59ed9 362 362 event = PageInfoEvent(page = self) 363 363 wx.PostEvent(self.parent, event) 364 365 def _set_fun_box_list(self,fun_box): 366 """ 367 Set the list of func for multifunctional models 368 369 :param fun_box: function combo box 370 """ 371 # Check if it is multi_functional model 372 if self.model.__class__ not in self.model_list_box["Multi-Functions"]: 373 return None 374 # Get the func name list 375 list = self.model.fun_list 376 377 if len(list) == 0: 378 return None 379 380 # build function (combo)box 381 ind = 0 382 while(ind < len(list)): 383 for key, val in list.iteritems(): 384 if (val == ind): 385 fun_box.Append(key,val) 386 break 387 ind += 1 388 389 def _on_fun_box(self,event): 390 """ 391 Select an func: Erf,Rparabola,LParabola... 392 """ 393 fun_val = None 394 fun_box = event.GetEventObject() 395 name = fun_box.Name 396 value = fun_box.GetValue() 397 if self.model.fun_list.has_key(value): 398 fun_val = self.model.fun_list[value] 399 400 self.model.setParam(name,fun_val) 401 # save state 402 self._copy_parameters_state(self.str_parameters, self.state.str_parameters) 403 # update params 404 #self._update_paramv_on_fit() 405 406 # draw 407 self._draw_model() 408 self.Refresh() 409 # get ready for new event 410 event.Skip() 364 411 365 412 def set_data(self, list=[], state=None): … … 507 554 self.sizer3.Clear(True) 508 555 self.parameters = [] 556 self.str_parameters = [] 509 557 self.param_toFit=[] 510 558 self.fixed_param=[] … … 532 580 Custom compare to order, first by alphabets then second by number. 533 581 """ 582 # number at the last digit 534 583 a_last = a[len(a)-1] 535 584 b_last = b[len(b)-1] 536 585 # default 537 586 num_a = None 538 587 num_b = None 588 # split the names 589 a2 = a.lower().split('_') 590 b2 = b.lower().split('_') 591 # check length of a2, b2 592 len_a2 = len(a2) 593 len_b2 = len(b2) 539 594 # check if it contains a int number(<10) 540 595 try: … … 544 599 num_b = int(b_last) 545 600 except: pass 601 # Put 'scale' near the top; happens 602 # when numbered param name exists 603 if a == 'scale': 604 return -1 546 605 # both have a number 547 606 if num_a != None and num_b != None: 548 if num_a > num_b: return 1 607 if num_a > num_b: return -1 608 # same number 549 609 elif num_a == num_b: 550 return cmp(a.lower(), b.lower()) 551 else: return -1 610 # different last names 611 if a2[len_a2-1] != b2[len_b2-1] and num_a != 0: 612 return -cmp(a2[len_a2-1], b2[len_b2-1]) 613 else: 614 return cmp(a, b) 615 else: return 1 552 616 # one of them has a number 553 617 elif num_a != None: return 1 554 618 elif num_b != None: return -1 555 # no nu umbers619 # no numbers 556 620 else: return cmp(a.lower(), b.lower()) 557 621 558 622 keys.sort(custom_compare) 559 623 … … 578 642 iy += 1 579 643 ix = 0 580 name = wx.StaticText(self, -1,item) 581 sizer.Add( name,( iy, ix),(1,1), 582 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 583 584 ix += 1 585 value= self.model.getParam(item) 586 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 587 style=wx.TE_PROCESS_ENTER) 588 589 ctl1.SetValue(str (format_number(value))) 590 591 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 592 ix +=1 593 # Units 594 if self.model.details.has_key(item): 595 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 644 if self.model.__class__ in self.model_list_box["Multi-Functions"]\ 645 and item in self.model.non_fittable: 646 non_fittable_name = wx.StaticText(self, -1, item ) 647 sizer.Add(non_fittable_name,(iy, ix),(1,1),\ 648 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 649 ## add parameter value 650 ix += 1 651 value= self.model.getParam(item) 652 if len(self.model.fun_list) > 0: 653 num = item.split('_')[1][5:7] 654 fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item) 655 self._set_fun_box_list(fun_box) 656 fun_box.SetSelection(0) 657 #self.fun_box.SetToolTipString("A function describing the interface") 658 wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box) 659 else: 660 fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 661 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 662 fun_box.SetToolTipString("Hit 'Enter' after typing.") 663 fun_box.SetValue(format_number(value)) 664 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 665 ##[cb state, name, value, "+/-", error of fit, min, max , units] 666 self.str_parameters.append([None,item, fun_box, \ 667 None,None,None,None,None]) 596 668 else: 597 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 598 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 599 ##[cb state, name, value, "+/-", error of fit, min, max , units] 600 self.parameters.append([None,item, ctl1, 601 None,None, None, None,None]) 669 name = wx.StaticText(self, -1,item) 670 sizer.Add( name,( iy, ix),(1,1), 671 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 672 673 ix += 1 674 value= self.model.getParam(item) 675 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 676 style=wx.TE_PROCESS_ENTER) 677 678 ctl1.SetValue(str (format_number(value))) 679 680 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 681 ix +=1 682 # Units 683 if self.model.details.has_key(item): 684 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 685 else: 686 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 687 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 688 ##[cb state, name, value, "+/-", error of fit, min, max , units] 689 self.parameters.append([None,item, ctl1, 690 None,None, None, None,None]) 602 691 iy+=1 603 692 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) -
theoryview/perspectives/theory/models.py
re87f9fc rfb59ed9 240 240 self.multiplication_factor.append(ParallelepipedModel) 241 241 242 from sans.models.CSParallelepipedModel import CSParallelepipedModel 243 self.shape_list.append(CSParallelepipedModel) 244 self.multiplication_factor.append(CSParallelepipedModel) 245 242 246 from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 243 247 self.shape_list.append(EllipticalCylinderModel) 244 248 self.multiplication_factor.append(EllipticalCylinderModel) 245 249 250 from sans.models.BarBellModel import BarBellModel 251 self.shape_list.append(BarBellModel) 252 # not implemeted yet! 253 #self.multiplication_factor.append(BarBellModel) 254 255 from sans.models.CappedCylinderModel import CappedCylinderModel 256 self.shape_list.append(CappedCylinderModel) 257 # not implemeted yet! 258 #self.multiplication_factor.append(CappedCylinderModel) 259 246 260 from sans.models.EllipsoidModel import EllipsoidModel 247 261 self.shape_list.append(EllipsoidModel) … … 267 281 from sans.models.LamellarPSHGModel import LamellarPSHGModel 268 282 self.shape_list.append(LamellarPSHGModel) 283 284 from sans.models.LamellarPCrystalModel import LamellarPCrystalModel 285 self.shape_list.append(LamellarPCrystalModel) 286 287 from sans.models.SCCrystalModel import SCCrystalModel 288 self.shape_list.append(SCCrystalModel) 289 290 from sans.models.FCCrystalModel import FCCrystalModel 291 self.shape_list.append(FCCrystalModel) 292 293 from sans.models.BCCrystalModel import BCCrystalModel 294 self.shape_list.append(BCCrystalModel) 269 295 270 296 ## Structure factor … … 290 316 self.shape_indep_list.append(BEPolyelectrolyte ) 291 317 self.form_factor_dict[str(wx.NewId())] = [SphereModel] 292 318 319 from sans.models.BroadPeakModel import BroadPeakModel 320 self.shape_indep_list.append(BroadPeakModel) 321 322 from sans.models.CorrLengthModel import CorrLengthModel 323 self.shape_indep_list.append(CorrLengthModel) 324 293 325 from sans.models.DABModel import DABModel 294 326 self.shape_indep_list.append(DABModel ) … … 297 329 self.shape_indep_list.append(DebyeModel ) 298 330 331 #FractalModel (a c-model)is now being used instead of FractalAbsModel. 332 from sans.models.FractalModel import FractalModel 333 self.shape_indep_list.append(FractalModel ) 334 335 from sans.models.FractalCoreShellModel import FractalCoreShellModel 336 self.shape_indep_list.append(FractalCoreShellModel ) 337 338 from sans.models.GaussLorentzGelModel import GaussLorentzGelModel 339 self.shape_indep_list.append(GaussLorentzGelModel) 340 299 341 from sans.models.GuinierModel import GuinierModel 300 342 self.shape_indep_list.append(GuinierModel ) 301 343 302 from sans.models. FractalModel import FractalModel303 self.shape_indep_list.append( FractalModel )304 344 from sans.models.GuinierPorodModel import GuinierPorodModel 345 self.shape_indep_list.append(GuinierPorodModel ) 346 305 347 from sans.models.LorentzModel import LorentzModel 306 348 self.shape_indep_list.append( LorentzModel) … … 314 356 from sans.models.Poly_GaussCoil import Poly_GaussCoil 315 357 self.shape_indep_list.append(Poly_GaussCoil) 316 358 359 from sans.models.PolymerExclVolume import PolymerExclVolume 360 self.shape_indep_list.append(PolymerExclVolume) 361 317 362 from sans.models.PorodModel import PorodModel 318 self.shape_indep_list.append(PorodModel ) 319 320 #FractalModel (a c-model)will be used.321 #from sans.models.FractalAbsModel import FractalAbsModel322 #self.shape_indep_list.append(FractalAbsModel)363 self.shape_indep_list.append(PorodModel ) 364 365 from sans.models.RPA10Model import RPA10Model 366 self.shape_indep_list.append(RPA10Model) 367 self.multi_func_list.append(RPA10Model) 323 368 324 369 from sans.models.TeubnerStreyModel import TeubnerStreyModel 325 370 self.shape_indep_list.append(TeubnerStreyModel ) 326 371 372 from sans.models.TwoLorentzianModel import TwoLorentzianModel 373 self.shape_indep_list.append(TwoLorentzianModel ) 374 375 from sans.models.TwoPowerLawModel import TwoPowerLawModel 376 self.shape_indep_list.append(TwoPowerLawModel ) 377 378 from sans.models.UnifiedPowerRgModel import UnifiedPowerRgModel 379 self.shape_indep_list.append(UnifiedPowerRgModel ) 380 self.multi_func_list.append(UnifiedPowerRgModel) 381 327 382 from sans.models.LineModel import LineModel 328 383 self.shape_indep_list.append(LineModel) 384 385 from sans.models.ReflectivityModel import ReflectivityModel 386 self.multi_func_list.append(ReflectivityModel) 329 387 330 388 #Looking for plugins 331 389 self.plugins = findModels() 332 390 self._get_multifunc_models() 391 self.plugins.append(ReflectivityModel) 333 392 return 0 334 393 … … 347 406 self.model_combobox.set_list("Multi-Functions", self.multi_func_list) 348 407 return self.model_combobox 349 408 409 def _get_multifunc_models(self): 410 """ 411 Get the multifunctional models 412 """ 413 for item in self.plugins: 414 try: 415 # check the multiplicity if any 416 if item.multiplicity_info[0] > 1: 417 self.multi_func_list.append(item) 418 except: 419 # pass to other items 420 pass -
theoryview/perspectives/theory/pagestate.py
r4523b68 rfb59ed9 41 41 # Contains link between model ,all its parameters, and panel organization 42 42 self.parameters =[] 43 # String parameter list that can not be fitted 44 self.str_parameters = [] 43 45 # Contains list of parameters that cannot be fitted and reference to 44 46 #panel objects … … 124 126 obj.enable2D = copy.deepcopy(self.enable2D) 125 127 obj.parameters = copy.deepcopy(self.parameters) 128 obj.str_parameters = copy.deepcopy(self.str_parameters) 126 129 obj.fixed_param = copy.deepcopy(self.fixed_param) 127 130 obj.fittable_param = copy.deepcopy(self.fittable_param) … … 181 184 rep += "maximum value : %s \n"%str(item[6][1]) 182 185 rep += "parameter unit: %s\n\n"%str(item[7]) 186 rep += "number str_parameters(self.str_parameters): %s\n"%len(self.str_parameters) 183 187 rep +="number orientation parameters" 184 188 rep +="(self.orientation_params): %s\n"%len(self.orientation_params) -
theoryview/perspectives/theory/profile_dialog.py
ra1b2471 rfb59ed9 2 2 import sys 3 3 4 import copy,numpy4 from copy import deepcopy 5 5 from danse.common.plottools.PlotPanel import PlotPanel 6 6 from danse.common.plottools.plottables import Graph … … 17 17 if sys.platform.count("win32")>0: 18 18 _STATICBOX_WIDTH = 380 19 PANEL_SIZE = 4 2019 PANEL_SIZE = 475 20 20 FONT_VARIANT = 0 21 21 else: 22 22 _STATICBOX_WIDTH = 410 23 PANEL_SIZE = 45023 PANEL_SIZE = 505 24 24 FONT_VARIANT = 1 25 25 … … 36 36 ## Flag to tell the AUI manager to put this panel in the center pane 37 37 CENTER_PANE = True 38 def __init__(self, parent=None,base=None,data =None, id = -1, *args, **kwds):38 def __init__(self, parent=None,base=None,data =None,axes =['Radius'], id = -1, *args, **kwds): 39 39 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 40 kwds["size"] = wx.Size(_STATICBOX_WIDTH* 2,PANEL_SIZE)40 kwds["size"] = wx.Size(_STATICBOX_WIDTH*1.5,PANEL_SIZE) 41 41 wx.Dialog.__init__(self, parent, id = id, *args, **kwds) 42 42 if data != None: … … 54 54 self.name = self.data.name 55 55 56 # Panel for 2Dplot57 self.plotpanel = SLDplotpanel(self, -1, style=wx.TRANSPARENT_WINDOW)56 # Panel for plot 57 self.plotpanel = SLDplotpanel(self, axes, -1, style=wx.TRANSPARENT_WINDOW) 58 58 self.cmap = DEFAULT_CMAP 59 59 ## Create Artist and bind it … … 61 61 62 62 self._setup_layout() 63 self.newplot=Theory1D(self.data.x,self.data.y) 63 data_plot = deepcopy(self.data) 64 self.newplot=Theory1D(data_plot.x,data_plot.y) 64 65 self.newplot.name = 'SLD' 65 66 self.plotpanel.add_image(self.newplot) … … 76 77 sizer = wx.GridBagSizer(14,14) 77 78 78 sizer.Add(self.plotpanel,(0, 0), (13, 13), wx.EXPAND | wx.LEFT| wx.RIGHT, 1 5)79 sizer.Add(self.plotpanel,(0, 0), (13, 13), wx.EXPAND | wx.LEFT| wx.RIGHT, 1) 79 80 80 81 #-----Button------------1 … … 110 111 Panel 111 112 """ 112 def __init__(self, parent, id = -1, color = None, dpi = None, **kwargs):113 def __init__(self, parent,axes=[], id = -1, color = None, dpi = None, **kwargs): 113 114 """ 114 115 """ … … 120 121 self.plots = {} 121 122 self.graph = Graph() 122 123 123 self.axes_label = [] 124 for idx in range(0,len(axes)): 125 self.axes_label.append(axes[idx]) 124 126 125 127 def add_image(self, plot): … … 133 135 self.graph.add(plot) 134 136 #add axes 135 self.graph.xaxis('\\rm{Radius} ', '\\AA') 137 x1_label = self.axes_label[0] 138 self.graph.xaxis('\\rm{%s} '% x1_label, '\\AA') 136 139 self.graph.yaxis('\\rm{SLD} ', '\\AA^{-2}') 137 140
Note: See TracChangeset
for help on using the changeset viewer.