Changeset 2661d8b in sasview


Ignore:
Timestamp:
Mar 5, 2010 10:06:23 PM (14 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:
c75a8ed
Parents:
2e94cbde
Message:

invariantview: fixed bad logic, broken calls to computational modules, broken logic for plot updates, badly written code, confusing tooltips, confusing error messages, inaccurate labels, and I'm not even done yet!

Location:
invariantview/perspectives/invariant
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • invariantview/perspectives/invariant/invariant.py

    r53b6b74 r2661d8b  
    189189                else: 
    190190                    data = plottable 
    191                 #set the data for the panel 
     191                # Store reference to data 
     192                self.__data = data 
     193                # Set the data set to be user for invariant calculation 
    192194                self.invariant_panel.set_data(data=data) 
    193                 
    194                 
    195     def _plot_data(self, reel_data, extra_data, name="Unknown"): 
    196         """ 
    197             Receive a data and post a NewPlotEvent to parent 
    198             @param data: data created frome xtrapolation to plot 
     195         
     196    def plot_theory(self, data=None, name=None): 
     197        """ 
     198            Receive a data set and post a NewPlotEvent to parent. 
     199            @param data: extrapolated data to be plotted 
    199200            @param name: Data's name to use for the legend 
    200201        """ 
    201         if self.graph is None: 
    202             return 
    203         #print "went here " 
    204         plottable = self.graph.get_plottable(name=name) 
    205         if plottable is not None: 
    206             self.graph.delete(plottable) 
    207         # Create a plottable data 
    208         new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
    209         self._plot_helper(new_plot=new_plot, 
    210                           reel_data=reel_data,  
    211                           extra_data=extra_data, name=name) 
    212          
    213     def _plot_theory(self, reel_data, extra_data, name="Unknown"): 
    214         """ 
    215             Receive a data and post a NewPlotEvent to parent 
    216             @param data: data created frome xtrapolation to plot 
    217             @param name: Data's name to use for the legend 
    218         """ 
    219         if self.graph is None: 
    220             return 
    221         plottable = self.graph.get_plottable(name=name) 
    222         if plottable is not None: 
    223             self.graph.delete(plottable) 
    224         # Create a plottable data 
    225         new_plot = Theory1D(x=[], y=[], dy=None) 
    226         self._plot_helper(new_plot=new_plot, 
    227                           reel_data=reel_data, 
    228                            extra_data=extra_data, name=name) 
    229          
    230     def _plot_helper(self, new_plot, reel_data, extra_data, name): 
    231         """ 
    232             Put value of extra_data (created data) into a new plottable 
    233             (new_plot) and assign value of a plotpael of the reel data to  
    234             the new plottable so that the new plottable is plot on the sama panel  
    235             of the data used for invariant. 
    236         """ 
    237          
    238         new_plot.copy_from_datainfo(extra_data)  
    239         extra_data.clone_without_data(clone=new_plot)  
    240              
     202        if data is None: 
     203            new_plot = Theory1D(x=[], y=[], dy=None) 
     204        else: 
     205            new_plot = Theory1D(x=data.x, y=data.y, dy=None) 
    241206        new_plot.name = name 
    242         title = reel_data.name 
    243         new_plot.xaxis(reel_data._xaxis, reel_data._xunit) 
    244         new_plot.yaxis(reel_data._yaxis, reel_data._yunit) 
    245         new_plot.group_id = reel_data.group_id 
    246         new_plot.id = reel_data.id + name 
    247         ##post data to plot 
    248         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
    249          
     207        new_plot.xaxis(self.__data._xaxis, self.__data._xunit) 
     208        new_plot.yaxis(self.__data._yaxis, self.__data._yunit) 
     209        new_plot.group_id = self.__data.group_id 
     210        new_plot.id = self.__data.id + name 
     211        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=self.__data.name)) 
     212 
     213 
     214         
  • invariantview/perspectives/invariant/invariant_panel.py

    r53b6b74 r2661d8b  
    150150                self.invariant_err_ctl.SetValue(format_number(qstar)) 
    151151            except: 
    152                 msg= "Error occurs for invariant: %s"%sys.exc_value 
     152                msg= "Error occurred computing invariant: %s"%sys.exc_value 
    153153                wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
    154154                return 
     
    159159                    qstar_low, qstar_low_err = inv.get_qstar_low() 
    160160                    self.invariant_low_ctl.SetValue(format_number(qstar_low)) 
    161                     #plot data 
    162                     low_out_data, low_in_data = inv.get_extra_data_low() 
    163                     self._manager._plot_theory(reel_data=self._data, 
    164                                                extra_data=low_out_data, 
    165                                      name=self._data.name+" Extra_low_Q") 
    166                     self._manager._plot_data(reel_data=self._data, 
    167                                              extra_data=low_in_data,  
    168                                 name=self._data.name+"Fitted data for low_Q") 
     161                    extrapolated_data = inv.get_extra_data_low(npts_in=npts_low)    
     162                    self._manager.plot_theory(data=extrapolated_data, 
     163                                               name="Low-Q extrapolation") 
    169164                except: 
    170                     msg= "Error occurs for low q invariant: %s"%sys.exc_value 
     165                    msg= "Error occurred computing low-Q invariant: %s"%sys.exc_value 
    171166                    wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
     167            else: 
     168                self._manager.plot_theory(name="Low-Q extrapolation") 
     169                 
    172170            if high_q: 
    173171                try:  
    174172                    qstar_high, qstar_high_err = inv.get_qstar_high() 
    175173                    self.invariant_high_ctl.SetValue(format_number(qstar_high)) 
    176                     #plot data 
    177                     high_out_data, high_in_data = inv.get_extra_data_high(q_end=Q_MAXIMUM_PLOT) 
    178                     self._manager._plot_theory(reel_data=self._data, 
    179                                                extra_data=high_out_data, 
    180                                      name=self._data.name+" Extra_high_Q") 
    181                     self._manager._plot_data(reel_data=self._data, 
    182                                              extra_data=high_in_data, 
    183                                  name=self._data.name+"Fitted data for high_Q") 
     174                    high_out_data = inv.get_extra_data_high(q_end=Q_MAXIMUM_PLOT) 
     175                    self._manager.plot_theory(data=high_out_data, 
     176                                               name="High-Q extrapolation") 
    184177                except: 
    185                     msg= "Error occurs for high q invariant: %s"%sys.exc_value 
     178                    msg= "Error occurred computing high-Q invariant: %s"%sys.exc_value 
    186179                    wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
     180            else: 
     181                self._manager.plot_theory(name="High-Q extrapolation") 
     182                 
    187183            try: 
    188184                qstar_total, qstar_total_err = inv.get_qstar_with_error(extrapolation) 
     
    192188                check_float(self.invariant_total_err_ctl) 
    193189            except: 
    194                 msg= "Error occurs for total invariant: %s"%sys.exc_value 
     190                msg= "Error occurred computing invariant using extrapolation: %s"%sys.exc_value 
    195191                wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop"))   
    196192             
     
    212208                    self.volume_err_ctl.SetValue(format_number(dv)) 
    213209                except: 
    214                     msg= "Error occurs for volume fraction: %s"%sys.exc_value 
     210                    msg= "Error occurred computing volume fraction: %s"%sys.exc_value 
    215211                    wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
    216212 
     
    222218                    self.surface_err_ctl.SetValue(format_number(ds)) 
    223219                except: 
    224                     msg= "Error occurs for surface: %s"%sys.exc_value 
     220                    msg= "Error occurred computing specific surface: %s"%sys.exc_value 
    225221                    wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
    226222                         
    227223        else: 
    228             msg= "invariant: Need float for background and scale" 
     224            msg= "A float value is required for background and scale" 
    229225            wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 
    230226            return 
     
    291287        self.data_range_value_txt = wx.StaticText(self, -1, str(data_range)) 
    292288         
    293         background_txt = wx.StaticText(self, -1, 'Background (Optional)') 
     289        background_txt = wx.StaticText(self, -1, 'Background') 
    294290        self.background_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    295291        self.background_ctl.SetValue(str(BACKGROUND)) 
    296         self.background_ctl.SetToolTipString("Background to subtract to data.") 
    297         scale_txt = wx.StaticText(self, -1, 'Scale (Optional)') 
     292        self.background_ctl.SetToolTipString("Background to be subtracted from data.") 
     293        scale_txt = wx.StaticText(self, -1, 'Scale') 
    298294        self.scale_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    299295        self.scale_ctl.SetValue(str(SCALE)) 
    300         self.scale_ctl.SetToolTipString("Scale to apply to data.") 
     296        self.scale_ctl.SetToolTipString("Scaling factor to be applied to data.") 
    301297        contrast_txt = wx.StaticText(self, -1, 'Contrast (Optional)') 
    302298        self.contrast_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    303         msg_hint = "Enter a value for the contrast to get the volume fraction" 
     299        msg_hint = "Enter a value for the contrast to compute the volume fraction" 
    304300        self.contrast_ctl.SetToolTipString(str(msg_hint)) 
    305         porod_const_txt = wx.StaticText(self, -1, 'Porod Constant(Optional)') 
     301        porod_const_txt = wx.StaticText(self, -1, 'Porod Constant (Optional)') 
    306302        self.porod_const_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    307         msg_hint ="Need both the contrast and surface to get the surface" 
     303        msg_hint ="Enter a Porod constant value to compute the specific surface" 
    308304        self.porod_const_ctl.SetToolTipString(str(msg_hint)) 
    309305        
     
    329325        sizer_low_q = wx.GridBagSizer(5,5) 
    330326         
    331         self.enable_low_cbox = wx.CheckBox(self, -1, "Enable low Q") 
     327        self.enable_low_cbox = wx.CheckBox(self, -1, "Extrapolate low-Q") 
    332328        self.enable_low_cbox.SetValue(False) 
    333         self.enable_high_cbox = wx.CheckBox(self, -1, "Enable High Q") 
     329        self.enable_high_cbox = wx.CheckBox(self, -1, "Extrapolate high-Q") 
    334330        self.enable_high_cbox.SetValue(False) 
    335331         
    336332        self.guinier = wx.RadioButton(self, -1, 'Guinier', 
    337333                                         (10, 10),style=wx.RB_GROUP) 
    338         self.power_law_low = wx.RadioButton(self, -1, 'Power_law', (10, 10)) 
     334        self.power_law_low = wx.RadioButton(self, -1, 'Power Law', (10, 10)) 
    339335        self.guinier.SetValue(True) 
    340336         
     
    342338        self.npts_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 
    343339        self.npts_low_ctl.SetValue(str(NPTS)) 
    344         msg_hint = "the number of first q points to consider" 
    345         msg_hint +="during the fit for extrapolation at low Q" 
     340        msg_hint = "Number of Q points to consider" 
     341        msg_hint +="while extrapolating the low-Q region" 
    346342        self.npts_low_ctl.SetToolTipString(msg_hint) 
     343        npts_exp_txt = wx.StaticText(self, -1, 'Power') 
    347344        self.power_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 
    348345        self.power_low_ctl.SetValue(str(self.power_law_exponant)) 
     
    350347        iy = 0 
    351348        ix = 0 
    352         sizer_low_q.Add(self.guinier,(iy, ix),(1,1), 
     349        sizer_low_q.Add(self.guinier,(iy, ix),(1,2), 
    353350                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    354351        iy += 1 
    355352        ix = 0 
    356         sizer_low_q.Add(self.power_law_low,(iy, ix),(1,1), 
    357                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     353         
     354        sizer_low_q.Add(self.power_law_low,(iy, ix),(1,2), 
     355                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     356         
     357        # Parameter controls for power law 
     358        ix = 1 
     359        iy += 1 
     360        sizer_low_q.Add(npts_exp_txt,(iy, ix),(1,1), 
     361                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     362         
    358363        ix += 1 
    359364        sizer_low_q.Add(self.power_low_ctl, (iy, ix), (1,1), 
    360365                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    361366        iy += 1 
    362         ix = 0 
     367        ix = 1 
    363368        sizer_low_q.Add(npts_low_txt,(iy, ix),(1,1), 
    364369                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    368373        iy += 1 
    369374        ix = 0 
    370         sizer_low_q.Add(self.enable_low_cbox,(iy, ix),(1,1), 
     375        sizer_low_q.Add(self.enable_low_cbox,(iy, ix),(1,5), 
    371376                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    372377        sizer_high_q = wx.GridBagSizer(5,5) 
    373         self.power_law_high = wx.RadioButton(self, -1, 'Power_law', 
     378        self.power_law_high = wx.RadioButton(self, -1, 'Power Law', 
    374379                                              (10, 10), style=wx.RB_GROUP) 
    375         msg_hint ="Check it to extrapolate data to high Q" 
     380        msg_hint ="Check to extrapolate data at high-Q" 
    376381        self.power_law_high.SetToolTipString(msg_hint) 
    377382        
     
    379384        self.power_law_high.SetValue(True) 
    380385        npts_high_txt = wx.StaticText(self, -1, 'Npts') 
     386        npts_high_exp_txt = wx.StaticText(self, -1, 'Power') 
    381387        self.npts_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 
    382         msg_hint = "the number of last q points to consider" 
    383         msg_hint += "during the fit for extrapolation high Q" 
     388        msg_hint = "Number of Q points to consider" 
     389        msg_hint += "while extrapolating the high-Q region" 
    384390        self.npts_high_ctl.SetToolTipString(msg_hint) 
    385391        self.npts_high_ctl.SetValue(str(NPTS)) 
     
    390396        iy = 1 
    391397        ix = 0 
    392         sizer_high_q.Add(self.power_law_high,(iy, ix),(1,1), 
    393                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     398        sizer_high_q.Add(self.power_law_high,(iy, ix),(1,2), 
     399                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     400        ix = 1 
     401        iy += 1 
     402        sizer_high_q.Add(npts_high_exp_txt,(iy, ix),(1,1), 
     403                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     404         
    394405        ix += 1 
    395406        sizer_high_q.Add(self.power_high_ctl, (iy, ix), (1,1), 
    396407                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    397408        iy += 1 
    398         ix = 0 
     409        ix = 1 
    399410        sizer_high_q.Add(npts_high_txt,(iy, ix),(1,1), 
    400411                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    404415        iy += 1 
    405416        ix = 0 
    406         sizer_high_q.Add(self.enable_high_cbox,(iy, ix),(1,1), 
     417        sizer_high_q.Add(self.enable_high_cbox,(iy, ix),(1,5), 
    407418                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    408419               
     
    452463        self.invariant_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    453464        self.invariant_ctl.SetEditable(False) 
    454         self.invariant_ctl.SetToolTipString("Invariant in q range.") 
     465        self.invariant_ctl.SetToolTipString("Invariant in the data set's Q range.") 
    455466        self.invariant_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    456467        self.invariant_err_ctl.SetEditable(False) 
    457         self.invariant_err_ctl.SetToolTipString("Uncertainty on invariant.") 
     468        self.invariant_err_ctl.SetToolTipString("Uncertainty on the invariant.") 
    458469        invariant_units_txt = wx.StaticText(self, -1, unit_invariant) 
    459470         
     
    461472        self.invariant_total_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    462473        self.invariant_total_ctl.SetEditable(False) 
    463         msg_hint = "Invariant in q range and extra polated range." 
     474        msg_hint = "Total invariant, including extrapolated regions." 
    464475        self.invariant_total_ctl.SetToolTipString(msg_hint) 
    465476        self.invariant_total_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     
    471482        self.volume_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    472483        self.volume_ctl.SetEditable(False) 
    473         self.volume_ctl.SetToolTipString("volume fraction.") 
     484        self.volume_ctl.SetToolTipString("Volume fraction.") 
    474485        self.volume_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    475486        self.volume_err_ctl.SetEditable(False) 
    476         self.volume_err_ctl.SetToolTipString("Uncertainty of volume fraction.") 
     487        self.volume_err_ctl.SetToolTipString("Uncertainty on the volume fraction.") 
    477488        volume_units_txt = wx.StaticText(self, -1, unit_volume) 
    478489         
    479         surface_txt = wx.StaticText(self, -1, 'Surface') 
     490        surface_txt = wx.StaticText(self, -1, 'Specific surface') 
    480491        self.surface_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    481492        self.surface_ctl.SetEditable(False) 
    482         self.surface_ctl.SetToolTipString("Surface.") 
     493        self.surface_ctl.SetToolTipString("Specific surface value.") 
    483494        self.surface_err_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    484495        self.surface_err_ctl.SetEditable(False) 
    485         self.surface_err_ctl.SetToolTipString("Uncertainty of surface.") 
     496        self.surface_err_ctl.SetToolTipString("Uncertainty on the specific surface.") 
    486497        surface_units_txt = wx.StaticText(self, -1, unit_surface) 
    487498         
    488         invariant_low_txt = wx.StaticText(self, -1, 'Invariant in low Q') 
     499        invariant_low_txt = wx.StaticText(self, -1, 'Invariant in low-Q region') 
    489500        self.invariant_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    490501        self.invariant_low_ctl.SetEditable(False) 
    491         self.invariant_low_ctl.SetToolTipString("Invariant compute in low Q") 
     502        self.invariant_low_ctl.SetToolTipString("Invariant computed with the extrapolated low-Q data.") 
    492503        invariant_low_units_txt = wx.StaticText(self, -1,  unit_invariant) 
    493504         
    494         invariant_high_txt = wx.StaticText(self, -1, 'Invariant in high Q') 
     505        invariant_high_txt = wx.StaticText(self, -1, 'Invariant in high-Q region') 
    495506        self.invariant_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    496507        self.invariant_high_ctl.SetEditable(False) 
    497         self.invariant_high_ctl.SetToolTipString("Invariant compute in high Q") 
     508        self.invariant_high_ctl.SetToolTipString("Invariant computed with the extrapolated high-Q data") 
    498509        invariant_high_units_txt = wx.StaticText(self, -1,  unit_invariant) 
    499510        
     
    591602        id = wx.NewId() 
    592603        button_calculate = wx.Button(self, id, "Compute") 
    593         button_calculate.SetToolTipString("Compute SlD of neutrons.") 
     604        button_calculate.SetToolTipString("Compute invariant") 
    594605        self.Bind(wx.EVT_BUTTON, self.compute_invariant, id = id)    
    595606         
Note: See TracChangeset for help on using the changeset viewer.