Ignore:
Timestamp:
Apr 7, 2010 6:36:10 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
199cef2
Parents:
3fab6ef
Message:

add more hint on invariant panel

Location:
invariantview/perspectives/invariant
Files:
2 edited

Legend:

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

    r3fab6ef reed601e  
    3737    def __init__(self): 
    3838        #invariant at low range 
    39         self.qstar_low = 0.0 
     39        self.qstar_low = None 
    4040        #invariant at low range error 
    41         self.qstar_low_err = 0.0 
     41        self.qstar_low_err = None 
    4242        #invariant  
    43         self.qstar = 0.0 
     43        self.qstar = None 
    4444        #invariant error 
    45         self.qstar_err = 0.0 
     45        self.qstar_err = None 
    4646        #invariant at high range 
    47         self.qstar_high = 0.0 
     47        self.qstar_high = None 
    4848        #invariant at high range error 
    49         self.qstar_high_err = 0.0 
     49        self.qstar_high_err = None 
    5050        #invariant total 
    5151        self.qstar_total = None 
     
    5353        self.qstar_total_err = None 
    5454        #scale 
    55         self.qstar_low_percent = 0.0 
    56         self.qstar_high_percent = 0.0 
    57         self.qstar_percent = 0.0 
     55        self.qstar_low_percent = None 
     56        self.qstar_high_percent = None 
     57        self.qstar_percent = None 
    5858        # warning message 
    5959        self.existing_warning = False 
     
    6464            Compute percentage of each invariant 
    6565        """ 
    66         if self.qstar_total is not None and self.qstar_total != 0: 
    67             #compute invariant percentage 
    68             if self.qstar is None: 
    69                 self.qstar = 0.0 
    70             self.qstar_percent = self.qstar/self.qstar_total 
    71             #compute low q invariant percentage 
    72             if self.qstar_low is None: 
    73                 self.qstar_low = 0.0 
    74             self.qstar_low_percent = self.qstar_low/self.qstar_total 
    75             #compute high q invariant percentage 
    76             if self.qstar_high is None: 
    77                 self.qstar_high = 0.0 
    78             self.qstar_high_percent = self.qstar_high/self.qstar_total 
     66        if self.qstar_total is None: 
     67            self.qstar_percent = None 
     68            self.qstar_low = None 
     69            self.qstar_high = None 
     70            self.check_values() 
     71            return  
     72         
     73        #compute invariant percentage 
     74        if self.qstar is None: 
     75            self.qstar_percent = None 
     76        else: 
     77            try: 
     78                self.qstar_percent = float(self.qstar)/float(self.qstar_total) 
     79            except: 
     80                self.qstar_percent = 'error' 
     81        #compute low q invariant percentage 
     82        if self.qstar_low is None: 
     83            self.qstar_low_percent = None 
     84        else: 
     85            try: 
     86                self.qstar_low_percent = float(self.qstar_low)/float(self.qstar_total) 
     87            except: 
     88                self.qstar_low_percent = 'error' 
     89        #compute high q invariant percentage 
     90        if self.qstar_high is None: 
     91            self.qstar_high_percent = None 
     92        else: 
     93            try: 
     94                self.qstar_high_percent = float(self.qstar_high)/float(self.qstar_total) 
     95            except: 
     96                self.qstar_high_percent = 'error' 
    7997        self.check_values() 
    8098    
     
    83101            check the validity if invariant 
    84102        """ 
     103        if self.qstar_total is None and self.qstar is None: 
     104            self.warning_msg = "Invariant not calculated.\n" 
     105            return  
     106        if self.qstar_total == 0: 
     107             self.existing_warning = True 
     108             self.warning_msg = "Invariant is zero. \n" 
     109             self.warning_msg += "The calculations are likely to be unreliable!\n" 
     110             return  
    85111        #warning to the user when the extrapolated invariant is greater than %5 
    86112        msg = '' 
    87         if self.qstar_low_percent >= 0.05: 
     113        if self.qstar_percent == 'error': 
     114            self.existing_warning = True 
     115            msg = 'Error occurred when computing invariant from data.\n ' 
     116       
     117        if self.qstar_low_percent == 'error': 
     118            self.existing_warning = True 
     119            msg = 'Error occurred when computing extrapolated invariant at low-Q region.\n' 
     120        elif self.qstar_low_percent is not None and self.qstar_low_percent >= 0.05: 
    88121            self.existing_warning = True 
    89122            msg += "Extrapolated contribution at Low Q is higher " 
    90123            msg += "than 5% of the invariant.\n" 
    91         if self.qstar_high_percent >= 0.05: 
     124        if self.qstar_high_percent == 'error': 
     125            self.existing_warning = True 
     126            msg += 'Error occurred when computing extrapolated invariant at high-Q region.\n' 
     127        elif self.qstar_high_percent is not None and self.qstar_high_percent >= 0.05: 
    92128            self.existing_warning = True 
    93129            msg += "Extrapolated contribution at High Q is higher " 
    94130            msg += "than 5% of the invariant.\n" 
    95         if self.qstar_low_percent + self.qstar_high_percent >= 0.05: 
     131        if (self.qstar_low_percent not in [None, "error"]) and \ 
     132            (self.qstar_high_percent not in [None, "error"])\ 
     133            and self.qstar_low_percent + self.qstar_high_percent >= 0.05: 
    96134            self.existing_warning = True 
    97135            msg += "The sum of all extrapolated contributions is higher " 
     
    132170        self.high_scale = self.get_scale(percentage=self.high_inv_percent, 
    133171                                         scale_name="Extrapolated at High Q") 
    134          
     172        
    135173        #Default color the extrapolation bar is grey 
    136174        self.extrapolation_color_low = wx.Colour(169,  169, 168, 128) 
     
    181219        unit_invariant = '[1/(cm * A)]' 
    182220      
    183         invariant_txt = wx.StaticText(self, -1, 'Invariant') 
     221        invariant_txt = wx.StaticText(self, -1, 'Q* from Data ') 
     222        invariant_txt.SetToolTipString("Invariant in the data set's Q range.") 
    184223        self.invariant_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    185224        self.invariant_tcl.SetToolTipString("Invariant in the data set's Q range.") 
    186225        self.invariant_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    187         self.invariant_err_tcl.SetToolTipString("Uncertainty on the invariant.") 
     226        self.invariant_err_tcl.SetToolTipString("Uncertainty on the invariant from data's range.") 
    188227        invariant_units_txt = wx.StaticText(self, -1, unit_invariant) 
     228        invariant_units_txt.SetToolTipString("Unit of the invariant from data's Q range") 
    189229        
    190         invariant_low_txt = wx.StaticText(self, -1, 'Invariant in low-Q region') 
     230        invariant_low_txt = wx.StaticText(self, -1, 'Q* from Low-Q') 
     231        invariant_low_txt.SetToolTipString("Extrapolated invariant from low-Q range.") 
    191232        self.invariant_low_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    192         self.invariant_low_tcl.SetToolTipString("Invariant computed with the extrapolated low-Q data.") 
     233        self.invariant_low_tcl.SetToolTipString("Extrapolated invariant from low-Q range.") 
    193234        self.invariant_low_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    194         self.invariant_low_err_tcl.SetToolTipString("Uncertainty on the invariant.") 
     235        self.invariant_low_err_tcl.SetToolTipString("Uncertainty on the invariant from low-Q range.") 
    195236        invariant_low_units_txt = wx.StaticText(self, -1,  unit_invariant) 
    196          
    197         invariant_high_txt = wx.StaticText(self, -1, 'Invariant in high-Q region') 
     237        invariant_low_units_txt.SetToolTipString("Unit of the extrapolated invariant from  low-Q range") 
     238         
     239        invariant_high_txt = wx.StaticText(self, -1, 'Q* from High-Q') 
     240        invariant_high_txt.SetToolTipString("Extrapolated invariant from  high-Q range") 
    198241        self.invariant_high_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    199         self.invariant_high_tcl.SetToolTipString("Invariant computed with the extrapolated high-Q data") 
     242        self.invariant_high_tcl.SetToolTipString("Extrapolated invariant from  high-Q range") 
    200243        self.invariant_high_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    201         self.invariant_high_err_tcl.SetToolTipString("Uncertainty on the invariant.") 
     244        self.invariant_high_err_tcl.SetToolTipString("Uncertainty on the invariant from high-Q range.") 
    202245        invariant_high_units_txt = wx.StaticText(self, -1,  unit_invariant) 
     246        invariant_high_units_txt.SetToolTipString("Unit of the extrapolated invariant from  high-Q range") 
    203247    
    204248        #Invariant low 
     
    308352            Check scale receive in this panel.  
    309353        """ 
     354        scale = RECTANGLE_SCALE 
    310355        try:  
    311             if percentage is None or percentage == 0.0: 
    312                  percentage = RECTANGLE_SCALE 
    313             percentage = float(percentage)  
     356            if percentage in [None, 0.0, "error"]: 
     357                 scale = RECTANGLE_SCALE 
     358                 return scale 
     359            scale = float(percentage)  
    314360        except: 
    315             percentage = RECTANGLE_SCALE 
     361            scale = RECTANGLE_SCALE 
    316362            self.warning_msg += "Receive an invalid scale for %s\n" 
    317363            self.warning_msg += "check this value : %s\n"%(str(scale_name),str(percentage)) 
    318         return  percentage 
     364        return  scale 
    319365     
    320366    def set_color_bar(self): 
     
    357403        #Draw low rectangle 
    358404        gc.PushState()         
    359         label = "Q* At Low-Q" 
     405        label = "Q* from Low-Q" 
    360406        PathFunc = gc.DrawPath 
    361407        w, h = gc.GetTextExtent(label) 
     
    367413        gc.SetPen(wx.Pen("black", 1)) 
    368414        gc.SetBrush(wx.Brush(self.extrapolation_color_low)) 
    369         low_percent = format_number(self.low_inv_percent*100)+ '%' 
     415        if self.low_inv_percent is None: 
     416            low_percent = 'Not Computed' 
     417        elif self.low_inv_percent == 'error': 
     418            low_percent = 'Error' 
     419        else: 
     420            low_percent = format_number(self.low_inv_percent*100)+ '%' 
    370421        x_center = 20 
    371422        y_center = -h 
     
    378429        gc.PushState()    # save it again 
    379430        y_origine += 20          
    380         gc.DrawText("Q* In range", x_origine, y_origine) 
     431        gc.DrawText("Q* from Data", x_origine, y_origine) 
    381432        # offset to the lower part of the window 
    382433        x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale/2 + w + 10 
     
    386437        gc.SetBrush(wx.Brush(wx.Colour(67,  208,  128, 128)))  
    387438        # Increase width by self.inv_scale 
    388         inv_percent = format_number(self.inv_percent*100)+ '%' 
     439        if self.inv_percent is None: 
     440            inv_percent = 'Not Computed' 
     441        elif self.inv_percent == 'error': 
     442            inv_percent = 'Error' 
     443        else: 
     444            inv_percent = format_number(self.inv_percent*100)+ '%' 
    389445        x_center = 20  
    390446        y_center = -h 
     
    397453        gc.PushState()  
    398454        y_origine += 20  
    399         gc.DrawText("Q* At High-Q", x_origine, y_origine)  
     455        gc.DrawText("Q* from High-Q", x_origine, y_origine)  
    400456        #define the position of the new rectangle 
    401457        x_center = x_origine + RECTANGLE_WIDTH * self.high_scale/2 + w + 10 
     
    404460        gc.SetBrush(wx.Brush(self.extrapolation_color_high))  
    405461        # increase scale by self.high_scale 
    406         high_percent = format_number(self.high_inv_percent*100)+ '%' 
     462        if self.high_inv_percent is None: 
     463            high_percent = 'Not Computed' 
     464        elif self.high_inv_percent == 'error': 
     465            high_percent = 'Error' 
     466        else: 
     467            high_percent = format_number(self.high_inv_percent*100)+ '%' 
    407468        x_center = 20 
    408469        y_center = -h 
     
    418479    container = InvariantContainer() 
    419480    container.qstar_total = 100.0 
    420     container.qstar = 15.0 
    421     container.qstar_low = 0.001 
    422     container.qstar_high = 100.0 
     481    container.qstar = 50 
     482    container.qstar_low = None 
     483    container.qstar_high = "alina" 
    423484    container.compute_percentage() 
     485    
    424486    dlg = InvariantDetailsPanel(qstar_container=container) 
    425487    dlg.ShowModal() 
  • invariantview/perspectives/invariant/invariant_panel.py

    r4e74e13 reed601e  
    879879        uncertainty = "+/-"  
    880880        unit_invariant = '[1/(cm * A)]' 
    881         invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total') 
     881        invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total [Q*]') 
    882882        self.invariant_total_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
    883         msg_hint = "Total invariant, including extrapolated regions." 
     883        msg_hint = "Total invariant [Q*], including extrapolated regions." 
    884884        self.invariant_total_tcl.SetToolTipString(msg_hint) 
    885885        self.invariant_total_err_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
Note: See TracChangeset for help on using the changeset viewer.