Changeset 8bdb6f5 in sasview for src/sas/qtgui
- Timestamp:
- Feb 16, 2017 9:26:32 AM (8 years ago)
- Branches:
- 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
- Children:
- dba6e57
- Parents:
- 4c7dd9f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/Fitting.py
r4c7dd9f r8bdb6f5 1 1 import sys 2 import json 3 import os 2 4 from PyQt4 import QtGui 3 5 from PyQt4 import QtCore 4 6 5 7 from UI.fitting import Ui_Dialog 8 9 from sasmodels import generate 10 from sasmodels import modelinfo 11 12 from collections import defaultdict 13 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 6 14 7 15 class prototype(QtGui.QDialog, Ui_Dialog): … … 12 20 self.setupUi(self) 13 21 22 self._readCategoryInfo() 23 cat_list = sorted(self.master_category_dict.keys()) 24 self.comboBox.addItems(cat_list) 14 25 self.tableView.setModel(self._model_model) 15 self.setModelModel() 26 27 model_list = self.master_category_dict['Cylinder'] 28 for (model, enabled) in model_list: 29 self.comboBox_2.addItem(model) 30 self.setModelModel('barbell') 16 31 17 32 self.pushButton.setEnabled(False) … … 34 49 self.tableView_2.setIndexWidget(i,c) 35 50 51 def _readCategoryInfo(self): 52 """ 53 Reads the categories in from file 54 """ 55 self.master_category_dict = defaultdict(list) 56 self.by_model_dict = defaultdict(list) 57 self.model_enabled_dict = defaultdict(bool) 58 59 try: 60 categorization_file = CategoryInstaller.get_user_file() 61 if not os.path.isfile(categorization_file): 62 categorization_file = CategoryInstaller.get_default_file() 63 cat_file = open(categorization_file, 'rb') 64 self.master_category_dict = json.load(cat_file) 65 self._regenerate_model_dict() 66 cat_file.close() 67 except IOError: 68 raise 69 print 'Problem reading in category file.' 70 print 'We even looked for it, made sure it was there.' 71 print 'An existential crisis if there ever was one.' 72 73 def _regenerate_model_dict(self): 74 """ 75 regenerates self.by_model_dict which has each model name as the 76 key and the list of categories belonging to that model 77 along with the enabled mapping 78 """ 79 self.by_model_dict = defaultdict(list) 80 for category in self.master_category_dict: 81 for (model, enabled) in self.master_category_dict[category]: 82 self.by_model_dict[model].append(category) 83 self.model_enabled_dict[model] = enabled 84 36 85 37 def setModelModel(self ):86 def setModelModel(self, model_name): 38 87 # Crete/overwrite model items 39 88 40 parameters=[] 41 p=["scale", "1", "0", "inf", ""] 42 for i in xrange(1): 43 #for parameter in parameters.keys(): 44 item1 = QtGui.QStandardItem("background") 89 model_name = str(model_name) 90 kernel_module = generate.load_kernel_module(model_name) 91 parameters = modelinfo.make_parameter_table(getattr(kernel_module, 'parameters', [])) 92 93 #TODO: scaale and background are implicit in sasmodels and needs to be added 94 item1 = QtGui.QStandardItem('scale') 95 item1.setCheckable(True) 96 item2 = QtGui.QStandardItem('1.0') 97 item3 = QtGui.QStandardItem('0.0') 98 item4 = QtGui.QStandardItem('inf') 99 item5 = QtGui.QStandardItem('') 100 self._model_model.appendRow([item1, item2, item3, item4, item5]) 101 102 item1 = QtGui.QStandardItem('background') 103 item1.setCheckable(True) 104 item2 = QtGui.QStandardItem('0.001') 105 item3 = QtGui.QStandardItem('-inf') 106 item4 = QtGui.QStandardItem('inf') 107 item5 = QtGui.QStandardItem('1/cm') 108 self._model_model.appendRow([item1, item2, item3, item4, item5]) 109 110 #TODO: iq_parameters are used here. If orientation paramateres or magnetic are needed kernel_paramters should be used instead 111 #For orientation and magentic parameters param.type needs to be checked 112 for param in parameters.iq_parameters: 113 item1 = QtGui.QStandardItem(param.name) 45 114 item1.setCheckable(True) 46 item2 = QtGui.QStandardItem("0.001") 47 item3 = QtGui.QStandardItem("-inf") 48 item4 = QtGui.QStandardItem("inf") 49 item5 = QtGui.QStandardItem("1/cm") 50 self._model_model.appendRow([item1, item2, item3, item4, item5]) 51 52 item1 = QtGui.QStandardItem("l_radius") 53 item1.setCheckable(True) 54 item2 = QtGui.QStandardItem("100") 55 item3 = QtGui.QStandardItem("0") 56 item4 = QtGui.QStandardItem("inf") 57 item5 = QtGui.QStandardItem("A") 58 self._model_model.appendRow([item1, item2, item3, item4, item5]) 59 60 item1 = QtGui.QStandardItem("ls_sld") 61 item1.setCheckable(True) 62 item2 = QtGui.QStandardItem("3.5e-06") 63 item3 = QtGui.QStandardItem("0") 64 item4 = QtGui.QStandardItem("inf") 65 item5 = QtGui.QStandardItem("1/A^2") 66 self._model_model.appendRow([item1, item2, item3, item4, item5]) 67 68 item1 = QtGui.QStandardItem("s_radius") 69 item1.setCheckable(True) 70 item2 = QtGui.QStandardItem("25") 71 item3 = QtGui.QStandardItem("0") 72 item4 = QtGui.QStandardItem("inf") 73 item5 = QtGui.QStandardItem("A") 74 self._model_model.appendRow([item1, item2, item3, item4, item5]) 75 76 item1 = QtGui.QStandardItem("solvent_sld") 77 item1.setCheckable(True) 78 item2 = QtGui.QStandardItem("6.36e-06") 79 item3 = QtGui.QStandardItem("0") 80 item4 = QtGui.QStandardItem("inf") 81 item5 = QtGui.QStandardItem("1/A^2") 82 self._model_model.appendRow([item1, item2, item3, item4, item5]) 83 84 item1 = QtGui.QStandardItem("vol_frac_ls") 85 item1.setCheckable(True) 86 item2 = QtGui.QStandardItem("0.1") 87 item3 = QtGui.QStandardItem("0") 88 item4 = QtGui.QStandardItem("inf") 89 item5 = QtGui.QStandardItem("") 115 item2 = QtGui.QStandardItem(str(param.default)) 116 item3 = QtGui.QStandardItem(str(param.limits[0])) 117 item4 = QtGui.QStandardItem(str(param.limits[1])) 118 item5 = QtGui.QStandardItem(param.units) 90 119 self._model_model.appendRow([item1, item2, item3, item4, item5]) 91 120
Note: See TracChangeset
for help on using the changeset viewer.