Changeset 6fb6592 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Dec 5, 2016 8:32:42 AM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 1c6bad0
- Parents:
- c9677c9 (diff), 1a5d5f2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sasgui/perspectives
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitting.py
rec72ceb r1a5d5f2 1521 1521 for uid in page_id: 1522 1522 res = result[index] 1523 fit_msg = res.mesg 1523 1524 if res.fitness is None or \ 1524 1525 not numpy.isfinite(res.fitness) or \ 1525 1526 numpy.any(res.pvec == None) or \ 1526 1527 not numpy.all(numpy.isfinite(res.pvec)): 1527 msg = "Fitting did not converge!!!" 1528 evt = StatusEvent(status=msg, info="warning", type="stop") 1529 wx.PostEvent(self.parent, evt) 1528 fit_msg += "\nFitting did not converge!!!" 1530 1529 wx.CallAfter(self._update_fit_button, page_id) 1531 1530 else: … … 1550 1549 wx.CallAfter(cpage._on_fit_complete) 1551 1550 except KeyboardInterrupt: 1552 msg = "Singular point: Fitting Stoped." 1553 evt = StatusEvent(status=msg, info="info", type="stop") 1554 wx.PostEvent(self.parent, evt) 1551 fit_msg += "\nSingular point: Fitting stopped." 1555 1552 except: 1556 msg = "Singular point: Fitting Error occurred." 1557 evt = StatusEvent(status=msg, info="error", type="stop") 1558 wx.PostEvent(self.parent, evt) 1553 fit_msg += "\nSingular point: Fitting error occurred." 1554 if fit_msg: 1555 evt = StatusEvent(status=fit_msg, info="warning", type="stop") 1556 wx.PostEvent(self.parent, evt) 1559 1557 1560 1558 except: -
src/sas/sasgui/perspectives/fitting/basepage.py
rc8e1996 r0b1d7d3 1106 1106 """ 1107 1107 for key, value in self.master_category_dict.iteritems(): 1108 formfactor = state.formfactorcombobox.split(":") 1109 if isinstance(formfactor, list): 1110 formfactor = formfactor[0] 1108 1111 for list_item in value: 1109 if state.formfactorcomboboxin list_item:1112 if formfactor in list_item: 1110 1113 return self.categorybox.Items.index(key) 1111 1114 return 0 … … 1157 1160 category_pos = int(state.categorycombobox) 1158 1161 except: 1159 state.formfactorcombobox = state.formfactorcombobox.lower() 1160 state.formfactorcombobox = \ 1161 state.formfactorcombobox.replace('model', '') 1162 state.formfactorcombobox = unicode(state.formfactorcombobox) 1162 if state.formfactorcombobox is not None \ 1163 and not state._is_sasmodels(): 1164 state._convert_to_sasmodels() 1163 1165 state.categorycombobox = unicode(state.categorycombobox) 1164 1166 if state.categorycombobox in self.categorybox.Items: … … 1175 1177 formfactor_pos = int(state.formfactorcombobox) 1176 1178 except: 1179 if self.categorybox.GetValue() == 'Customized Models' \ 1180 and '[plug-in]' not in state.formfactorcombobox: 1181 state.formfactorcombobox = \ 1182 '[plug-in] ' + state.formfactorcombobox 1177 1183 formfactor_pos = 0 1178 1184 for ind_form in range(self.formfactorbox.GetCount()): … … 1528 1534 index_data = ((self.qmin_x <= self.data.x) & 1529 1535 (self.data.x <= self.qmax_x)) 1530 val = str(len( self.data.x[index_data is True]))1536 val = str(len([index_data is True])) 1531 1537 self.Npts_fit.SetValue(val) 1532 1538 else: … … 1574 1580 if len(statelist) == 0 or len(listtorestore) == 0: 1575 1581 return 1576 if len(statelist) != len(listtorestore):1577 return1578 1582 1579 1583 for j in range(len(listtorestore)): 1580 item_page = listtorestore[j] 1581 item_page_info = statelist[j] 1582 # change the state of the check box for simple parameters 1583 if item_page[0] is not None: 1584 item_page[0].SetValue(item_page_info[0]) 1585 if item_page[2] is not None: 1586 item_page[2].SetValue(item_page_info[2]) 1587 if item_page[2].__class__.__name__ == "ComboBox": 1588 if item_page_info[2] in self.model.fun_list: 1589 fun_val = self.model.fun_list[item_page_info[2]] 1590 self.model.setParam(item_page_info[1], fun_val) 1591 if item_page[3] is not None: 1592 # show or hide text +/- 1593 if item_page_info[2]: 1594 item_page[3].Show(True) 1595 else: 1596 item_page[3].Hide() 1597 if item_page[4] is not None: 1598 # show of hide the text crtl for fitting error 1599 if item_page_info[4][0]: 1600 item_page[4].Show(True) 1601 item_page[4].SetValue(item_page_info[4][1]) 1602 else: 1603 item_page[3].Hide() 1604 if item_page[5] is not None: 1605 # show of hide the text crtl for fitting error 1606 item_page[5].Show(item_page_info[5][0]) 1607 item_page[5].SetValue(item_page_info[5][1]) 1608 1609 if item_page[6] is not None: 1610 # show of hide the text crtl for fitting error 1611 item_page[6].Show(item_page_info[6][0]) 1612 item_page[6].SetValue(item_page_info[6][1]) 1584 for param in statelist: 1585 if param[1] == listtorestore[j][1]: 1586 item_page = listtorestore[j] 1587 item_page_info = param 1588 if (item_page_info[1] == "theta" or item_page_info[1] == 1589 "phi") and not self._is_2D(): 1590 break 1591 # change the state of the check box for simple parameters 1592 if item_page[0] is not None: 1593 item_page[0].SetValue(item_page_info[0]) 1594 if item_page[2] is not None: 1595 # TODO: On loading save state, should try to coerce 1596 # TODO: length and scale params to positive values 1597 item_page[2].SetValue(item_page_info[2]) 1598 if item_page[2].__class__.__name__ == "ComboBox": 1599 if item_page_info[2] in self.model.fun_list: 1600 fun_val = self.model.fun_list[item_page_info[2]] 1601 self.model.setParam(item_page_info[1], fun_val) 1602 if item_page[3] is not None: 1603 # show or hide text +/- 1604 if item_page_info[2]: 1605 item_page[3].Show(True) 1606 else: 1607 item_page[3].Hide() 1608 if item_page[4] is not None: 1609 # show of hide the text crtl for fitting error 1610 if item_page_info[4][0]: 1611 item_page[4].Show(True) 1612 item_page[4].SetValue(item_page_info[4][1]) 1613 else: 1614 item_page[3].Hide() 1615 if item_page[5] is not None: 1616 # show of hide the text crtl for fitting error 1617 item_page[5].Show(item_page_info[5][0]) 1618 item_page[5].SetValue(item_page_info[5][1]) 1619 1620 if item_page[6] is not None: 1621 # show of hide the text crtl for fitting error 1622 item_page[6].Show(item_page_info[6][0]) 1623 item_page[6].SetValue(item_page_info[6][1]) 1624 1625 break 1613 1626 1614 1627 def _reset_strparam_state(self, listtorestore, statelist): -
src/sas/sasgui/perspectives/fitting/pagestate.py
rc8e1996 r0b1d7d3 25 25 from lxml import etree 26 26 27 from sasmodels import convert 27 28 import sasmodels.weights 28 29 … … 355 356 obj.saved_states[copy_name] = copy_state 356 357 return obj 358 359 def _is_sasmodels(self): 360 """ 361 A check to see if the loaded save state was saved in SasView v4_0+ 362 :return: None 363 """ 364 newname = convert._conversion_target(self.formfactorcombobox) 365 if newname == None: 366 return True 367 else: 368 return False 369 370 def _convert_to_sasmodels(self): 371 """ 372 Convert parameters to a form usable by sasmodels converter 373 374 :return: None 375 """ 376 # Create conversion dictionary to send to sasmodels 377 p = dict() 378 for fittable, name, value, _, uncert, lower, upper, units in \ 379 self.parameters: 380 if not value: 381 value = numpy.nan 382 if not uncert or uncert[1] == '': 383 uncert[0] = False 384 uncert[1] = numpy.nan 385 if not upper or upper[1] == '': 386 upper[0] = False 387 upper[1] = numpy.nan 388 if not lower or lower[1] == '': 389 lower[0] = False 390 lower[1] = numpy.nan 391 p[name] = float(value) 392 p[name + ".fittable"] = bool(fittable) 393 p[name + ".std"] = float(uncert[1]) 394 p[name + ".upper"] = float(upper[1]) 395 p[name + ".lower"] = float(lower[1]) 396 p[name + ".units"] = units 397 398 structurefactor, params = \ 399 convert.convert_model(self.structurecombobox, p) 400 formfactor, params = \ 401 convert.convert_model(self.formfactorcombobox, params) 402 # if len(self.str_parameters) > 0: 403 # formfactor, str_params = \ 404 # convert.convert_model(formfactor, self.str_parameters) 405 406 # Only convert if old != new, otherwise all the same 407 if formfactor != self.formfactorcombobox or \ 408 structurefactor != self.structurecombobox: 409 self.formfactorcombobox = formfactor 410 self.structurecombobox = structurefactor 411 self.parameters = [] 412 for name, info in params.iteritems(): 413 if ".fittable" in name or ".std" in name or ".upper" in name or\ 414 ".lower" in name or ".units" in name: 415 pass 416 else: 417 fittable = params.get(name + ".fittable", True) 418 std = params.get(name + ".std", '0.0') 419 upper = params.get(name + ".upper", 'inf') 420 lower = params.get(name + ".lower", '-inf') 421 units = params.get(name + ".units") 422 if std is not None and std is not numpy.nan: 423 std = [True, str(std)] 424 else: 425 std = [False, ''] 426 if lower is not None and lower is not numpy.nan: 427 lower = [True, str(lower)] 428 else: 429 lower = [True, '-inf'] 430 if upper is not None and upper is not numpy.nan: 431 upper = [True, str(upper)] 432 else: 433 upper = [True, 'inf'] 434 param_list = [bool(fittable), str(name), str(info), 435 "+/-", std, lower, upper, str(units)] 436 self.parameters.append(param_list) 437 357 438 358 439 def _repr_helper(self, list, rep): -
src/sas/sasgui/perspectives/invariant/invariant_state.py
rcb93b40 rdb5294e 423 423 for item in DEFAULT_STATE: 424 424 input_field = get_content('ns:%s' % item, entry) 425 val = str(input_field.text.strip()) 425 if input_field.text is not None: 426 val = str(input_field.text.strip()) 427 else: 428 val = '' 426 429 if input_field is not None: 427 430 temp_state[item] = val … … 433 436 for item in DEFAULT_STATE: 434 437 input_field = get_content('ns:%s' % item, entry) 435 val = str(input_field.text.strip()) 438 if input_field.text is not None: 439 val = str(input_field.text.strip()) 440 else: 441 val = '' 436 442 if input_field is not None: 437 443 self.set_saved_state(name=item, value=val)
Note: See TracChangeset
for help on using the changeset viewer.