Changeset 4a52223 in sasview
- Timestamp:
- Oct 12, 2011 5:11:12 PM (13 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:
- ea8283d
- Parents:
- 1363416
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitting.py
r2de278d9 r4a52223 1094 1094 for res in list_res: 1095 1095 model, data = res.inputs[0] 1096 correct_result = False 1096 1097 if model is not None and hasattr(model, "model"): 1097 1098 model = model.model 1098 1099 if data is not None and hasattr(data, "sans_data"): 1099 1100 data = data.sans_data 1100 if res.fitness is None or \ 1101 is_data2d = issubclass(data.__class__, Data2D) 1102 #check consistency of arrays 1103 if not is_data2d: 1104 if len(res.theory) == len(res.index) and \ 1105 len(res.index) == len(data.y): 1106 correct_result = True 1107 else: 1108 if len(res.theory)== len(res.index) and \ 1109 len(res.index) == len(data.data): 1110 correct_result = True 1111 #get all fittable parameters of the current model 1112 param_list = model.getParamList() 1113 for param in model.getDispParamList(): 1114 if not model.is_fittable(param) and \ 1115 param in param_list: 1116 param_list.remove(param) 1117 if not correct_result or res.fitness is None or \ 1101 1118 not numpy.isfinite(res.fitness) or \ 1102 1119 numpy.any(res.pvec == None) or not \ … … 1110 1127 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1111 1128 model_name) 1129 ERROR = numpy.NAN 1130 cell = BatchCell() 1131 cell.label = res.fitness 1132 cell.value = res.fitness 1133 batch_outputs["Chi2"].append(ERROR) 1134 for param in param_list: 1135 # save value of fixed parameters 1136 if param not in batch_outputs.keys(): 1137 batch_outputs[param] = [] 1138 if param not in res.param_list: 1139 batch_outputs[str(param)].append(ERROR) 1140 for index in range(len(res.param_list)): 1141 #save only fitted values 1142 batch_outputs[res.param_list[index]].append(ERROR) 1143 batch_inputs["error on %s" % res.param_list[index]].append(ERROR) 1112 1144 else: 1113 1145 cell = BatchCell() … … 1116 1148 batch_outputs["Chi2"].append(cell) 1117 1149 # add parameters to batch_results 1118 param_list = model.getParamList()1119 for param in model.getDispParamList():1120 if not model.is_fittable(param) and \1121 param in param_list:1122 param_list.remove(param)1123 1150 for param in param_list: 1124 1151 # save value of fixed parameters … … 1142 1169 fitproblem = self.page_finder[pid][data.id] 1143 1170 qmin, qmax = fitproblem.get_range() 1144 flag = issubclass(data.__class__, Data2D) 1145 if not flag: 1146 if len(res.theory) == len(res.index) and \ 1147 len(res.index) == len(data.y): 1148 correct_result = True 1171 1172 if correct_result: 1173 if not is_data2d: 1149 1174 self._complete1D(x=data.x, y=res.theory, page_id=pid, 1150 1175 elapsed=None, … … 1154 1179 data=data, update_chisqr=False, 1155 1180 source='fit') 1156 self.on_set_batch_result(page_id=pid,1157 fid=data.id,1158 batch_outputs=batch_outputs,1159 batch_inputs=batch_inputs)1160 1181 else: 1161 data_name = str(None)1162 if data is not None:1163 data_name = str(data.name)1164 model_name = str(None)1165 if model is not None:1166 model_name = str(model.name)1167 msg += "Data %s and Model %s did not fit.\n" % (data_name,1168 model_name)1169 1170 else:1171 if len(res.theory)== len(res.index) and \1172 len(res.index) == len(data.data):1173 correct_result = True1174 1182 self._complete2D(image=res.theory, data=data, 1175 1183 model=model, … … 1181 1189 update_chisqr=False, 1182 1190 source='fit') 1183 1191 self.on_set_batch_result(page_id=pid, 1184 1192 fid=data.id, 1185 1193 batch_outputs=batch_outputs, 1186 1194 batch_inputs=batch_inputs) 1187 else: 1188 data_name = str(None) 1189 if data is not None: 1190 data_name = str(data.name) 1191 model_name = str(None) 1192 if model is not None: 1193 model_name = str(model.name) 1194 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1195 model_name) 1196 1195 1197 1196 wx.PostEvent(self.parent, StatusEvent(status=msg, error="error", 1198 1197 type="stop"))
Note: See TracChangeset
for help on using the changeset viewer.