- Timestamp:
- Jun 12, 2009 12:05:57 PM (16 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:
- 3595309d
- Parents:
- 3fe701a
- Location:
- prview/perspectives/pr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/inversion_panel.py
r302510b r0d88a09 205 205 self.nterms_estimate_ctl.SetLabel("%-g" % value) 206 206 elif name=='plotname': 207 if self.standalone==False: 208 self.plot_data.SetValue(str(value)) 209 self._on_pars_changed(None) 207 self.plot_data.SetValue(str(value)) 208 self._on_pars_changed(None) 210 209 elif name=='datafile': 211 if self.standalone==True: 212 self.data_file.SetValue(str(value)) 213 self._on_pars_changed(None) 210 self.plot_data.SetValue(str(value)) 211 self._on_pars_changed(None) 214 212 else: 215 213 wx.Panel.__setattr__(self, name, value) … … 305 303 return None 306 304 elif name=='plotname': 307 if self.standalone==False: 308 return self.plot_data.GetValue() 309 else: 310 return None 305 return self.plot_data.GetValue() 311 306 elif name=='datafile': 312 if self.standalone==True: 313 return self.data_file.GetValue() 314 else: 315 return None 307 return self.plot_data.GetValue() 316 308 else: 317 309 wx.Panel.__getattr__(self, name) … … 329 321 path = dlg.GetPath() 330 322 self._default_save_location = os.path.dirname(path) 323 else: 324 return None 325 331 326 dlg.Destroy() 332 327 … … 347 342 348 343 # Data file 349 if self.manager.standalone==True: 350 state.file = self.data_file.GetValue() 351 else: 352 state.file = self.plot_data.GetValue() 344 state.file = self.plot_data.GetValue() 353 345 354 346 # Background evaluation checkbox … … 369 361 state.bck = self.bck 370 362 371 if self.manager.standalone==True: 372 state.toXML(path) 373 else: 374 self.manager.save_data(filepath=path, prstate=state) 363 self.manager.save_data(filepath=path, prstate=state) 375 364 376 365 return state … … 401 390 402 391 # Data file 403 if self.standalone==True: 404 self.data_file.SetValue(str(state.file)) 405 else: 406 self.plot_data.SetValue(str(state.file)) 392 self.plot_data.SetValue(str(state.file)) 407 393 408 394 # Background evaluation checkbox … … 434 420 self.bck = state.bck 435 421 436 # Check whether the file is accessible, if so, 437 # load it a recompute P(r) using the new parameters 438 if self.standalone==True: 439 if os.path.isfile(state.file): 440 self._change_file(filepath=state.file) 441 self._on_invert(None) 442 else: 443 message = "Could not find [%s] on the file system." % state.file 444 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 445 else: 422 # Perform inversion 423 if self.standalone == False: 446 424 self._on_invert(None) 447 425 448 426 def set_manager(self, manager): 449 427 self.manager = manager 450 # Get data451 452 # Push data to form453 454 428 455 429 def _do_layout(self): … … 468 442 pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 469 443 470 if self.standalone==True: 471 self.data_file = wx.TextCtrl(self, -1, size=(220,20)) 472 self.data_file.SetEditable(False) 473 self.data_file.SetValue("") 474 pars_sizer.Add(self.data_file, (iy,1), (1,1), wx.ADJUST_MINSIZE, 15) 475 else: 476 self.plot_data = wx.TextCtrl(self, -1, size=(220,20)) 477 self.plot_data.SetEditable(False) 478 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15) 444 self.plot_data = wx.TextCtrl(self, -1, size=(220,20)) 445 self.plot_data.SetEditable(False) 446 pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15) 479 447 480 448 self.bck_chk = wx.CheckBox(self, -1, "Estimate background level") … … 814 782 self.alpha_estimate_ctl.Enable(False) 815 783 816 if self.standalone==False: 817 dataset = self.plot_data.GetValue() 818 self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, 819 d_max=dmax, 820 q_min=qmin, q_max=qmax, 821 bck=has_bck, 822 height=height, 823 width=width) 824 else: 825 path = self.data_file.GetValue() 826 self.manager.estimate_file_inversion(alpha=alpha, nfunc=nfunc, 827 d_max=dmax, path=path, 828 q_min=qmin, q_max=qmax, 829 bck=has_bck, 830 height=height, 831 width=width) 832 784 dataset = self.plot_data.GetValue() 785 self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, 786 d_max=dmax, 787 q_min=qmin, q_max=qmax, 788 bck=has_bck, 789 height=height, 790 width=width) 833 791 834 792 def _read_pars(self, evt=None): … … 949 907 950 908 if flag: 951 if self.standalone==False: 952 dataset = self.plot_data.GetValue() 953 if len(dataset.strip())==0: 954 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 955 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 956 else: 957 self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 958 d_max=dmax, 959 q_min=qmin, q_max=qmax, 960 bck=has_bck, 961 height=height, 962 width=width) 909 dataset = self.plot_data.GetValue() 910 if len(dataset.strip())==0: 911 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 912 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 963 913 else: 964 path = self.data_file.GetValue() 965 if len(path.strip())==0: 966 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 967 wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 968 else: 969 self.manager.setup_file_inversion(alpha=alpha, nfunc=nfunc, 970 d_max=dmax, path=path, 971 q_min=qmin, q_max=qmax, 972 bck=has_bck, 973 height=height, 974 width=width) 975 914 self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 915 d_max=dmax, 916 q_min=qmin, q_max=qmax, 917 bck=has_bck, 918 height=height, 919 width=width) 976 920 else: 977 921 message = "The P(r) form contains invalid values: please submit it again." … … 987 931 988 932 if path and os.path.isfile(path): 989 self. data_file.SetValue(str(path))933 self.plot_data.SetValue(str(path)) 990 934 self.manager.show_data(path, reset=True) 991 935 self._on_pars_changed(None) 936 937 # Perform inversion 938 if self.standalone == True: 939 self._on_invert(None) 992 940 993 941 class HelpDialog(wx.Dialog): -
prview/perspectives/pr/inversion_state.py
r302510b r0d88a09 339 339 ext=['.prv', '.PRV'] 340 340 341 def __init__(self, call_back, cansas= False):341 def __init__(self, call_back, cansas=True): 342 342 """ 343 343 Initialize the call-back method to be called … … 345 345 @param call_back: call-back method 346 346 @param cansas: True = files will be written/read in CanSAS format 347 False = standalone mode347 False = write CanSAS format 348 348 349 349 """ -
prview/perspectives/pr/pr.py
r302510b r0d88a09 7 7 import logging 8 8 import time 9 from danse.common.plottools import Data1D, Theory1D 9 from sans.guiframe.dataFitting import Data1D 10 from danse.common.plottools import Theory1D 10 11 from sans.guicomm.events import NewPlotEvent, StatusEvent 11 12 import math, numpy 12 13 from sans.pr.invertor import Invertor 13 14 from DataLoader.loader import Loader 15 16 import copy 14 17 15 18 PR_FIT_LABEL = r"$P_{fit}(r)$" … … 89 92 from inversion_state import Reader 90 93 91 # TODO: get rid of the cansas flag92 self.state_reader = Reader(self.set_state , cansas = not self.standalone)94 # Create a CanSAS/Pr reader 95 self.state_reader = Reader(self.set_state) 93 96 l = Loader() 94 97 l.associate_file_reader('.prv', self.state_reader) … … 106 109 """ 107 110 try: 108 # If we are not in standalone mode, the panel will not 109 # load any data file and we need to keep track of the 110 # data here. 111 if self.standalone == False: 112 if datainfo is None: 113 raise RuntimeError, "Pr.set_state: datainfo parameter cannot be None in standalone mode" 114 115 # Ensuring that plots are coordinated correctly 116 t = time.localtime(datainfo.meta_data['prstate'].timestamp) 117 time_str = time.strftime("%b %d %H:%M", t) 118 datainfo.meta_data['prstate'].file = datainfo.meta_data['prstate'].file +' [' + time_str + ']' 119 datainfo.filename = datainfo.meta_data['prstate'].file 120 121 self.current_plottable = datainfo 122 self.current_plottable.group_id = datainfo.meta_data['prstate'].file 123 111 if datainfo is None: 112 raise RuntimeError, "Pr.set_state: datainfo parameter cannot be None in standalone mode" 113 114 # Ensuring that plots are coordinated correctly 115 t = time.localtime(datainfo.meta_data['prstate'].timestamp) 116 time_str = time.strftime("%b %d %H:%M", t) 117 118 # Check that no time stamp is already appended 119 max_char = datainfo.meta_data['prstate'].file.find("[") 120 if max_char < 0: 121 max_char = len(datainfo.meta_data['prstate'].file) 122 123 datainfo.meta_data['prstate'].file = datainfo.meta_data['prstate'].file[0:max_char] +' [' + time_str + ']' 124 datainfo.filename = datainfo.meta_data['prstate'].file 125 126 self.current_plottable = datainfo 127 self.current_plottable.group_id = datainfo.meta_data['prstate'].file 128 124 129 # Load the P(r) results 125 130 self.control_panel.set_state(state) … … 849 854 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="I(q)", reset=reset)) 850 855 856 self.current_plottable = new_plot 857 self.current_plottable.group_id = IQ_DATA_LABEL 858 859 851 860 # Get Q range 852 861 self.control_panel.q_min = self.pr.x.min()
Note: See TracChangeset
for help on using the changeset viewer.