Changeset 5251ec6 in sasview for src/sas/sasgui/perspectives/pr/pr.py
- Timestamp:
- Oct 11, 2018 2:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/pr/pr.py
r2469df7 r5251ec6 18 18 19 19 import sys 20 import wx21 20 import logging 22 21 import time 23 22 import math 23 24 import wx 24 25 import numpy as np 25 26 import pylab 27 26 28 from sas.sasgui.guiframe.gui_manager import MDIFrame 27 29 from sas.sasgui.guiframe.dataFitting import Data1D … … 33 35 import sas.sascalc.dataloader 34 36 35 from pr_widgets import load_error36 37 from sas.sasgui.guiframe.plugin_base import PluginBase 38 39 from .inversion_state import Reader # .prv file reader 40 from .inversion_panel import InversionControl 41 #from .inversion_panel import HelpDialog 42 from .inversion_panel import PrDistDialog 43 from .pr_thread import CalcPr 44 from .pr_thread import EstimatePr 45 from .pr_thread import EstimateNT 46 from .pr_widgets import load_error 47 from .pr_widgets import DataDialog 37 48 38 49 logger = logging.getLogger(__name__) … … 106 117 self.list_plot_id = [] 107 118 108 # Associate the inversion state reader with .prv files109 from inversion_state import Reader110 111 119 # Create a CanSAS/Pr reader 112 120 self.state_reader = Reader(self.set_state) … … 151 159 msg = "Pr.set_state: datainfo parameter cannot " 152 160 msg += "be None in standalone mode" 153 raise RuntimeError , msg161 raise RuntimeError(msg) 154 162 155 163 # Ensuring that plots are coordinated correctly … … 184 192 title=self.current_plottable.title)) 185 193 self.control_panel.set_state(state) 186 except :187 logger.error("prview.set_state: %s" % sys.exc_value)194 except Exception as exc: 195 logger.error("prview.set_state: %s" % exc) 188 196 189 197 … … 195 203 196 204 """ 197 from inversion_panel import HelpDialog198 205 dialog = HelpDialog(None, -1) 199 206 if dialog.ShowModal() == wx.ID_OK: … … 369 376 Redisplay P(r) with a different number of points 370 377 """ 371 from inversion_panel import PrDistDialog372 378 dialog = PrDistDialog(None, -1) 373 379 dialog.set_content(self._pr_npts) … … 452 458 # Notify the user if we could not read the file 453 459 if dataread is None: 454 raise RuntimeError , "Invalid data"460 raise RuntimeError("Invalid data") 455 461 456 462 x = None … … 472 478 if dataread is None: 473 479 return x, y, err 474 raise RuntimeError , "This tool can only read 1D data"480 raise RuntimeError("This tool can only read 1D data") 475 481 476 482 self._current_file_data.x = x … … 511 517 data_y = np.append(data_y, y) 512 518 data_err = np.append(data_err, err) 513 except :514 logger.error( sys.exc_value)519 except Exception as exc: 520 logger.error(exc) 515 521 516 522 if scale is not None: … … 562 568 data_y = np.append(data_y, y) 563 569 data_err = np.append(data_err, err) 564 except :565 logger.error( sys.exc_value)570 except Exception as exc: 571 logger.error(exc) 566 572 elif line.find("The 6 columns") >= 0: 567 573 data_started = True … … 720 726 Start a calculation thread 721 727 """ 722 from pr_thread import CalcPr723 724 728 # If a thread is already started, stop it 725 729 if self.calc_thread is not None and self.calc_thread.isrunning(): … … 849 853 try: 850 854 pr = self._create_file_pr(data) 851 except :852 status = "Problem reading data: %s" % sys.exc_value855 except Exception as exc: 856 status = "Problem reading data: %s" % exc 853 857 wx.PostEvent(self.parent, StatusEvent(status=status)) 854 raise RuntimeError , status858 raise RuntimeError(status) 855 859 856 860 # If the file contains nothing, just return 857 861 if pr is None: 858 raise RuntimeError , "Loaded data is invalid"862 raise RuntimeError("Loaded data is invalid") 859 863 860 864 self.pr = pr … … 906 910 msg = "pr.save_data: the data being saved is not a" 907 911 msg += " sas.data_info.Data1D object" 908 raise RuntimeError , msg912 raise RuntimeError(msg) 909 913 910 914 def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None, … … 928 932 self.pr = pr 929 933 self.perform_inversion() 930 except :931 wx.PostEvent(self.parent, StatusEvent(status= sys.exc_value))934 except Exception as exc: 935 wx.PostEvent(self.parent, StatusEvent(status=exc)) 932 936 933 937 def estimate_plot_inversion(self, alpha, nfunc, d_max, … … 952 956 self.pr = pr 953 957 self.perform_estimate() 954 except :955 wx.PostEvent(self.parent, StatusEvent(status= sys.exc_value))958 except Exception as exc: 959 wx.PostEvent(self.parent, StatusEvent(status=exc)) 956 960 957 961 def _create_plot_pr(self, estimate=False): … … 1033 1037 self.pr = pr 1034 1038 self.perform_inversion() 1035 except :1036 wx.PostEvent(self.parent, StatusEvent(status= sys.exc_value))1039 except Exception as exc: 1040 wx.PostEvent(self.parent, StatusEvent(status=exc)) 1037 1041 1038 1042 def estimate_file_inversion(self, alpha, nfunc, d_max, data, … … 1056 1060 self.pr = pr 1057 1061 self.perform_estimate() 1058 except :1059 wx.PostEvent(self.parent, StatusEvent(status= sys.exc_value))1062 except Exception as exc: 1063 wx.PostEvent(self.parent, StatusEvent(status=exc)) 1060 1064 1061 1065 def _create_file_pr(self, data): … … 1085 1089 self._current_file_data.err = data.dy 1086 1090 x, y, err = data.x, data.y, data.dy 1087 except :1088 load_error( sys.exc_value)1091 except Exception as exc: 1092 load_error(exc) 1089 1093 return None 1090 1094 … … 1124 1128 pr.slit_width = self.slit_width 1125 1129 return pr 1126 except :1127 load_error( sys.exc_value)1130 except Exception as exc: 1131 load_error(exc) 1128 1132 return None 1129 1133 … … 1132 1136 Perform parameter estimation 1133 1137 """ 1134 from pr_thread import EstimatePr1135 1136 1138 # If a thread is already started, stop it 1137 1139 if self.estimation_thread is not None and \ … … 1162 1164 Perform parameter estimation 1163 1165 """ 1164 from pr_thread import EstimateNT1165 1166 1166 # If a thread is already started, stop it 1167 1167 if self.estimation_thread is not None and self.estimation_thread.isrunning(): … … 1239 1239 Create and return a list of panel objects 1240 1240 """ 1241 from inversion_panel import InversionControl1242 1243 1241 self.parent = parent 1244 1242 self.frame = MDIFrame(self.parent, None, 'None', (100, 200)) … … 1262 1260 if data_list is None: 1263 1261 data_list = [] 1262 else: 1263 data_list = list(data_list) # force iterator to list 1264 1264 if len(data_list) >= 1: 1265 1265 if len(data_list) == 1: … … 1287 1287 msg += "Please select one.\n" 1288 1288 if len(data_list) > 1: 1289 from pr_widgets import DataDialog1290 1289 dlg = DataDialog(data_list=data_1d_list, text=msg) 1291 1290 if dlg.ShowModal() == wx.ID_OK: … … 1306 1305 self.data_id = data.id 1307 1306 self.control_panel._change_file(evt=None, data=data) 1308 except :1309 msg = "Prview Set_data: " + str( sys.exc_value)1307 except Exception as exc: 1308 msg = "Prview Set_data: " + str(exc) 1310 1309 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 1311 1310 else:
Note: See TracChangeset
for help on using the changeset viewer.