Changeset 0d88a09 in sasview for prview/perspectives/pr


Ignore:
Timestamp:
Jun 12, 2009 2:05:57 PM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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
Message:

prview: streamline standalone vs plugin version.

Location:
prview/perspectives/pr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • prview/perspectives/pr/inversion_panel.py

    r302510b r0d88a09  
    205205            self.nterms_estimate_ctl.SetLabel("%-g" % value) 
    206206        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) 
    210209        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) 
    214212        else: 
    215213            wx.Panel.__setattr__(self, name, value) 
     
    305303                return None 
    306304        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() 
    311306        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() 
    316308        else: 
    317309            wx.Panel.__getattr__(self, name) 
     
    329321            path = dlg.GetPath() 
    330322            self._default_save_location = os.path.dirname(path) 
     323        else: 
     324            return None 
     325         
    331326        dlg.Destroy() 
    332327                 
     
    347342         
    348343        # 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() 
    353345         
    354346        # Background evaluation checkbox 
     
    369361        state.bck     = self.bck 
    370362             
    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) 
    375364         
    376365        return state 
     
    401390         
    402391        # 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)) 
    407393     
    408394        # Background evaluation checkbox 
     
    434420            self.bck     = state.bck 
    435421 
    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: 
    446424            self._on_invert(None)     
    447425         
    448426    def set_manager(self, manager): 
    449427        self.manager = manager 
    450         # Get data 
    451          
    452         # Push data to form 
    453          
    454428         
    455429    def _do_layout(self): 
     
    468442        pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    469443         
    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) 
    479447         
    480448        self.bck_chk = wx.CheckBox(self, -1, "Estimate background level") 
     
    814782            self.alpha_estimate_ctl.Enable(False) 
    815783             
    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) 
    833791         
    834792    def _read_pars(self, evt=None):     
     
    949907         
    950908        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)) 
    963913            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) 
    976920        else: 
    977921            message = "The P(r) form contains invalid values: please submit it again." 
     
    987931             
    988932            if path and os.path.isfile(path): 
    989                 self.data_file.SetValue(str(path)) 
     933                self.plot_data.SetValue(str(path)) 
    990934                self.manager.show_data(path, reset=True) 
    991935                self._on_pars_changed(None) 
     936             
     937                # Perform inversion 
     938                if self.standalone == True: 
     939                    self._on_invert(None) 
    992940 
    993941class HelpDialog(wx.Dialog): 
  • prview/perspectives/pr/inversion_state.py

    r302510b r0d88a09  
    339339    ext=['.prv', '.PRV']   
    340340     
    341     def __init__(self, call_back, cansas=False): 
     341    def __init__(self, call_back, cansas=True): 
    342342        """ 
    343343            Initialize the call-back method to be called 
     
    345345            @param call_back: call-back method 
    346346            @param cansas:  True = files will be written/read in CanSAS format 
    347                             False = standalone mode 
     347                            False = write CanSAS format 
    348348             
    349349        """ 
  • prview/perspectives/pr/pr.py

    r302510b r0d88a09  
    77import logging 
    88import time 
    9 from danse.common.plottools import Data1D, Theory1D 
     9from sans.guiframe.dataFitting import Data1D 
     10from danse.common.plottools import Theory1D 
    1011from sans.guicomm.events import NewPlotEvent, StatusEvent     
    1112import math, numpy 
    1213from sans.pr.invertor import Invertor 
    1314from DataLoader.loader import Loader 
     15 
     16import copy 
    1417 
    1518PR_FIT_LABEL       = r"$P_{fit}(r)$" 
     
    8992        from inversion_state import Reader 
    9093          
    91         #TODO: get rid of the cansas flag  
    92         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) 
    9396        l = Loader() 
    9497        l.associate_file_reader('.prv', self.state_reader) 
     
    106109        """ 
    107110        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             
    124129            # Load the P(r) results 
    125130            self.control_panel.set_state(state) 
     
    849854        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="I(q)", reset=reset)) 
    850855         
     856        self.current_plottable = new_plot 
     857        self.current_plottable.group_id = IQ_DATA_LABEL 
     858         
     859         
    851860        # Get Q range 
    852861        self.control_panel.q_min = self.pr.x.min() 
Note: See TracChangeset for help on using the changeset viewer.